Approximating Metric TSP

A delivery company must route a truck through 500 addresses. It must return to the depot afterward. It must do this while minimizing total distance. This is the Traveling Salesman Problem, and it is NP-hard. No known algorithm finds the optimal tour in polynomial time. None is expected to exist. Yet the truck must leave the depot every morning. Waiting for an exact algorithm that may never come is not an option. So the practical question becomes: how close to optimal can we get, provably, and fast? The Metric Traveling Salesman Problem is the special case where distances come from an actual metric. They satisfy the triangle inequality. Road networks, Euclidean coordinates, and network latencies typically satisfy it too. This restriction seems modest. Yet it is exactly what unlocks efficient approximation. Without the triangle inequality, TSP cannot be approximated within any constant factor in polynomial time, unless P = NP. With it, we can guarantee tours within a small constant multiple of optimal. This holds provably, on every input. This article develops two classical approximation algorithms for Metric TSP. The first, MST-doubling, is a beautifully simple 2-approximation. It is built directly from a minimum spanning tree. The second, Christofides' algorithm, sharpens this to a 3/2-approximation. It does so by patching the spanning tree more cleverly using a matching. Both algorithms exemplify the central theme of approximation algorithm design. Find a computable lower bound on the optimum. Then build a feasible solution. It should cost only a bounded factor more than that bound. By the end, you will understand not just what these algorithms output. You will understand why. You will see why the triangle inequality is the load-bearing assumption. It makes the whole enterprise possible. You will see how a spanning tree functions as a cost certificate. And you will see why matching parity-odd vertices buys the extra half in Christofides' ratio. This works better than doubling every edge.

Key takeaways
  • Metric TSP requires the triangle inequality; the general (non-metric) TSP has no polynomial-time constant-factor approximation unless P = NP.
  • MST-doubling builds a multigraph by duplicating every MST edge, finds an Eulerian tour, then shortcuts repeated vertices to get a Hamiltonian cycle costing at most 2·OPT.
  • The MST is a valid lower bound on OPT because removing any edge from an optimal tour yields a spanning tree.
  • Christofides' algorithm replaces "double every edge" with "add a minimum-weight perfect matching on odd-degree vertices," achieving a 3/2·OPT guarantee.
  • Both algorithms run in polynomial time (dominated by MST or matching computation), unlike exact TSP solvers which are exponential in the worst case.
  • Christofides remained the best known approximation ratio for decades; only recently has a (very small) improvement below 3/2 been proven, though 3/2 remains the standard teaching benchmark.
The core insight

Under the triangle inequality, a minimum spanning tree is a cheap lower bound on the optimal tour, and repairing it into a tour — by doubling edges or by adding a minimum matching on odd-degree vertices — costs at most a small constant factor more.

The idea

The Traveling Salesman Problem asks for a Hamiltonian cycle of minimum total weight in a complete edge-weighted graph. Metric TSP is the restriction where edge weights ww satisfy the triangle inequality:

w(u,v)≤w(u,x)+w(x,v)for all vertices u,x,v.w(u, v) \le w(u, x) + w(x, v) \quad \text{for all vertices } u, x, v.

Equivalently, going directly from uu to vv is never more expensive than any detour through a third vertex. This holds automatically when weights are shortest-path distances in an underlying graph, or Euclidean/Manhattan distances in the plane, which makes the metric case enormously important in practice: routing, circuit board drilling, and clustering all inherit this structure. The key algorithmic move in both algorithms below is to relax the Hamiltonian-cycle requirement to a weaker structure that is easy to compute optimally, then repair it back into a valid tour. A spanning tree connects all vertices with n−1n-1 edges and no cycles; an Eulerian circuit traverses every edge of a graph exactly once and exists if and only if every vertex has even degree (and the graph is connected). Neither object is itself a Hamiltonian cycle, but each can be massaged into one using the triangle inequality to justify "shortcutting" — skipping over already-visited vertices without increasing the total cost. The central inequality used repeatedly is w(MST)≤OPTw(\text{MST}) \le \text{OPT}: deleting any single edge from an optimal tour produces a spanning tree, so no spanning tree — in particular the minimum one — can cost more than the tour. This turns the minimum spanning tree into a computable, polynomial-time lower bound certificate against which we measure our constructed tour, exactly the strategy used in the Vertex Cover 2-Approximation, where a matching serves as the analogous lower bound.

