Explaining and proving Christofides algorithm
The explanation covers all key steps: computing MST, identifying odd-degree vertices, finding minimum perfect matching on them, forming Eulerian multigraph, extracting Eulerian tour, and shortcutting to TSP tour. It carefully proves MST cost ≤ OPT and the critical matching cost ≤ OPT/2 via constructing an even cycle on odd vertices from the optimal tour and decomposing it into two perfect matchings, ensuring the 3/2 approximation ratio.
A very clean way of thinking about Christofides' algorithm is to separate the two ingredients that make the travelling–salesman problem hard:
- You need to find some connected subgraph on all (n) vertices; and
- In the end you need all degrees to be even so that you can traverse it as a single closed tour.
If you ignore the second requirement you are just looking for a minimum spanning tree, and if you ignore the first requirement you are just looking for a minimum‑weight even‑degree multiset of edges, i.e. a minimum perfect matching. Christofides' idea is to satisfy the connectivity requirement as cheaply as possible and then “repair the parity” as cheaply as possible.
Here is the algorithm on a complete graph (K_n) with non–negative edge–weights (d(u,v)) that satisfy the triangle inequality (d(u,w)\leq d(u,v)+d(v,w)):
- Compute a minimum spanning tree (T) of the metric. This can be done in (O(n^2)) time by Prim's or Kruskal's algorithm. Let (O\subseteq V) be the set of vertices of odd degree in (T). By the handshaking lemma (|O|) is even.
- Compute a minimum–weight perfect matching (M) on the vertex set (O) with respect to the given distances. Because the graph is complete and (|O|) is even, such a matching exists.
- Form the multigraph (G=T\cup M), i.e. take all the edges of (T) and add the matching edges (M). In (G) every vertex has even degree: those that were even in (T) are untouched, and those that were odd in (T) get their parity flipped by the one incident matching edge. Thus (G) is connected and Eulerian.
- Find an Eulerian circuit (W) in (G), which by definition traverses every edge of (G) exactly once and returns to its start. This can be done in linear time.
- Finally, shortcut (W) to obtain a Hamiltonian circuit (C): walk along (W), but whenever you are about to visit a vertex for the second or later time, skip it and go straight to the next unvisited vertex. Because of the triangle inequality, replacing a path (x\to v\to y) by the direct edge (x\to y) cannot increase the total length.
The circuit (C) is a feasible TSP tour. It remains to bound its length.
Let (\mathrm{OPT}) denote the cost of an optimal Hamiltonian tour. Two simple facts give the approximation guarantee:
- Removing any one edge from an optimal tour leaves a spanning tree, so the cost of a minimum spanning tree is at most (\mathrm{OPT}): (w(T)\leq \mathrm{OPT}).
- To bound (w(M)), look at how the optimal tour visits the odd–degree vertices (O). Traversing the optimal tour and “short–cutting” over vertices in (V\setminus O) produces a cycle on the vertex set (O) of total length at most (\mathrm{OPT}), again by the triangle inequality. Any cycle of even length can be decomposed into two edge–disjoint perfect matchings by taking alternate edges. The sum of the weights of these two matchings is the weight of the cycle, so one of them has weight at most half the cycle. Thus there exists a perfect matching on (O) of weight at most (\mathrm{OPT}/2), and the minimum‑weight perfect matching (M) certainly has (w(M)) no larger:
[
w(M)\leq \frac{1}{2},\mathrm{OPT}.
]
In the Eulerian multigraph (G=T\cup M) each edge is used exactly once by (W), so (w(W)=w(T)+w(M)\leq \mathrm{OPT}+\tfrac{1}{2}\mathrm{OPT}=\tfrac{3}{2}\mathrm{OPT}). The shortcutting step cannot increase the length because of the triangle inequality, so
[
w(C)\leq w(W)\leq \tfrac{3}{2},\mathrm{OPT}.
]
This shows that Christofides' algorithm always produces a tour whose cost is at most (3/2) times the optimum on any metric instance.