0% found this document useful (0 votes)
2 views59 pages

IntractabilityIII 207

The document discusses strategies for coping with NP-completeness, focusing on special cases like trees and planarity, as well as approximation algorithms for problems such as vertex cover and knapsack. It also covers exponential algorithms for 3-SAT and TSP, and presents dynamic programming solutions for weighted independent sets on trees. Additionally, it highlights the planarity of graphs and their implications for solving NP-complete problems more efficiently.

Uploaded by

Anindya Biswas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views59 pages

IntractabilityIII 207

The document discusses strategies for coping with NP-completeness, focusing on special cases like trees and planarity, as well as approximation algorithms for problems such as vertex cover and knapsack. It also covers exponential algorithms for 3-SAT and TSP, and presents dynamic programming solutions for weighted independent sets on trees. Additionally, it highlights the planarity of graphs and their implications for solving NP-complete problems more efficiently.

Uploaded by

Anindya Biswas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
Lecture slides by Kevin Wayne
Copyright © 2005 Pearson-Addison Wesley
h t t p : / / w w w . c s . p r i n c e t o n . e d u / ~w a y n e / k l e i n b e r g - t a r d o s

Abdur Rashid Tushar


Lecturer, CSE, BUET

Last updated on 27.07.23 07:21


Coping with NP-completeness

Q. Suppose I need to solve an NP-hard problem. What should I do?

A. Sacrifice one of three desired features.


i. Solve arbitrary instances of the problem.
ii. Solve problem to optimality.
iii. Solve problem in polynomial time.

Coping strategies.
i. Design algorithms for special cases of the problem. using greedy,
dynamic programming,
ii. Design approximation algorithms or heuristics. divide-and-conquer, and
network flow algorithms!
iii. Design algorithms that may take exponential time.

2
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
SECTION 10.2
Independent set on trees

Independent set on trees. Given a tree, find a max-cardinality subset of


nodes such that no two are adjacent.

Fact. A tree has at least one node that is a leaf (degree = 1).

Key observation. If node v is a leaf, there exists


a max-cardinality independent set containing v.
u
Pf. [exchange argument]
・Consider a max-cardinality independent set S. v

・If v ∈ S, we’re done.


・Otherwise, let (u, v) denote the lone edge incident to v.
- if u ∉ S and v ∉ S, then S ∪ { v } is independent ⇒ S not maximum
- if u ∈ S and v ∉ S, then S ∪ { v } − { u } is independent ▪

4
Independent set on trees: greedy algorithm

Theorem. The greedy algorithm finds a max-cardinality independent


set in forests (and hence trees).

Pf. Correctness follows from the previous key observation. ▪

INDEPENDENT-SET-IN-A-FOREST(F)
_________________________________ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ___

S ← ∅.
WHILE (F has at least 1 edge)
Let v be a leaf node and let (u, v) be the lone edge incident to v.
S ← S ∪ { v }.
F ← F – { u, v }. delete both u and v (including all incident edges)

RETURN S ∪ { nodes remaining in F }.

Remark. Can implement in O(n) time by maintaining nodes of degree 1.

5
Intractability III: quiz 1

How might the greedy algorithm fail if the graph is not a tree/forest?

A. Might get stuck. (resulting) graph may not have a leaf node

if algorithm can always find a leaf node, then it finds


B. Might take exponential time. a max-cardinality independent set in O(m + n) time

C. Might produce a suboptimal independent set.

D. Any of the above.

6
Weighted independent set on trees

Weighted independent set on trees. Given a tree and node weights wv ≥ 0,


find an independent set S that maximizes Σ v ∈ S wv.

Greedy algorithm can fail spectacularly.

u weight = huge

7
Weighted independent set on trees

Weighted independent set on trees. Given a tree and node weights wv ≥ 0,


find an independent set S that maximizes Σ v ∈ S wv.

Dynamic-programming solution. Root tree at some node, say r.


・OPTin (u) = max-weight IS in subtree rooted at u, containing u.
・OPTout (u) = max-weight IS in subtree rooted at u, not containing u.
・Goal: max { OPTin (r), OPTout (r) }.

overlapping r
subproblems
Bellman equation.

v w x

children(u) = { v, w, x }
8
Intractability III: quiz 2

In which order to solve the subproblems?

A. Preorder.

B. Postorder. all descendants of a node processed before node

C. Level order.

D. Any of the above.