How it works

MST-doubling algorithm

Step 1 — Build a minimum spanning tree TT of the complete weighted graph GG.

Step 2 — Double every edge of TT, producing a multigraph HH in which every vertex has even degree (each vertex's tree-degree is doubled, and even numbers stay even).

Step 3 — Find an Eulerian circuit in HH. This exists because HH is connected (it contains TT) and every vertex has even degree.

Step 4 — Shortcut the Eulerian circuit: walk it in order, and whenever it revisits a vertex already output, skip directly to the next new vertex, using the triangle inequality to justify that this skip does not increase total cost. The result is a Hamiltonian cycle. ``` MST-DOUBLE-TSP(G, w): // G: complete graph on vertex set V, w: edge weights satisfying triangle inequality T ← MST(G, w) // e.g., Prim's or Kruskal's algorithm H ← multigraph formed by duplicating every edge of T C ← EULERIAN-CIRCUIT(H) // exists: H connected, all degrees even tour ← [] visited ← empty set for v in C: if v not in visited: append v to tour add v to visited append tour[0] to tour // close the cycle return tour ```

Christofides' algorithm

The doubling step above is wasteful: it forces every edge to be traversed twice, even vertices that already had even degree. Christofides' refinement fixes only what is broken.

Step 1 — Build a minimum spanning tree TT of GG.

Step 2 — Identify odd-degree vertices. Let OO be the set of vertices with odd degree in TT. A handshake-lemma argument guarantees ∣O∣|O| is even.

Step 3 — Compute a minimum-weight perfect matching MM on the vertices in OO, using only edges of GG (the complete metric graph restricted to OO).

Step 4 — Union TT and MM. Every vertex in OO gains exactly one more incident edge from MM, flipping its degree to even; vertices not in OO are untouched. The multigraph T∪MT \cup M is connected and every vertex has even degree.

Step 5 — Find an Eulerian circuit in T∪MT \cup M, then shortcut exactly as before to obtain a Hamiltonian cycle. ``` CHRISTOFIDES-TSP(G, w): T ← MST(G, w) O ← { v ∈ V(T) : degree_T(v) is odd } M ← MIN-WEIGHT-PERFECT-MATCHING(G[O], w) // O(|O|^3) via Edmonds' blossom algorithm H ← multigraph union of T and M // all degrees now even C ← EULERIAN-CIRCUIT(H) tour ← [] visited ← empty set for v in C: if v not in visited: append v to tour add v to visited append tour[0] to tour return tour ``` The diagram below traces both repair strategies from the same spanning tree.

Figure
From MST to tour: doubling vs. matching odd-degree vertices
Minimum Spanning Tree a b c d e f yellow = odd degree (a,b,e,f) blue = even degree (c: deg 3? see note) MST-Doubling a b c d e f every edge duplicated cost = 2 · w(MST) Christofides Matching a b c d e f only odd vertices matched (green) cost = w(MST) + w(matching)

Both repaired multigraphs are Eulerian; the shortcutting step then converts the Eulerian circuit into a Hamiltonian cycle in O(n)O(n) additional time. The difference between the two algorithms lies entirely in how much extra weight is added to make degrees even — doubling adds a full copy of TT, while matching adds only enough edges to fix the (typically much smaller) set of odd-degree vertices.

Complexity & correctness

Running time. Computing an MST takes O(Elog⁡V)O(E \log V) with Prim's or Kruskal's algorithm, or O(n2)O(n^2) directly on a complete graph using a simple array-based Prim's implementation. Finding an Eulerian circuit takes O(E)O(E) using Hierholzer's algorithm. Shortcutting is a single O(n)O(n) pass. For MST-doubling, total time is dominated by the MST step: O(n2)O(n^2) on a dense metric instance. For Christofides, the additional cost is the minimum-weight perfect matching on the (at most nn) odd-degree vertices, computable in O(n3)O(n^3) via Edmonds' blossom algorithm; this term dominates, giving overall O(n3)O(n^3).

Space is O(n2)O(n^2) to store the complete distance matrix, or O(E)O(E) for the graph if sparse, plus O(n)O(n) for the tree, tour, and auxiliary structures.

Correctness of the lower bound. Let OPT denote the weight of an optimal tour C∗C^*. Removing any single edge from C∗C^* leaves a Hamiltonian path, which is in particular a spanning tree. Since the MST has minimum weight among all spanning trees,

w(MST)≤w(C∗∖{e})≤w(C∗)=OPT.w(\text{MST}) \le w(C^* \setminus \{e\}) \le w(C^*) = \text{OPT}.

This inequality is exact and requires no assumption about the metric — it is purely combinatorial.

Correctness of the shortcutting step. This is where the triangle inequality is essential. An Eulerian circuit visits every edge of HH exactly once, possibly revisiting vertices multiple times. When we skip from the last new vertex uu directly to the next new vertex vv, bypassing already-visited vertices in between, the triangle inequality guarantees

w(u,v)≤∑(weights of the skipped sub-path from u to v in the circuit),w(u, v) \le \sum (\text{weights of the skipped sub-path from } u \text{ to } v \text{ in the circuit}),

by repeated application of w(x,z)≤w(x,y)+w(y,z)w(x,z) \le w(x,y) + w(y,z) along the path. Hence shortcutting never increases total cost: the final Hamiltonian cycle costs at most w(H)w(H), the weight of the Eulerian multigraph.

MST-doubling ratio. The multigraph HH has weight w(H)=2⋅w(MST)w(H) = 2 \cdot w(\text{MST}). Combining the two facts above:

w(tour)≤w(H)=2⋅w(MST)≤2⋅OPT.w(\text{tour}) \le w(H) = 2 \cdot w(\text{MST}) \le 2 \cdot \text{OPT}.

This proves the algorithm is a 2-approximation: it always outputs a tour of weight at most twice optimal, and this can be verified in polynomial time on any instance.

Christofides ratio — the extra argument. Let OO be the odd-degree vertices of the MST, and let MM be the minimum-weight perfect matching on OO found by the algorithm. We need w(M)≤12OPTw(M) \le \tfrac{1}{2}\text{OPT}. Consider the optimal tour C∗C^* restricted to the vertices of OO in the cyclic order they appear along C∗C^*. Because ∣O∣|O| is even, this cyclic sequence splits into two perfect matchings on OO by taking alternating edges (every other edge of the induced cycle). Concretely, if the vertices of OO appear along C∗C^* in order v1,v2,…,v2kv_1, v_2, \ldots, v_{2k} (with shortcut edges connecting them directly, again licensed by the triangle inequality), then {v1v2,v3v4,…}\{v_1v_2, v_3v_4, \ldots\} and {v2v3,v4v5,…,v2kv1}\{v_2v_3, v_4v_5, \ldots, v_{2k}v_1\} are two perfect matchings on OO whose combined weight is at most w(C∗)=OPTw(C^*) = \text{OPT} (using the triangle inequality once more to bound the shortcut edges by the original tour segments they replace). Since these two matchings partition a cost of at most OPT, the cheaper one costs at most 12OPT\tfrac{1}{2}\text{OPT}. As MM is the minimum-weight perfect matching on OO, it costs no more than this cheaper one:

w(M)≤12 OPT.w(M) \le \tfrac{1}{2}\,\text{OPT}.

Now the Eulerian multigraph is H=T∪MH = T \cup M, with

w(H)=w(T)+w(M)≤OPT+12 OPT=32 OPT.w(H) = w(T) + w(M) \le \text{OPT} + \tfrac{1}{2}\,\text{OPT} = \tfrac{3}{2}\,\text{OPT}.

Shortcutting again only decreases cost, so

w(tour)≤w(H)≤32 OPT.w(\text{tour}) \le w(H) \le \tfrac{3}{2}\,\text{OPT}.

This proves Christofides is a 3/2-approximation under the metric assumption.

Honesty about tradeoffs. The 3/2 bound is a worst-case guarantee, not a typical-case one; on many real instances both algorithms land within a few percent of optimal, and Christofides typically outperforms doubling in practice, not just in the worst-case bound. The price of the better ratio is a more expensive subroutine: blossom-algorithm matching is asymptotically and practically slower than an MST computation, and harder to implement correctly. Neither algorithm generalizes to non-metric TSP: without the triangle inequality, the shortcutting argument breaks entirely, since skipping a vertex could cost arbitrarily more than visiting it. Indeed, non-metric TSP has no polynomial-time constant-factor approximation unless P = NP, which is provable by a reduction from the Hamiltonian cycle problem that assigns weight 1 to real edges and an astronomically large weight to non-edges — any good approximation would have to distinguish Hamiltonian from non-Hamiltonian graphs.

Worked example

Consider five points with Euclidean-style distances (satisfying the triangle inequality) laid out roughly as a pentagon with one interior point:

ABCDE
A–29107
B2–689
C96–38
D1083–4
E7984–

Step 1 — MST. Sorting edges: AB(2), CD(3), DE(4), BC(6), AE(7), BD(8), CE(8), AC(9), BE(9), AD(10). Running Kruskal's algorithm: add AB(2), add CD(3), add DE(4) [connects {C,D} with {D,E}, fine], next BC(6) connects {A,B} with {C,D,E} — add it. That is 4 edges for 5 vertices: MST = {AB, CD, DE, BC}, weight = 2+3+4+6 = 15. Degrees in the MST: A has degree 1 (to B), B has degree 2 (to A, C), C has degree 2 (to B, D), D has degree 2 (to C, E), E has degree 1 (to D). Odd-degree vertices: O = {A, E}.

Step 2a — MST-doubling. Double every MST edge: multigraph has AB, AB, BC, BC, CD, CD, DE, DE, total weight 2×15=302 \times 15 = 30. An Eulerian circuit, e.g., A–B–C–D–E–D–C–B–A. Shortcutting (skip repeats): A, B, C, D, E, back to A. Tour cost: w(AB)+w(BC)+w(CD)+w(DE)+w(EA)=2+6+3+4+7=22w(AB)+w(BC)+w(CD)+w(DE)+w(EA) = 2+6+3+4+7 = \mathbf{22}. Check against the bound: 2×MST=30≥222 \times \text{MST} = 30 \ge 22, and since MST≤OPT\text{MST} \le \text{OPT}, we know OPT≥15\text{OPT} \ge 15, so the guarantee 22≤2×OPT22 \le 2 \times \text{OPT} holds regardless of OPT's exact value.

Step 2b — Christofides. O={A,E}O = \{A, E\}, and since ∣O∣=2|O|=2 there is only one possible perfect matching: the single edge AEAE, weight 7. This is trivially the minimum-weight perfect matching on OO. Union T∪MT \cup M = {AB, BC, CD, DE, AE}, weight 15+7=2215 + 7 = 22. Every vertex now has even degree (A: 2, B: 2, C: 2, D: 2, E: 2) — in fact this multigraph is already a single cycle: A–B–C–D–E–A. The Eulerian circuit is the Hamiltonian cycle already, no shortcutting needed. Tour cost: 2+6+3+4+7=222+6+3+4+7 = \mathbf{22}. In this small instance both algorithms happen to produce the identical tour of cost 22 (the MST plus one connecting edge was already Hamiltonian), and in fact the brute-force optimum here is also 22 — verified by checking all 4!/2=124!/2 = 12 distinct tours through the 5 points, none of which beats 22. This coincidence is typical of tiny instances; on larger graphs Christofides' extra matching step routinely produces a strictly cheaper repair than blind doubling, since w(M)≤12w(T)w(M) \le \tfrac12 w(T) is common while doubling always pays the full w(T)w(T) again.

Common pitfalls & traps

PitfallWhy it's wrong
Applying MST-doubling or Christofides to a non-metric instanceThe shortcutting step can increase cost arbitrarily if the triangle inequality fails; the 2- or 3/2-approximation guarantee simply does not hold
Matching on all vertices instead of only odd-degree onesWastes cost and can even make previously-even vertices odd again; Christofides' 1/2-OPT bound relies specifically on matching only the odd set, whose size is bounded by a clean cycle-splitting argument
Forgetting that ∣O∣|O| must be even before matchingIf implemented incorrectly (e.g., miscounting tree degree), an odd ∣O∣|O| makes a perfect matching impossible; the handshake lemma guarantees evenness only if degrees were computed correctly from the same tree
Confusing "duplicate the MST" with "duplicate the tour"Doubling operates on the spanning tree, not on any tour; conflating them produces a different (usually worse and unbounded) construction
Believing 3/2 is tight for every instance3/2 is a worst-case upper bound; real-world instances usually score far better, and treating the bound as an "expected error" misleads capacity planning
Ignoring matching algorithm cost when choosing Christofides for very large nnO(n3)O(n^3) blossom-algorithm matching can dominate runtime badly at scale; MST-doubling's O(n2)O(n^2) may be preferable when a slightly worse ratio is an acceptable tradeoff

Pioneers & history

The Traveling Salesman Problem's approximability was shaped by the broader development of NP-completeness theory and combinatorial optimization in the 1970s. Nicos Christofides introduced the matching-based repair in 1976 as a technical report, and it stood for decades as the best known approximation ratio for metric TSP — a striking testament to how a conceptually simple idea (patch only what's broken) can resist improvement for so long. The MST-doubling idea, while simpler, reflects the same era's realization that spanning trees give clean, computable lower bounds for tour problems.

