1 TSP with triangle inequality Travelling Salesman Problem (TSP)
In many practical situations, it is always cheapest to go directly from a
place u to a place w; rather going by way of any intermediate stop v.
The triangle inequality is a natural one, and in many applications it is satisfied.
For example, if the vertices of the graph are points in the plane and the cost of traveling between two vertices is the euclidean distance between them, then the triangle inequality is satisfied. TSP with triangle inequality Approx-TSP Tour Input: A complete graph G (V, E) Output: A Hamiltonian cycle 1. Select a “root” vertex r ∈V [G]. 2. Use MST-Prim (G, c, r) to compute a minimum spanning tree from r. 3. Let L to be the sequence of vertices visited in a preorder tree walk of T. 4. Return the Hamiltonian cycle H that visits the vertices in the order L. TSP with triangle inequality Example: TSP with triangle inequality Theorem: APPROX-TSP-TOUR is a polynomial-time 2-approximation algorithm for the TSP problem with triangle inequality. Proof: Since a minimum spanning tree T and its preorder traversal can be found in polynomial time, APPROX-TSP-TOUR is a polynomial-time algorithm. Let H* denote an optimal tour for the given set of vertices. Since we obtain a spanning tree by deleting any edge from a tour, if T is a minimum spanning tree for the given set of vertices, then c(T) ≤ c(H*) (1) TSP with triangle inequality A full walk (preorder) of T lists the vertices when they are first visited and also whenever they are returned to after a visit to a subtree. Let us call this walk W. The full walk of our example gives the order • a, b, c, b, h, b, a, d, e, f, e, g, e, d, a. Since the full walk traverses every edge of T exactly twice, we have c(W) = 2c(T) (2) Combining equations (1) and (2) we get c(W) ≤ 2c(H*) (3) TSP with triangle inequality Unfortunately, W is generally not a tour, since it visits some vertices more than once. By the triangle inequality, however, we can delete a visit to any vertex from W and the cost does not increase. (If a vertex v is deleted from W between visits to u and w, the resulting ordering specifies going directly from u to w.) By repeatedly applying this operation, we can remove from W all but the first visit to each vertex. In our example, this leaves the ordering a, b, c, h, d, e, f, g . TSP with triangle inequality Let H be the cycle corresponding to this preorder walk. It is a hamiltonian cycle, since every vertex is visited exactly once. Since H is obtained by deleting vertices from the full walk W, we have c(H) ≤ c(W) (4) Combining (3) & (4) we get c(H) ≤ 2c(H*) TSP with triangle inequality Observe: The approximation ratio is 2 due to doubling edges. We did this in order to obtain an Eulerian tour. But any graph in which all vertices have even degree is Eulerian, so we can still get an Eulerian tour by adding edges only between odd degree vertices in T. Christofides Algorithm exploits this and improves the approximation ratio from 2 to 3/2. Christofides Algorithm Theorem: There exists a 1.5-approximation algorithm for TSP with triangle inequality. Proof: • Find a minimum spanning tree T for (G, c). • Let S be the vertices of odd degree in T. (Note: |S| is even) • M be the min cost perfect matching of odd degree nodes in T • Assume this can be done in polynomial time Christofides Algorithm Let G’ union of spanning tree and matching edges.
In G’ every vertex is of even degree.
So G’ has an Eulerian Tour say E
E:abcbhfegeda Christofides Algorithm
Let H be the cycle corresponding to E
We can prove that c(H) ≤ 3/2c(H*)
Alternate Greedy Algorithm Nearest Neighbor Algorithm (NNA): Start at an arbitrary vertex s, While (there are unvisited vertices) From the current vertex u, go to the nearest unvisited vertex v Return to s. Theorem: NNA is an O(log n)-approximation algorithm Exercise: NNA is not an O(1)-approximation algorithm. General TSP (without triangle inequality)
Suppose we drop the assumption that the cost function c
satisfies the triangle inequality. Then good approximate tours cannot be found in polynomial time unless P = NP. Theorem: If P ≠ NP, then for any constant ρ ≥ 1, there is no polynomial-time approximation algorithm with approximation ratio ρ for the general traveling-salesman problem. General TSP (without triangle inequality) Proof: The proof is by contradiction. Suppose to the contrary that for some number ρ ≥ 1, there is a polynomial-time ρ -approximation algorithm A. Without loss of generality, we assume that ρ is an integer, by rounding it up if necessary. We shall show how to use A to solve instances of the hamiltonian-cycle problem in polynomial time. Since the hamiltonian-cycle problem is NP-complete, solving it in polynomial time implies that P = NP. General TSP (without triangle inequality) Let G = (V, E) be an instance of the hamiltonian-cycle problem. We wish to determine efficiently whether G contains a hamiltonian cycle by making use of the hypothesized approximation algorithm A. We turn G into an instance of the traveling-salesman problem as follows. Let G' = (V, E') be the complete graph on V; that is, E' = {(u, v): u, v V and u ≠ v}. Assign an integer cost to each edge in E' as follows: General TSP (without triangle inequality) We can construct G' and c from a representation of G in time polynomial in |V| and |E|. Now, consider the traveling-salesman problem (G', c). Observe: • If the original graph G has a hamiltonian cycle H, then the cost function c assigns to each edge of H a cost of 1, and so (G', c) contains a tour of cost |V|. • On the other hand, if G does not contain a hamiltonian cycle, then any tour of G' must use some edge not in E. But any tour that uses an edge not in E has a cost of at least General TSP (without triangle inequality) Now suppose we apply the approximation algorithm A to the traveling-salesman problem (G', c) • Because A is guaranteed to return a tour of cost no more than ρ times the cost of an optimal tour, if G contains a hamiltonian cycle, then A must return it. • If G has no hamiltonian cycle, then A returns a tour of cost more than ρ|V|. Therefore, we can use A to solve the hamiltonian-cycle problem in polynomial time.