9
Weighted independent set on trees: dynamic-programming
algorithm

Theorem. The DP algorithm computes max weight of an independent set


in a tree in O(n) time. can also find independent set itself
(not just value)

WEIGHTED-INDEPENDENT-SET-IN-A-TREE (T)
_________________________________ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ___

Root the tree T at any node r.


S ← ∅.
FOREACH (node u of T in postorder/topological order)
IF (u is a leaf node)
ensures a node is processed
Min[u] = wu.
after all of its descendants
Mout[u] = 0.
ELSE
Min[u] = wu + Σv ∈ children(u) Mout[v].
Mout[u] = Σv ∈ children(u) max { Min[v], Mout[v] }.
RETURN max { Min[r], Mout[r] }.

10
NP-hard problems on trees: context

Independent set on trees. Tractable because we can find a node that breaks
the communication among the subproblems in different subtrees.

T T
T1
2 3

11
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
SECTION 23.1
Planarity

Def. A graph is planar if it can be embedded in the plane in such a way that
no two edges cross.

K5 is nonplanar K3,3 is nonplanar

planar

Applications. VLSI circuit design, computer graphics, ...

13
Planarity testing

Theorem. [Hopcroft–Tarjan 1974] There exists an O(n) time algorithm to


determine whether a graph is planar.
simple planar graph
has at ≤ 3n edges

14
Problems on planar graphs

Fact 0. Many graph problems can be solved faster in planar graphs.


Ex. Shortest paths, max flow, MST, matchings, …

Fact 1. Some NP-complete problems become tractable in planar graphs.


Ex. MAX-CUT, ISING, CLIQUE, GRAPH-ISOMORPHISM, 4-COLOR, ...

Fact 2. Other NP-complete problems become easier in planar graphs.


Ex. INDEPENDENT-SET, VERTEX-COVER, TSP, STEINER-TREE, ...

15
Planar graph 3-colorability

PLANAR-3-COLOR. Given a planar graph, can it be colored using 3 colors


so that no two adjacent nodes have the same color?

16
Planar map 3-colorability

PLANAR-MAP-3-COLOR. Given a planar map, can it be colored using 3 colors


so that no two adjacent regions have the same color?

yes instance

17
Planar map 3-colorability

PLANAR-MAP-3-COLOR. Given a planar map, can it be colored using 3 colors


so that no two adjacent regions have the same color?

no instance

18
Planar graph and map 3-colorability reduce to one another

Theorem. PLANAR-3-COLOR ≣ P PLANAR-MAP-3-COLOR.


Pf sketch.
・Nodes correspond to regions.
・Two nodes are adjacent iff they share a nontrivial border.
e.g., not Arizona
and Colorado

19
Planar 3-colorability is NP-complete

Theorem. PLANAR-3-COLOR ∈ NP-complete.

Pf.
・Easy to see that PLANAR-3-COLOR ∈ NP.
・We show 3-COLOR ≤ P PLANAR-3-COLOR.
・Given 3-COLOR instance G, we construct an instance of
PLANAR-3-COLOR that is 3-colorable iff G is 3-colorable.

20
Planar map k-colorability

Theorem. [Appel–Haken 1976] Every planar map is 4-colorable.


・Resolved century-old open problem.
・Used 50 days of computer time to deal with many special cases.
・First major theorem to be proved using computer.

Remarks.
・Appel–Haken yields O(n4) algorithm to 4-color of a planar map.
・Best known: O(n2) to 4-color; O(n) to 5-color.
・Determining whether 3 colors suffice is NP-complete.
25
Poly-time special cases of NP-hard problems

Trees. VERTEX-COVER, INDEPENDENT-SET, LONGEST-PATH, GRAPH-ISOMORPHISM, ...


Bipartite graphs. VERTEX-COVER, INDEPENDENT-SET, 3-COLOR, EDGE-COLOR, …
Planar graphs. MAX-CUT, ISING, CLIQUE, GRAPH-ISOMORPHISM, 4-COLOR, ...
Bounded treewidth. HAM-CYCLE, INDEPENDENT-SET, GRAPH-ISOMORPHISM, ...
Small integers. SUBSET-SUM, KNAPSACK, PARTITION, ...

tree bipartite planar bounded treewidth


27
10. E XTENDING T RACTABILITY

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms
‣ register allocation
‣ exponential algorithms
Register allocation