Origins · 1 minNicos Christofides and how this was discovered
NC
Nicos Christofides
1942–2019 · Operations research, combinatorial optimization

Christofides worked on heuristic and approximation methods for vehicle routing and scheduling problems throughout his career at Imperial College London. His 1976 technical report describing the matching-augmented spanning-tree algorithm became one of the most cited results in approximation algorithms, remaining the standard teaching example — and, until a 2020s refinement, the best known worst-case guarantee — for metric TSP for over forty years.

History
1956
— Prim and (independently, earlier) Jarník formalize efficient minimum spanning tree algorithms, later reused as TSP lower bounds.
1962
— Edmonds develops polynomial-time matching algorithms (the blossom algorithm), the key subroutine Christofides' method depends on.
1972
— Karp's NP-completeness results place TSP among the foundational intractable combinatorial problems.
1976
— Christofides publishes the matching-augmented MST algorithm, establishing the 3/2-approximation for metric TSP.
2020
s — Karlin, Klein, and Gharan announce a proof of a (very small, non-constant-fraction) improvement over 3/2 for metric TSP, the first such advance in nearly fifty years.

Where this matters

Metric TSP approximations underpin vehicle routing software used by logistics companies to plan delivery sequences, since real road-network distances (or their shortest-path approximations) satisfy the triangle inequality. Circuit board manufacturing uses TSP approximations to sequence drill-head movements across thousands of holes, where Euclidean travel time is the metric. Genome sequencing pipelines have historically used TSP-style tours to order DNA fragments by similarity. Christofides-style repair is also a template beyond TSP itself: the general pattern — cheap lower-bound structure, augment to satisfy a parity or connectivity constraint, exploit a metric or submodular property to bound the augmentation cost — recurs in network design approximations and facility location. These same algorithms serve as the natural baseline against which more elaborate Heuristics and Local Search methods, such as 2-opt, Lin-Kernighan, and simulated annealing, are measured, since a local-search heuristic with no guarantee is only convincing once compared against a provable worst-case bound like Christofides'.

