The Metric TSP Promise
Christofides solves the symmetric metric TSP: the graph is complete, edge costs are nonnegative and symmetric, and every triple obeys the triangle inequality
The output is a Hamiltonian cycle, and its cost is guaranteed to be at most $3/2$ times the optimal tour cost. The promise matters: symmetry supports undirected matching, and the triangle inequality makes shortcutting repeated vertices safe.
Connect cheaply
An MST is a low-cost backbone and a lower bound on the optimal tour.
Repair parity
Match the tree's odd-degree vertices as cheaply as possible.
Shortcut repeats
Turn the Eulerian walk into a tour without increasing its cost.
Intuition: Backbone and Parity Repair
A minimum spanning tree is cheap and reaches every city, but it is not a tour. Doubling every tree edge would make all degrees even and yield the familiar $2$-approximation. Christofides is more selective: only odd-degree vertices prevent an Eulerian circuit, so it pays for the cheapest perfect matching that fixes exactly those parity defects.
Repair Only What Is Broken
The MST is the inexpensive frame. Odd-degree vertices are loose ends. A perfect matching pairs those loose ends with minimum added cost; there is no need to duplicate the entire frame.
Why a Perfect Matching Exists
Every graph has an even number of odd-degree vertices. Because the metric graph is complete, those vertices can always be paired. The matching is general—not bipartite—so Hopcroft–Karp is not the required subroutine.
The Algorithm Pipeline
- Compute a minimum spanning tree $T$.
- Collect the set $O$ of vertices having odd degree in $T$.
- Find a minimum-weight perfect matching $M$ in the complete graph induced by $O$.
- Combine $T$ and $M$ as a multigraph. Parallel copies must remain distinct.
- Find an Eulerian circuit in $T\cup M$.
- Scan the circuit and skip already visited vertices, then return to the start.
Adding $M$ flips the parity of every vertex in $O$. The even-degree tree vertices are untouched, and the odd-degree vertices become even. The combined multigraph stays connected because it still contains the spanning tree, so an Eulerian circuit exists.
A Five-City Metric Trace
Consider a center city $0$ at Manhattan distance $1$ from four surrounding cities; every pair of surrounding cities is distance $2$. This is a genuine metric instance.
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 2 | 2 | 2 |
| 2 | 1 | 2 | 0 | 2 | 2 |
| 3 | 1 | 2 | 2 | 0 | 2 |
| 4 | 1 | 2 | 2 | 2 | 0 |
Why Shortcutting Works
The Eulerian circuit may revisit vertices because it traverses every multigraph edge exactly once. Scan its vertex sequence and keep only each vertex's first appearance. Whenever a repeated block is skipped, replace a path $a\to b\to\cdots\to c$ with the direct edge $a\to c$.
Repeated application of the triangle inequality proves the direct jump cannot cost more. In the example, the Euler segment $2\to0\to3$ costs $1+1=2$, while shortcut $2\to3$ also costs $2$.
Metric Closure
A sparse road graph can first be replaced by all-pairs shortest-path distances. Those distances form a metric closure. A shortcut edge then means “follow its stored shortest path” in the original network, though expanded paths may revisit intermediate road vertices.
The $3/2$ Approximation Proof
Let $OPT$ be the cost of an optimal metric tour.
1. The tree uses at most one $OPT$ budget
Deleting any edge from the optimal tour leaves a spanning tree. Since $T$ is minimum among all spanning trees,
2. Parity repair uses at most half an $OPT$ budget
List the odd-degree vertices $O$ in the order they appear on the optimal tour and shortcut between consecutive members. Triangle inequality gives a cycle on $O$ of cost at most $OPT$. Because $|O|$ is even, alternating edges of that cycle form two perfect matchings. Their total is at most $OPT$, so the cheaper one costs at most $OPT/2$. The algorithm chooses the minimum perfect matching, hence $w(M)\le OPT/2$.
3. Euler and shortcut steps spend no extra budget
The Eulerian circuit uses every edge of $T\cup M$ exactly once, so it costs $w(T)+w(M)$. Shortcutting cannot increase cost. Therefore
Guarantee, Not Prediction
The bound permits a tour up to 50% longer than optimal; it does not predict typical quality. Many instances—including the worked example—produce an optimal tour.
Implementation
The Python tab is a complete educational implementation. To remain dependency-free, it finds the odd-set matching with exponential subset recursion, so the resulting program is appropriate only for small instances. A production polynomial-time implementation must replace that helper with a minimum-weight perfect-matching algorithm such as weighted Blossom. The C++ and Java tabs show the MST/parity scaffold where those production subroutines connect.
Complexity of the Teaching Code
The guarantee requires a minimum-weight perfect matching. The Python example computes it exactly, but exponentially, to stay self-contained. Replacing it with greedy pairing makes the code faster but forfeits the $3/2$ proof.
Complexity
| Stage | Dense metric graph | Key data structure |
|---|---|---|
| minimum spanning tree | $O(n^2)$ with dense Prim | keys and parent array |
| odd-degree scan | $O(n)$ after the tree | degree array |
| minimum perfect matching | $O(n^3)$ with classical weighted matching | general-graph matching |
| Eulerian circuit | $O(n)$ multigraph edges here | edge IDs and adjacency lists |
| shortcut | $O(n)$ walk length here | visited set |
For sparse input networks, first computing a metric closure may itself require all-pairs shortest paths. The relevant total cost then includes both closure construction and Christofides on the resulting complete distance graph.
Where the Guarantee Applies
| Input | Use Christofides directly? | Reason |
|---|---|---|
| symmetric metric matrix | yes | all proof steps apply |
| Euclidean or Manhattan points | yes | their distances are symmetric metrics |
| undirected road graph | after metric closure | shortest-path distances satisfy triangle inequality |
| asymmetric travel costs | no | the matching and shortcut proof is for symmetric TSP |
| arbitrary nonmetric costs | no guarantee | a direct shortcut may cost more than the skipped path |
A tour still comes out if the program is fed a nonmetric matrix, but the $3/2$ statement no longer follows. Approximation guarantees are contracts: every assumption in the theorem is part of the input specification.
Common Pitfalls and a Reliable Checklist
| Pitfall | Consequence | Reliable practice |
|---|---|---|
| greedily pairing odd vertices | matching can exceed the half-$OPT$ budget | compute an exact minimum-weight perfect matching |
| using bipartite matching | the odd set has no natural left/right partition | use a weighted general-graph algorithm |
| deduplicating repeated edges | vertex parity changes and Euler traversal breaks | store a multigraph with unique edge IDs |
| checking only even degrees | a disconnected graph need not have one Euler circuit | retain the connected MST backbone |
| shortcutting without closing | returns a Hamiltonian path | append the starting vertex |
| assuming one deterministic tour | MST, matching, and Euler ties alter output | test validity, cost, and bound—not one sequence |
| rounding coordinates carelessly | may break the metric promise | validate or take a shortest-path metric closure |
Implementation Checklist
Validate symmetry and triangle inequality; preserve parallel edges; confirm the odd set has even size; use exact minimum matching; verify every multiedge is consumed; shortcut repeated vertices once; close the cycle; and compare the result with $1.5$ times an exact optimum on test instances.
Where Christofides Is Useful
Large-Scale Delivery Route Planning
On metric routing instances, Christofides supplies a polynomial-time baseline with a worst-case certificate. In practice it can seed local search such as 2-opt or 3-opt: the guarantee belongs to the initial tour, while improvement steps retain or reduce its cost. Real systems still need constraints such as capacity, time windows, and multiple vehicles modeled separately.
- Guaranteed baseline: compare heuristic or learned tours against a solution with a proven metric bound.
- Local-search initializer: begin from a structured tour, then improve it without losing feasibility.
- Small-instance study: compare Christofides with exact Held–Karp to measure the observed approximation ratio.
- Algorithm composition: study how MST, parity, matching, Euler traversal, and metric shortcutting cooperate in one proof.
Exercises
- Parity: prove that the odd-degree set of every tree has even cardinality.
- Trace: reproduce the five-city pipeline, including vertex degrees before and after matching.
- Euler choices: find a different Eulerian circuit in the same multigraph and shortcut it. Does the tour change?
- Proof: draw an eight-vertex odd-set cycle and split its edges into two perfect matchings.
- Counterexample: construct three nonmetric costs where shortcut $a\to c$ is more expensive than $a\to b\to c$.
- Verification: generate small Euclidean instances, compare the Python tour with exact Held–Karp, and assert the ratio never exceeds $1.5$.
History and Takeaway
Nicos Christofides described the method in a 1976 technical report. Anatoliy Serdyukov discovered the same $3/2$ approach independently and published it in 1978, motivating the name Christofides–Serdyukov algorithm. Decades later, randomized work by Anna Karlin, Nathan Klein, and Shayan Oveis Gharan established a ratio of $3/2-\varepsilon$ for some $\varepsilon>10^{-36}$.
The Mental Model to Keep
Start with the cheapest connected skeleton. Repair only its parity defects, paying at most half an optimal-tour budget. Traverse the resulting even multigraph, then let the triangle inequality erase repeats for free. Each stage has one job, and each inequality in the proof pays for exactly one stage.