Register. One of k of high-speed memory locations in computer’s CPU.


say 32
Register allocator. Part of an optimizing compiler that controls which
variables are saved in the registers as compiled program executes.
variables or temporaries

Interference graph. Nodes are “live ranges.” Edge (u, v) if there exists an
operation where both u and v are “live” at the same time.

Observation. [Chaitin 1982] Can solve register allocation problem iff


interference graph is k-colorable.

Spilling. If graph is not k-colorable (or we can’t find a k-coloring), we “spill”


certain variables to main memory and swap back as needed.

typically infrequently used


variables that are not in inner loops

29
A useful property

Remark. Register allocation problem is NP-hard.

Key fact. If a node v in graph G has fewer than k neighbors,


G is k-colorable iff G − { v } is k-colorable.

delete v and all incident edges

Pf. Delete node v from G and color G − { v }.


・If G − { v } is not k-colorable, then neither is G.
・If G − { v } is k-colorable, then ≥ 1 remaining color left for v. ▪

v
k=3 k=2

G is 2-colorable even though


all nodes have degree 2
30
Chaitin’s algorithm

Vertex-Color(G, k) { say, node with fewest neighbors

while (G is not empty) {

Pick a node v with fewer than k neighbors

Push v on stack

Delete v and all its incident edges

while (stack is not empty) {

Pop next node v from the stack

Assign v a color different from its neighboring

nodes which have already been colored

31
Chaitin’s algorithm

Theorem. [Kempe 1879, Chaitin 1982] Chaitin’s algorithm produces a


k-coloring of any graph with max degree k – 1.
Pf. Follows from key fact since each node has fewer than k neighbors.

algorithm succeeds in k-coloring


many graphs with max degree ≥ k

Remark. If algorithm never encounters a graph where all nodes have


degree ≥ k, then it produces a k-coloring.

Practice. Chaitin’s algorithm (and variants) are extremely effective and


widely used in real compilers for register allocation.

32
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
SECTION 11.8
Approximation algorithms

r-approximation algorithm.
・Runs in polynomial time.
・Applies to arbitrary instances of the problem.
・Guaranteed to find a solution within ratio r of true optimum.
Ex. Given a graph G, can find a vertex cover that uses ≤ 2 OPT(G) vertices
in O(m + n) time.

Challenge. Need to prove a solution’s value is close to optimum value,


without even knowing what optimum value is!

34
Vertex cover

VERTEX-COVER. Given a graph G = (V, E), find a min-size vertex cover.

for each edge (u, v) ∈ E:


either u ∈ S, v ∈ S, or both

vertex cover of size 4

35
Vertex cover: greedy algorithm

VERTEX-COVER. Given a graph G = (V, E), find a min-size vertex cover.

GREEDY-VERTEX-COVER(G)
_________________________________ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ __

S ← ∅.
E′ ← E.
WHILE (E′ ≠ ∅) every vertex cover must take
at least one of these; we take both
Let (u, v) ∈ E′ be an arbitrary edge.
M ← M ∪ {(u, v)}. M is a matching
S ← S ∪ {u} ∪ {v}.
Delete from E′ all edges incident to either u or v.
RETURN S.

Running time. Can be implemented in O(m + n) time.

36
Intractability III: quiz 3

Given a graph G, let M be any matching and let S be any vertex cover. Which
of the following must be true?

A. ⎢ M ⎢ ≤ ⎢S ⎢

B. ⎢ S ⎢ ≤ ⎢M ⎢

C. ⎢ S ⎢ = ⎢M ⎢

D. None of the above.

strong duality holds for bipartite graphs


Weak duality. ⎢ M ⎢ ≤ ⎢ S ⎢. (recall problem set #7)
Pf.
・For each edge (u, v) ∈ M : S must contain either u, or v, or both.
・Edges in M have no common endpoints. ▪
37
Vertex cover: greedy algorithm is a 2-approximation algorithm

Theorem. Let S * be a minimum vertex cover. Then, greedy algorithm


computes a vertex cover S with ⎢ S ⎢ ≤ 2 ⎢ S * ⎢. 2-approximation algorithm

Pf.
・S is a vertex cover. delete edge only after it’s already covered

・M is a matching. when (u, v) added to M, all edges incident to either u or v are deleted

・⎢ S ⎢ = 2 ⎢ M ⎢ ≤ 2 ⎢ S * ⎢. ▪

design weak duality

Corollary. Let M * be a maximum matching. Then, greedy algorithm


computes a matching M with ⎢ M ⎢ ≥ ½ ⎢ M * ⎢.
Pf. ⎢ M ⎢ = ½ ⎢ S ⎢ ≥ ½ ⎢ M * ⎢. ▪

weak duality

38
Vertex cover inapproximability

Theorem. [Dinur–Safra 2004] If P  NP, then no r-approximation for


VERTEX-COVER for any r < 1.3606.

Open research problem. Close the gap.


Conjecture. no r-approximation for VERTEX-COVER for any r < 2.

39
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
SECTION 11.8
Knapsack problem

Knapsack problem.
・Given n objects and a knapsack.
・Item i has value vi > 0 and weighs wi > 0. we assume w ≤ W for each i
i

・Knapsack has weight limit W.


・Goal: fill knapsack so as to maximize total value.
Ex: { 3, 4 } has value 40.

item value weight

1 1 1

2 6 2

3 18 5

4 22 6

5 28 7

original instance (W = 11)

41
Knapsack is NP-complete

SUBSET-SUM. Given a set X, values ui ≥ 0, and an integer U, is there a subset


S ⊆ X whose elements sum to exactly U ?

KNAPSACK. Given a set X, weights wi ≥ 0, values vi ≥ 0, a weight limit W, and a


target value V, is there a subset S ⊆ X such that:

Theorem. SUBSET-SUM ≤ P KNAPSACK.


Pf. Given instance (u1, …, un, U) of SUBSET-SUM, create KNAPSACK instance:

42
Knapsack problem: dynamic programming I

Def. OPT(i, w) = max value subset of items 1,..., i with weight limit w.

Case 1. OPT does not select item i.


・OPT selects best of 1, …, i – 1 using up to weight limit w.
Case 2. OPT selects item i.
・New weight limit = w – wi.
・OPT selects best of 1, …, i – 1 using up to weight limit w – wi.

Theorem. Computes the optimal value in O(n W) time.


・Not polynomial in input size.
・Polynomial in input size if weights are small integers.
43
Knapsack problem: dynamic programming II

Def. OPT(i, v) = min weight of a knapsack for which we can obtain a solution
of value ≥ v using a subset of items 1,..., i.

Note. Optimal value is the largest value v such that OPT(n, v) ≤ W.

Case 1. OPT does not select item i.


・OPT selects best of 1, …, i – 1 that achieves value ≥ v.
Case 2. OPT selects item i.
・Consumes weight wi, need to achieve value ≥ v – vi.
・OPT selects best of 1, …, i – 1 that achieves value ≥ v – vi.

44
Knapsack problem: dynamic programming II

Theorem. Dynamic programming algorithm II computes the optimal value


in O(n2 vmax) time, where vmax is the maximum of any value.
Pf.
・The optimal value V* ≤ n vmax.
・There is one subproblem for each item and for each value v ≤ V*.
・It takes O(1) time per subproblem. ▪
Remark 1. Not polynomial in input size!
Remark 2. Polynomial time if values are small integers.

45
Knapsack problem: poly-time approximation scheme

Intuition for approximation algorithm.


・Round all values up to lie in smaller range.
・Run dynamic programming algorithm II on rounded/scaled instance.
・Return optimal items in rounded instance.

item value weight item value weight

1 934221 1 1 1 1

2 5956342 2 2 6 2

3 18 5
1781001
3 5
3 4 22 6

2121780 5 28 7
4 6
0
original instance (W = 11) rounded instance (W = 11)
2734319
5 7
9

46
Knapsack problem: poly-time approximation scheme

Round up all values:


・0 < ε ≤ 1 = precision parameter.
・vmax = largest value in original instance.
・θ = scaling factor = ε vmax / 2n.

Observation. Optimal solutions to problem with are equivalent to


optimal solutions to problem with .

Intuition. close to v so optimal solution using is nearly optimal;


small and integral so dynamic programming algorithm II is fast.

47
Knapsack problem: poly-time approximation scheme

Theorem. If S is solution found by rounding algorithm and S*


is any other feasible solution, then

Pf. Let S* be any feasible solution satisfying weight constraint.

subset containing
always round up only the item
of largest value

solve rounded
instance optimally
choosing S* = { max }
never round up
by more than θ

|S| ≤ n
thus

θ = ε vmax / 2n

vmax ≤ 2 Σi ∈ S vi

48
Knapsack problem: poly-time approximation scheme

Theorem. For any ε > 0, the rounding algorithm computes a feasible solution
whose value is within a (1 + ε) factor of the optimum in O(n3 / ε) time.

Pf.
・We have already proved the accuracy bound.
・Dynamic program II running time is , where

49
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
Exact exponential algorithms

Complexity theory deals with worst-case behavior.


・Instances you want to solve may be “easy.”

“ For every polynomial-time algorithm you have, there is an exponential


algorithm that I would rather run.” — Alan Perlis

52
I NTRACTABILITY III

‣ special cases: trees


‣ special cases: planarity
‣ approximation algorithms: vertex
cover
‣ approximation algorithms: knapsack
‣ exponential algorithms: 3-SAT
‣ exponential algorithms: TSP
Pokemon Go

Given the locations of n Pokémon, find shortest tour to collect them all.

63
Traveling salesperson problem

TSP. Given a set of n cities and a pairwise distance function d(u, v),
is there a tour of length ≤ D ?
can view as a complete graph

13,509 cities in the United States


http://www.math.uwaterloo.ca/tsp 64
Traveling salesperson problem

TSP. Given a set of n cities and a pairwise distance function d(u, v),
is there a tour of length ≤ D ?

11,849 holes to drill in a programmed logic array


http://www.math.uwaterloo.ca/tsp 65
TSP books, apps, and movies

66
Hamilton cycle reduces to traveling salesperson problem

TSP. Given a set of n cities and a pairwise distance function d(u, v),
is there a tour of length ≤ D ?

HAMILTON-CYCLE. Given an undirected graph G = (V, E), does there exist a


cycle that visits every node exactly once?

Theorem. HAMILTON-CYCLE ≤ P TSP.


Pf.
・Given an instance G = (V, E) of HAMILTON-CYCLE, create n = ⎜ V ⎜ cities
with distance function

・TSP instance has tour of length ≤ n iff G has a Hamilton cycle. ▪

67
Intractability III: quiz 4

What is complexity of TSP? Choose the best answer.

A. O(n2) would imply P = NP

B. O*(1.657 n) known for HAMILTON-CYCLE but not TSP

C. O*(2n) coming next

D. O*(n!) there are ½ (n – 1)! tours

O* hides poly(n) terms

68
Exponential algorithm for TSP: dynamic programming

Theorem. [Held–Karp, Bellman 1962] TSP can be solved in O(n2 2n) time.

HAMILTON-CYCLE is a special case

70
Exponential algorithm for TSP: dynamic programming

Theorem. [Held–Karp, Bellman 1962] TSP can be solved in O(n2 2n) time.

Pf. [dynamic programming] pick node s arbitrarily

・Subproblems: c(s, v, X) = cost of cheapest path between s and v ≠ s


that visits every node in X exactly once (and uses only nodes in X).
・Goal:
・There are ≤ n 2n subproblems and they satisfy the recurrence:

v s
・The values c(s, v, X) can be computed in increasing
order of the cardinality of X. ▪

71
22-city TSP instance takes 1,000 years

222 = 4,194,304

22! = 1,124,000,727,777,607,680,000 ~ 10 21

73
Concorde TSP solver

Concorde TSP solver. [Applegate–Bixby–Chvátal–Cook]


・Linear programming + branch-and-bound + polyhedral combinatorics.
・Greedy heuristics, including Lin–Kernighan.
・MST, Delaunay triangulations, fractional b-matchings, ...
Remarkable fact. Concorde has solved all 110 TSPLIB instances.

largest instance has 85,900 cities!

74
Euclidean traveling salesperson problem

Euclidean TSP. Given n points in the plane and a real number L, is there a
tour that visit every city exactly once that has distance ≤ L ?

Fact. 3-SAT ≤ P EUCLIDEAN-TSP.


Remark. Not known to be in NP.
8.928198407 < 8.928203230

using rounded weights

13509 cities in the USA and an optimal tour


75
Euclidean traveling salesperson problem

Theorem. [Arora 1998, Mitchell 1999] Given n points in the plane, for any
constant ε > 0: there exists a poly-time algorithm to find a tour whose length
is at most (1 + ε) times that of the optimal tour.

Pf recipe. Structure theorem + divide-and-conquer + dynamic programming.

76

You might also like