Ask the tutor: How does the proof that w(M)≤12OPTw(M) \le \tfrac12 \text{OPT} change if the odd-degree vertex set OO is very large relative to nn?

Why does the triangle inequality matter so much for these algorithms?

The triangle inequality is what justifies "shortcutting" — skipping over an already-visited vertex in an Eulerian circuit to go directly to the next new one. Without it, a direct edge between two vertices could cost far more than the path through intermediate vertices, so skipping could make the tour arbitrarily expensive rather than cheaper. With the triangle inequality, w(u,v)≤w(u,x)+w(x,v)w(u,v) \le w(u,x) + w(x,v) guarantees that cutting out xx never increases cost. This single property is the load-bearing assumption behind both the 2-approximation and the 3/2-approximation; it is why the algorithms are described specifically as solving Metric TSP rather than TSP in general.

Is Christofides' algorithm always better than MST-doubling in practice?

In the worst-case guarantee, yes — 3/2·OPT is strictly better than 2·OPT. In practice, Christofides also tends to produce shorter tours on typical instances, because the matching step often adds much less weight than a full doubling would (w(M)w(M) is frequently well below 12w(T)\tfrac12 w(T)). The tradeoff is computational cost: minimum-weight perfect matching via the blossom algorithm runs in roughly O(n3)O(n^3) time, versus O(n2)O(n^2) for the MST step alone, so on very large instances MST-doubling's speed can be the deciding factor if a slightly worse ratio is acceptable.

