How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
How bad is GreedyVertexCover ? Understanding the graph... Top row has n vertices. 1 Bottom row has 2 Upper bound: 1 α = � n i =2 ⌊ n/i ⌋ ≤ � n i =1 n/i ≤ nH n = O ( n log n ) . Lower bound: α = � n i =2 ⌊ n/i ⌋ ≥ 2 � n i =1 n/i − ( n − 1) − n ≥ n ( H n − 2) ≥ n (ln n − 2) . Bottom row has Θ( n log n ) vertices. 3 Greedy algorithm returns bottom row Θ( n log n ) vertices. 3 Optimal solution is top row: n vertices. 4 Greedy algorithm is O (log n ) approximation in this case. 5 Sariel (UIUC) New CS473 10 Fall 2015 10 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Some math required � n n 1 1 � H n = i ≤ 1 + xdx = 1 + ln n − ln 1 = 1 + ln n. x =1 i =1 � �� � � i +1 1 / ( i +1) ≤ x = i (1 /x ) dx � n +1 n 1 1 � i ≥ = ln( n + 1 − ln 1 = ln( n + 1) H n = xdx x =1 i =1 � �� � � i +1 1 1 i ≥ x dx x = i ≥ ln n. Lemma For H n = � n i =1 1 /i we have that ln n ≤ H n ≤ 1 + ln n . Sariel (UIUC) New CS473 11 Fall 2015 11 / 39
Greedy Vertex Cover Theorem The greedy algorithm for VertexCover achieves Θ(log n ) approximation, where n (resp. m ) is the number of vertices (resp., edges) in the graph. Running time is O ( mn 2 ) . Proof Lower bound follows from lemma. Upper bound follows from analysis of greedy algorithm for Set Cover , which will be done shortly. As for the running time, each iteration of the algorithm takes O ( mn ) time, and there are at most n iterations. Sariel (UIUC) New CS473 12 Fall 2015 12 / 39
8.1.1: A better greedy algorithm: Two for the price of one Sariel (UIUC) New CS473 13 Fall 2015 13 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one - example Sariel (UIUC) New CS473 14 Fall 2015 14 / 39
Two for the price of one ApproxVertexCover ( G ): S ← ∅ while E ( G ) � = ∅ do uv ← any edge of G S ← S ∪ { u, v } Remove u, v from V ( G ) Remove all edges involving u or v from E ( G ) return S Theorem ApproxVertexCover is a 2 -approximation algorithm for VertexCoverMin that runs in O ( n 2 ) time. Proof ... Sariel (UIUC) New CS473 15 Fall 2015 15 / 39
8.2: Fixed parameter tractability, approximation, and fast exponential time algorithms (to say nothing of the dog) Sariel (UIUC) New CS473 16 Fall 2015 16 / 39
8.2.1: A silly brute force algorithm for vertex cover Sariel (UIUC) New CS473 17 Fall 2015 17 / 39
What if the vertex cover is small? G = ( V , E ) with n vertices 1 K ← Approximate VertexCoverMin up to a factor of two. 2 Any vertex cover of G is of size ≥ K/ 2 . 3 � n K +2 � Naively compute optimal in O time. 4 Sariel (UIUC) New CS473 18 Fall 2015 18 / 39
Neighborhood of a vertex Definition N G ( v ) : Neighborhood of v – set of vertices of G adjacent to v . v N G ( v ) Sariel (UIUC) New CS473 19 Fall 2015 19 / 39
Induced subgraph Definition Let G = ( V , E ) be a graph. For a subset S ⊆ V , let G S be the induced subgraph over S . Sariel (UIUC) New CS473 20 Fall 2015 20 / 39
Induced subgraph Definition Let G = ( V , E ) be a graph. For a subset S ⊆ V , let G S be the induced subgraph over S . Sariel (UIUC) New CS473 20 Fall 2015 20 / 39
Induced subgraph Definition Let G = ( V , E ) be a graph. For a subset S ⊆ V , let G S be the induced subgraph over S . Sariel (UIUC) New CS473 20 Fall 2015 20 / 39
Induced subgraph Definition Let G = ( V , E ) be a graph. For a subset S ⊆ V , let G S be the induced subgraph over S . Sariel (UIUC) New CS473 20 Fall 2015 20 / 39
8.2.2: Fixed parameter algorithm Sariel (UIUC) New CS473 21 Fall 2015 21 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Exact algorithm for Set Cover G : Input graph. 1 Opt = min size vertex cover for G . opt = | Opt | . 2 Compute a set S ⊆ V ( G ) s.t. | S | ≤ 2 opt . 3 Takes: O ( n + m ) time. Enumerate over all possible X ⊆ S : 4 Check if X is vertex cover in G . 1 Takes O ( n + m ) time. Return smallest VC encountered. 5 Running time: O (2 2 opt ( n + m ) + n + m ) = O (2 2 opt m ) . 6 Sariel (UIUC) New CS473 22 Fall 2015 22 / 39
Summary of result Theorem Given a graph G with n vertices and m ( ≥ n ) edges, and with a vertex cover of size k . Then, one can compute the optimal vertex cover in G in O (2 2 k m ) time. Note, that running time is Fixed Parameter Tractable . Sariel (UIUC) New CS473 23 Fall 2015 23 / 39
8.3: Traveling Salesperson Problem Sariel (UIUC) New CS473 24 Fall 2015 24 / 39
TSP TSP-Min Instance : G = ( V, E ) a complete graph, and ω ( e ) a cost function on edges of G . Question: The cheapest tour that visits all the vertices of G exactly once. Solved exactly naively in ≈ n ! time. Using DP, solvable in O ( n 2 2 n ) time. Sariel (UIUC) New CS473 25 Fall 2015 25 / 39
TSP TSP-Min Instance : G = ( V, E ) a complete graph, and ω ( e ) a cost function on edges of G . Question: The cheapest tour that visits all the vertices of G exactly once. Solved exactly naively in ≈ n ! time. Using DP, solvable in O ( n 2 2 n ) time. Sariel (UIUC) New CS473 25 Fall 2015 25 / 39
TSP Hardness Theorem TSP-Min can not be approximated within any factor unless NP = P . Proof. Reduction from Hamiltonian Cycle into TSP . 1 G = ( V , E ) : instance of Hamiltonian cycle. 2 J : Complete graph over V . 3 � uv ∈ E 1 ∀ u, v ∈ V w J ( uv ) = 2 otherwise . ∃ tour of price n in J ⇐ ⇒ ∃ Hamiltonian cycle in G . 4 No Hamiltonian cycle = ⇒ TSP price at least n + 1 . 5 But... replace 2 by cn , for c an arbitrary number 6 Sariel (UIUC) New CS473 26 Fall 2015 26 / 39
TSP Hardness Theorem TSP-Min can not be approximated within any factor unless NP = P . Proof. Reduction from Hamiltonian Cycle into TSP . 1 G = ( V , E ) : instance of Hamiltonian cycle. 2 J : Complete graph over V . 3 � uv ∈ E 1 ∀ u, v ∈ V w J ( uv ) = 2 otherwise . ∃ tour of price n in J ⇐ ⇒ ∃ Hamiltonian cycle in G . 4 No Hamiltonian cycle = ⇒ TSP price at least n + 1 . 5 But... replace 2 by cn , for c an arbitrary number 6 Sariel (UIUC) New CS473 26 Fall 2015 26 / 39
TSP Hardness Theorem TSP-Min can not be approximated within any factor unless NP = P . Proof. Reduction from Hamiltonian Cycle into TSP . 1 G = ( V , E ) : instance of Hamiltonian cycle. 2 J : Complete graph over V . 3 � uv ∈ E 1 ∀ u, v ∈ V w J ( uv ) = 2 otherwise . ∃ tour of price n in J ⇐ ⇒ ∃ Hamiltonian cycle in G . 4 No Hamiltonian cycle = ⇒ TSP price at least n + 1 . 5 But... replace 2 by cn , for c an arbitrary number 6 Sariel (UIUC) New CS473 26 Fall 2015 26 / 39
TSP Hardness Theorem TSP-Min can not be approximated within any factor unless NP = P . Proof. Reduction from Hamiltonian Cycle into TSP . 1 G = ( V , E ) : instance of Hamiltonian cycle. 2 J : Complete graph over V . 3 � uv ∈ E 1 ∀ u, v ∈ V w J ( uv ) = 2 otherwise . ∃ tour of price n in J ⇐ ⇒ ∃ Hamiltonian cycle in G . 4 No Hamiltonian cycle = ⇒ TSP price at least n + 1 . 5 But... replace 2 by cn , for c an arbitrary number 6 Sariel (UIUC) New CS473 26 Fall 2015 26 / 39
TSP Hardness - proof continued Proof. Price of all tours are either: 1 (i) n (only if ∃ Hamiltonian cycle in G ), (ii) larger than cn + 1 (actually, ≥ cn + ( n − 1) ). Suppose you had a poly time c -approximation to TSP-Min. 2 Run it on J : 3 (i) If returned value ≥ cn + 1 = ⇒ no Ham Cycle since ( cn + 1) /c > n (ii) If returned value ≤ cn = ⇒ Ham Cycle since OP T ≤ cn < cn + 1 c -approximation algorithm to TSP = ⇒ poly-time algorithm 4 for NP-Complete problem. Possible only if P = NP . Sariel (UIUC) New CS473 27 Fall 2015 27 / 39
TSP Hardness - proof continued Proof. Price of all tours are either: 1 (i) n (only if ∃ Hamiltonian cycle in G ), (ii) larger than cn + 1 (actually, ≥ cn + ( n − 1) ). Suppose you had a poly time c -approximation to TSP-Min. 2 Run it on J : 3 (i) If returned value ≥ cn + 1 = ⇒ no Ham Cycle since ( cn + 1) /c > n (ii) If returned value ≤ cn = ⇒ Ham Cycle since OP T ≤ cn < cn + 1 c -approximation algorithm to TSP = ⇒ poly-time algorithm 4 for NP-Complete problem. Possible only if P = NP . Sariel (UIUC) New CS473 27 Fall 2015 27 / 39
TSP Hardness - proof continued Proof. Price of all tours are either: 1 (i) n (only if ∃ Hamiltonian cycle in G ), (ii) larger than cn + 1 (actually, ≥ cn + ( n − 1) ). Suppose you had a poly time c -approximation to TSP-Min. 2 Run it on J : 3 (i) If returned value ≥ cn + 1 = ⇒ no Ham Cycle since ( cn + 1) /c > n (ii) If returned value ≤ cn = ⇒ Ham Cycle since OP T ≤ cn < cn + 1 c -approximation algorithm to TSP = ⇒ poly-time algorithm 4 for NP-Complete problem. Possible only if P = NP . Sariel (UIUC) New CS473 27 Fall 2015 27 / 39
TSP Hardness - proof continued Proof. Price of all tours are either: 1 (i) n (only if ∃ Hamiltonian cycle in G ), (ii) larger than cn + 1 (actually, ≥ cn + ( n − 1) ). Suppose you had a poly time c -approximation to TSP-Min. 2 Run it on J : 3 (i) If returned value ≥ cn + 1 = ⇒ no Ham Cycle since ( cn + 1) /c > n (ii) If returned value ≤ cn = ⇒ Ham Cycle since OP T ≤ cn < cn + 1 c -approximation algorithm to TSP = ⇒ poly-time algorithm 4 for NP-Complete problem. Possible only if P = NP . Sariel (UIUC) New CS473 27 Fall 2015 27 / 39
TSP with the triangle inequality Because it is not that bad after all. TSP △� = -Min Instance : G = ( V, E ) is a complete graph. There is also a cost function ω ( · ) defined over the edges of G , that complies with the triangle inequality. Question: The cheapest tour that visits all the vertices of G exactly once. triangle inequality : ω ( · ) if ∀ u, v, w ∈ V ( G ) , ω ( u, v ) ≤ ω ( u, w ) + ω ( w, v ) . Shortcutting σ : a path from s to t in G = ⇒ ω ( st ) ≤ ω ( σ ) . Sariel (UIUC) New CS473 28 Fall 2015 28 / 39
TSP with the triangle inequality Because it is not that bad after all. TSP △� = -Min Instance : G = ( V, E ) is a complete graph. There is also a cost function ω ( · ) defined over the edges of G , that complies with the triangle inequality. Question: The cheapest tour that visits all the vertices of G exactly once. triangle inequality : ω ( · ) if ∀ u, v, w ∈ V ( G ) , ω ( u, v ) ≤ ω ( u, w ) + ω ( w, v ) . Shortcutting σ : a path from s to t in G = ⇒ ω ( st ) ≤ ω ( σ ) . Sariel (UIUC) New CS473 28 Fall 2015 28 / 39
TSP with the triangle inequality Because it is not that bad after all. TSP △� = -Min Instance : G = ( V, E ) is a complete graph. There is also a cost function ω ( · ) defined over the edges of G , that complies with the triangle inequality. Question: The cheapest tour that visits all the vertices of G exactly once. triangle inequality : ω ( · ) if ∀ u, v, w ∈ V ( G ) , ω ( u, v ) ≤ ω ( u, w ) + ω ( w, v ) . Shortcutting σ : a path from s to t in G = ⇒ ω ( st ) ≤ ω ( σ ) . Sariel (UIUC) New CS473 28 Fall 2015 28 / 39
TSP with the triangle inequality Continued... Definition Cycle in G is Eulerian if it visits every edge of G exactly once. Assume you already seen the following: Lemma A graph G has a cycle that visits every edge of G exactly once (i.e., an Eulerian cycle) if and only if G is connected, and all the vertices have even degree. Such a cycle can be computed in O ( n + m ) time, where n and m are the number of vertices and edges of G , respectively. Sariel (UIUC) New CS473 29 Fall 2015 29 / 39
Recommend
More recommend