This is a great question about the Christofides algorithm for the metric Traveling Salesman Problem (TSP). Let me explain it comprehensively.
Christofides Algorithm for Metric TSP
The Christofides algorithm is a 3/2-approximation algorithm for the metric TSP. Let me go through the key components.
Problem Setup
- We have n cities with distances d(i,j) satisfying the triangle inequality
- We want to find a tour visiting all cities exactly once that minimizes total distance
- TSP is NP-hard, so we seek approximations
Algorithm Steps
Step 1: Compute Minimum Spanning Tree (MST)
- Find an MST of all n vertices using Kruskal's or Prim's algorithm
- Let the cost of MST be C(MST)
Step 2: Find Odd-Degree Vertices
- In the MST, identify all vertices with odd degree
- It's a well-known fact that any graph has an even number of vertices with odd degree (handshaking lemma)
Step 3: Perfect Matching on Odd Vertices
- Find a minimum-weight perfect matching on the set of odd-degree vertices
- This pairs up all odd-degree vertices with minimum total cost
- Let the cost of this matching be C(M)
Step 4: Combine MST and Matching to Form Eulerian Graph
- Take the union of edges from MST and the perfect matching
- This creates a multigraph where every vertex has even degree
- Therefore, an Eulerian circuit exists
Step 5: Find Eulerian Tour
- Find an Eulerian tour in this multigraph using DFS or Hierholzer's algorithm
- This visits every edge exactly once
Step 6: Convert to Hamiltonian Tour (Shortcutting)
-
Traverse the Eulerian tour
-
When we reach a vertex we've already visited, shortcut it (skip to the next unvisited vertex)
-
The triangle inequality ensures shortcuts never increase the total cost
-
This produces a valid Hamiltonian tour
Analysis and 3/2 Approximation Proof
Claim: Christofides algorithm produces a tour of cost at most 3/2 · OPT.
Proof:
Let OPT be the cost of an optimal TSP tour.
-
Lower bound on MST:
The optimal TSP tour is a Hamiltonian cycle. If we remove any edge from OPT, we get a spanning tree.
Therefore: C(MST) ≤ OPT
-
Lower bound on perfect matching:
The odd-degree vertices in the MST form an even-sized set by the handshaking lemma. When we look at these vertices in the order they appear on the optimal TSP tour—call them v₁, v₂, v₃, v₄, ..., v₂ₖ—we can construct a matching by pairing consecutive vertices along the tour. Any perfect matching on these odd vertices costs at most half the TSP tour's cost, since the tour itself provides a way to connect all these vertices, and we're just selecting alternate edges from that path. to the cost of the optimal tour. When we pair the odd vertices according to this perfect matching, the total cost is bounded by OPT. Since the minimum-weight perfect matching is optimal among all possible pairings, we have C(M) ≤ OPT.
The Christofides algorithm then constructs an Eulerian tour on the combined graph MST ∪ M, which costs C(MST) + C(M). Converting this to a Hamiltonian tour through shortcutting preserves the cost bound by the triangle inequality. Therefore, the final tour has cost at most C(MST) + C(M) ≤ OPT + OPT, giving us the 2-approximation guarantee.
Wait, that's not quite right—this should yield a 3/2-approximation, not 2. The issue is that I'm not properly accounting for the lower bound on the matching cost. Let me reconsider the argument.
The crucial insight is that any perfect matching on the odd-degree vertices costs at most OPT. Here's why: in the optimal TSP tour, the odd-degree vertices appear in some sequence. If we pair them consecutively as they appear on the tour—(u₁,u₂), (u₃,u₄), and so on—the matching cost equals the sum of distances between these consecutive pairs along the tour path, which cannot exceed the tour's total cost.
The key observation is that the TSP tour's edges can be decomposed into two perfect matchings on these odd vertices. One of these matchings must have cost at most OPT/2, which gives us the 3/2 bound when combined with the MST cost.
More precisely: if the odd vertices appear in cyclic order u₁, u₂, ..., u₂ₖ along the tour, I can form two different matchings—one pairing consecutive vertices (u₁ with u₂, u₃ with u₄, etc.) and another pairing them the other way around. The sum of these two matchings equals the tour cost, so at least one matching costs at most OPT/2. The argument I was attempting doesn't quite work. Let me reconsider with the proper approach.
The key insight is that for any even-sized subset O of vertices in a complete graph with triangle inequality, a minimum-weight perfect matching on O costs at most OPT. Here's why: take the optimal TSP tour and observe where vertices from O appear along the cycle in order u₁, u₂, ..., u₂ₖ. For any matching edge connecting two vertices in O, the triangle inequality ensures we can't do worse than following the tour's path between them. Since every matching edge can be bounded this way relative to the tour structure, the total matching cost stays within OPT. In the optimal Hamiltonian cycle, the odd-degree vertices appear in some cyclic order. I can decompose this cycle into 2k segments connecting consecutive odd vertices, and the sum of these segment costs equals OPT.
If I pair consecutive odd vertices in this cyclic order—(v₁,v₂), (v₃,v₄), and so on—the total cost of this matching is at most OPT, since each pair is connected by a path within the cycle. Any perfect matching on the odd vertices must have cost at most OPT because the cycle itself provides one valid pairing with that cost. (1), v^(2), ..., v^(2k), v^(1).
The Hamiltonian cycle connects these odd vertices through paths between consecutive pairs. Each path P_i runs from v^(i) to v^(i+1), and together they partition the entire cycle, so their lengths sum to OPT. By the triangle inequality, the direct distance between any two consecutive odd vertices is at most the length of the path connecting them in the cycle. This means the cost of M_{odd}—which pairs odd-indexed vertices—is bounded by half the cycle length, and similarly for M_{even} with even-indexed vertices.
Since the two matchings together cover all edges between consecutive odd vertices and their combined cost cannot exceed OPT, at least one matching must have cost at most OPT/2. The minimum weight perfect matching on the odd vertices will perform no worse than these two natural matchings, giving us the desired approximation bound. The MST cost is at most OPT since any Hamiltonian cycle is a spanning tree with one edge removed.
For the matching, I need to show C(M) ≤ (1/2) · OPT. The key insight is that when we decompose the optimal tour into two matchings on the odd-degree vertices—one covering odd-indexed vertices and one covering even-indexed vertices—their combined cost equals the tour cost. Since at least one of these matchings must be cheaper than their average, we get min(cost(M_odd), cost(M_even)) ≤ (1/2) · OPT.
The minimum weight perfect matching on the odd vertices is guaranteed to be no worse than whichever of these two matchings is cheaper, so C(M) ≤ (1/2) · OPT.
Since the MST costs at most OPT and the matching costs at most (1/2) · OPT, the total before shortcutting is at most (3/2) · OPT. The triangle inequality ensures shortcutting only improves this, giving the (3/2)-approximation. C(MST) ≤ OPT since the MST is a lower bound for any Hamiltonian cycle.
For the matching cost, I need to think about how the odd-degree vertices appear in an optimal tour. When traversing the optimal cycle, these vertices occur in some sequence. If I pair them as consecutive pairs along this tour—u₁ with u₂, u₃ with u₄, and so on—the cost of connecting these pairs is at most half the tour cost, since each edge in the tour is counted at most once across all pairs. This means C(M) ≤ OPT/2.
Combining these bounds: C(Christofides) ≤ C(MST) + C(M) ≤ OPT + OPT/2 = 1.5·OPT. In any optimal Hamiltonian cycle, the odd-degree vertices appear in some order. We can partition the edges between consecutive odd vertices into two matchings: one connecting alternating pairs and another connecting the remaining pairs. Since each edge in the cycle contributes to exactly one matching, and the metric property ensures distances don't exceed path lengths on the cycle, one of these matchings must cost at most half of OPT_HC. The Hamiltonian cycle's edges partition into paths connecting consecutive odd vertices. By the triangle inequality, the direct distance between any two consecutive odd vertices is at most the cost of the path connecting them in the cycle. Since these paths cover the entire cycle, the sum of distances for odd pairs is bounded by OPT_HC, and similarly for even pairs. (path uᵢ ⇝ uᵢ₊₁)
= OPT_HC
So at least one of M_odd or M_even must have cost at most OPT_HC / 2. Since the optimal matching is no worse than either of these, we get C(M) ≤ OPT_HC / 2.
Combining the MST and matching costs: C(Christofides) ≤ OPT_HC + (1/2)OPT_HC = (3/2)OPT_HC.
The crucial observation is that any optimal matching can't exceed the cost of the two matchings we extract from the Hamiltonian cycle.
Christofides Algorithm for Metric TSP
Algorithm Overview
The Christofides algorithm is a polynomial-time 3/2-approximation for TSP on metric graphs (where distances satisfy the triangle inequality).
Algorithm Steps
Input: Complete graph G on n vertices with metric distances
Output: Hamiltonian tour
1. Compute minimum spanning tree (MST)
2. Find all odd-degree vertices in MST → set O
3. Find minimum-weight perfect matching M on vertices in O
4. Combine MST ∪ M to form multigraph G'
(every vertex now has even degree)
5. Find Eulerian tour in G' using DFS
6. Convert to Hamiltonian tour via shortcutting:
- Traverse Eulerian tour
- When revisiting a vertex, skip to next unvisited vertex
- Triangle inequality ensures cost doesn't increase
Key Components Explained
1. MST (Minimum Spanning Tree)
- Find an MST using Kruskal's or Prim's algorithm: O(n² log n)
- Cost: C(MST)
2. Odd-Degree Vertices
- By the Handshaking Lemma, every graph has an even number of odd-degree vertices
- So |O| is even, enabling perfect matching
- These are vertices with degree 1, 3, 5, ... in the MST
3. Perfect Matching
- A perfect matching on O pairs all 2k odd vertices into k edges
- No algorithms for metric matching in polynomial time, but general matching via Edmonds' blossom algorithm: O(n³)
- Cost: C(M)
4. Eulerian Tour
- G' = MST ∪ M is Eulerian (all degrees even)
- Eulerian tour traverses every edge exactly once: O(n)
5. Shortcutting (Converting to Hamiltonian)
- Remove repeated vertices while traversing the Eulerian tour
- By triangle inequality: d(u,w) ≤ d(u,v) + d(v,w)
- Total cost never increases
Approximation Proof: 3/2-Approximation
Theorem: Christofides returns a tour of cost ≤ 3/2 · OPT
Proof:
Lemma 1: MST Lower Bound
C(MST)≤OPT
Proof: An optimal Hamiltonian cycle is a spanning subgraph. Removing any edge from it leaves a spanning tree. Therefore, MST ≤ any spanning tree ≤ OPT. □
Lemma 2: Matching Upper Bound
C(M)≤21⋅OPT
Proof:
In an optimal Hamiltonian cycle, the odd-degree vertices appear in cyclic order: u1,u2,…,u2k.
The cycle decomposes into paths between consecutive odd vertices (possibly through other vertices):
Path1(u1→
These paths are edge-disjoint and partition the Hamiltonian cycle, so:
∑i=12klength(Pathi)=
Now consider two perfect matchings on O:
- Modd: pairs (u1
By the triangle inequality:
d(ui,ui+1)≤length(Path
Therefore:
C(Modd)+C(M
Thus:
min(C(Modd),C(Meven))≤
Since the optimal matching is at least as good as both:
C(M)≤min(C(Modd),C(M □
Final Analysis
The Christofides tour cost is bounded by:
C(Christofides)≤C(MST)+C(M)≤OPT+
Complexity
| Component | Time |
|---|
| MST (Prim) | O(n²) |
| Odd vertices | O(n) |
| Min-weight matching (Blossom) | O(n³) |
| Eulerian tour | O(n) |
| Total | O(n³) |
Tightness
The 3/2 approximation factor is tight—there exist metric instances where Christofides achieves exactly 1.5 times optimal. Better approximations for metric TSP are unknown, making this a classic result in approximation algorithms.