Does a 3/2-approximation mean every tour Christofides produces is at least 2/3 as good as optimal?

Yes, that is exactly what the bound implies: if the algorithm's tour costs at most 32⋅OPT\tfrac32 \cdot \text{OPT}, then OPT≥23⋅(algorithm’s tour cost)\text{OPT} \ge \tfrac23 \cdot (\text{algorithm's tour cost}), so the algorithm's tour is never more than 50% worse than optimal. This is a worst-case bound holding for every valid metric instance, not an average-case or typical-case statement. Many real instances see far smaller gaps, often just a few percent, but the proof guarantees the 50% ceiling regardless of input, which is what makes it a genuine approximation algorithm rather than a heuristic with no guarantee.

Can these algorithms be extended to the asymmetric TSP, where w(u,v) ≠ w(v,u)?

Not directly. Both the MST-doubling and Christofides constructions rely on undirected structures — spanning trees and Eulerian circuits in undirected graphs — and on a symmetric, triangle-inequality-respecting distance function. Asymmetric metric TSP requires different techniques, such as algorithms based on the Held-Karp linear programming relaxation adapted for directed graphs, and historically had weaker approximation guarantees than the symmetric case. Recent theoretical work has improved asymmetric TSP approximation ratios substantially, but those constructions are structurally different from the tree-and-matching approach described here.

Why is minimum-weight perfect matching computable in polynomial time when TSP itself is not?

Perfect matching has extra combinatorial structure that TSP lacks: Jack Edmonds' blossom algorithm exploits alternating-path augmentation and a clever contraction technique for odd cycles ("blossoms") to find a maximum (or minimum-weight) matching in polynomial time, roughly O(n3)O(n^3). TSP, by contrast, requires finding a Hamiltonian cycle, and verifying whether any Hamiltonian cycle exists is itself NP-complete — there is no known efficient combinatorial structure analogous to alternating paths that solves the full cycle problem. This asymmetry is precisely what makes matching a usable, efficient subroutine inside a TSP approximation algorithm.

What role does shortcutting play, and could we skip it by using the Eulerian circuit directly as the answer?

An Eulerian circuit is not a valid TSP tour because it revisits vertices, sometimes many times, while a Hamiltonian cycle must visit each vertex exactly once. Shortcutting is the step that converts one into the other: walk the Eulerian circuit and, whenever a vertex has already been output, jump directly to the next unvisited vertex. This is only cost-safe because of the triangle inequality, which guarantees skipping never increases total weight. Without shortcutting, the algorithm would output a closed walk rather than a genuine tour, and would not solve the TSP as posed.

Has anyone beaten the 3/2 approximation ratio for metric TSP?

For nearly fifty years, 3/2 stood as the best known guarantee for general metric TSP. In the 2020s, a proof by Karlin, Klein, and Oveis Gharan established a bound of 3/2−ε3/2 - \varepsilon for a specific small constant ε\varepsilon, the first asymptotic improvement over Christofides. The improvement is theoretically significant but the constant gain is extremely small and the algorithm is far more intricate, so Christofides' 3/2-approximation remains the standard teaching example and the practical workhorse for understanding metric TSP approximation.

Before this

Where this leads