Christofides algorithm
The Christofides algorithm, also known as the Christofides–Serdyukov algorithm, is a polynomial-time approximation algorithm for the metric traveling salesman problem (TSP), which seeks a minimum-length Hamiltonian cycle in a complete graph where edge weights satisfy the triangle inequality, non-negativity, and symmetry.[1] It achieves a 3/2-approximation ratio, meaning the length of the tour it produces is at most 1.5 times the optimal TSP tour length, and runs in O(n³) time for n vertices.[2]
Developed by Nicos Christofides in a 1976 technical report at Carnegie Mellon University, the algorithm was independently discovered around the same time by Soviet mathematician A. I. Serdyukov, whose work was submitted in January 1976 but published in 1978. Christofides' approach improved upon earlier 2-approximation heuristics, such as twice traversing a minimum spanning tree (MST) and shortcutting repeats, by addressing the parity issue in degrees to better bound the tour cost.[1] The core steps involve: (1) computing an MST T of the graph, whose cost is at most that of the optimal tour OPT; (2) identifying the set O of vertices with odd degree in T (an even number due to graph properties); (3) finding a minimum-weight perfect matching M on the complete graph induced by O, with cost at most half of OPT; (4) forming a multigraph G' by unioning T and M, which has all even degrees and admits an Eulerian tour; and (5) shortcutting the Eulerian tour in G' to yield a valid TSP tour, leveraging the metric property to ensure no length increase.[2]
The approximation guarantee follows from the inequality that the final tour length is at most the cost of T plus M, which is ≤ OPT + (1/2)OPT = (3/2)OPT, with shortcutting preserving or reducing length under the triangle inequality.[1] For nearly five decades, this 3/2 factor represented the best known polynomial-time approximation ratio for metric TSP, underscoring its foundational role in combinatorial optimization. Although recent advances, such as a 2020 result improving the ratio to slightly below 3/2 for general metric instances, have refined the landscape, the Christofides algorithm remains a benchmark for its simplicity, provable performance, and influence on subsequent TSP heuristics.[3]
Background
Traveling Salesman Problem
The traveling salesman problem (TSP) is a fundamental combinatorial optimization problem in computer science and operations research. Given a set of cities and the distances between each pair, the goal is to determine the shortest possible route that starts and ends at the same city while visiting each city exactly once.[4]
The TSP is NP-hard, implying that no polynomial-time algorithm exists to solve it exactly for general instances unless P = NP, and its decision version—asking whether a tour of total distance at most a given threshold exists—is NP-complete.[5] Exact solutions are possible through methods like dynamic programming, exemplified by the Held-Karp algorithm, which achieves optimality in O(2^n n^2) time complexity but becomes computationally infeasible for instances with more than about 20-30 cities due to exponential growth.[6]
The problem is classified as symmetric if the distance between any two cities is the same in both directions (i.e., undirected graph), or asymmetric otherwise, where directional differences apply (i.e., directed graph).[7] A notable variant is the metric TSP, which assumes distances obey the triangle inequality and is addressed in subsequent sections.
Metric TSP Variant
The metric traveling salesman problem (TSP) is a restricted version of the TSP where the input is a complete undirected graph with edge weights representing distances that form a metric. These distances are non-negative, symmetric (i.e., the distance from city u to v equals that from v to u), zero along self-loops, and satisfy the triangle inequality: for any cities u, v, and w, d(u,v) \leq d(u,w) + d(w,v).[8] This condition ensures that the shortest path between two points is direct or no longer than any detour via a third point, preventing artificial shortcuts that could trivialize the problem.[9]
The metric TSP is particularly relevant for modeling practical routing applications, such as delivery logistics or circuit board design, where distances approximate Euclidean geometries or actual road networks that inherently obey the triangle inequality.[10] In these scenarios, the metric assumption aligns with physical constraints, allowing algorithms to leverage geometric properties for feasible solutions without violating real-world travel dynamics.[11]
Unlike the general TSP, which lacks these distance constraints and cannot admit a polynomial-time approximation scheme (PTAS) unless P = NP due to its extreme inapproximability (e.g., no approximation within n^{1-\epsilon} for any \epsilon > 0), the metric variant enables constant-factor approximations by exploiting the triangle inequality to bound tour lengths effectively. This distinction arises because the metric structure permits constructive techniques like shortcutting, which are infeasible in arbitrary graphs.[12]
Metric TSP instances are formulated on complete graphs, ensuring every pair of cities is connected by an edge weighted by the metric distance, which facilitates the assumption of direct accessibility while maintaining the problem's combinatorial challenge.[13]
Algorithm Description
High-Level Overview
The Christofides algorithm is a polynomial-time approximation algorithm for the metric traveling salesman problem (TSP), in which the goal is to find a minimum-length Hamiltonian cycle in a complete graph where edge weights satisfy the triangle inequality. It was developed by Nicos Christofides in 1976 and independently discovered by Anatoliy Serdyukov in 1976 (submitted January 1976), who published the result in 1978.[14]
The core idea combines a minimum spanning tree (MST) of the graph with a minimum-weight perfect matching on the vertices of odd degree in the MST. This union forms an Eulerian multigraph, from which an Eulerian tour is extracted and then shortcut—by removing repeated vertices while preserving the order—to yield a Hamiltonian cycle that serves as an approximate TSP tour.[1] The approach leverages the properties of MSTs and matchings to ensure the tour remains efficient under the metric assumption.[1]
The algorithm guarantees a tour whose total length is at most 1.5 times that of the optimal metric TSP tour.[1]
A high-level outline of the algorithm is as follows:
Algorithm Christofides(G) // G is a complete undirected [graph](/page/Graph) with [metric](/page/Metric) edge weights
1. Compute a [minimum spanning tree](/page/Minimum_spanning_tree) T of G.
2. Identify the set O of vertices with odd degree in T.
3. Compute a minimum-weight [perfect matching](/page/Perfect_matching) M on the complete subgraph induced by O (using weights from G).
4. Form the [multigraph](/page/Multigraph) H = (V(G), E(T) ∪ E(M)).
5. Compute an Eulerian [tour](/page/Tour) C in the connected Eulerian [multigraph](/page/Multigraph) H.
6. Shortcut C to a Hamiltonian cycle by skipping any repeated vertices encountered in the tour order.
Return the Hamiltonian cycle as the approximate TSP tour.
Algorithm Christofides(G) // G is a complete undirected [graph](/page/Graph) with [metric](/page/Metric) edge weights
1. Compute a [minimum spanning tree](/page/Minimum_spanning_tree) T of G.
2. Identify the set O of vertices with odd degree in T.
3. Compute a minimum-weight [perfect matching](/page/Perfect_matching) M on the complete subgraph induced by O (using weights from G).
4. Form the [multigraph](/page/Multigraph) H = (V(G), E(T) ∪ E(M)).
5. Compute an Eulerian [tour](/page/Tour) C in the connected Eulerian [multigraph](/page/Multigraph) H.
6. Shortcut C to a Hamiltonian cycle by skipping any repeated vertices encountered in the tour order.
Return the Hamiltonian cycle as the approximate TSP tour.
This pseudocode captures the essential steps without implementation specifics.[1]
Step-by-Step Construction
The Christofides algorithm constructs an approximate solution to the metric traveling salesman problem (TSP) through a sequence of graph-theoretic operations that build upon a minimum spanning tree (MST). The process begins by computing an MST of the complete undirected graph G = (V, E) with metric edge weights, which can be done efficiently using standard algorithms such as Kruskal's algorithm or Prim's algorithm.[1]
Next, the algorithm identifies the set of vertices in the MST that have odd degree; since the number of such vertices is always even in any graph, this set induces a complete subgraph on which a minimum-weight perfect matching can be computed. This matching is found by solving the assignment problem on the subgraph restricted to these odd-degree vertices, ensuring that each is paired exactly once with minimum total edge weight.[1]
The edges of this minimum-weight perfect matching are then added to the MST, resulting in a multigraph where all vertices now have even degree, thereby making the multigraph Eulerian. An Eulerian tour of this multigraph, which traverses each edge exactly once and returns to the starting vertex, is subsequently computed using Hierholzer's algorithm, a standard method for finding Eulerian circuits in even-degree graphs.[1]
Finally, the Eulerian tour is transformed into a Hamiltonian cycle—a TSP tour that visits each vertex exactly once—by shortcutting: whenever the tour revisits a previously visited vertex, the path between repeats is replaced by a direct edge to the next unvisited vertex. Under the triangle inequality satisfied by the metric edge weights, this shortcutting does not increase the total tour cost, as the direct edge weight is at most the sum of the weights along the skipped path.[1]
Theoretical Guarantees
Approximation Ratio Derivation
The approximation ratio of the Christofides algorithm is derived by establishing upper bounds on the costs of its constructed components relative to the optimal tour cost, denoted as \OPT, which is the length of the shortest Hamiltonian cycle in the metric graph.[15]
The minimum spanning tree T satisfies c(T) \leq \OPT, since deleting any single edge from the optimal tour yields a spanning tree whose total edge cost is at most \OPT.[15]
Let O be the set of vertices with odd degree in T; by the handshaking lemma, |O| is even. The minimum-weight perfect matching M in the complete subgraph induced by O (with edge weights from the original metric) satisfies c(M) \leq \frac{1}{2} \OPT. To see this, shortcut the optimal tour by bypassing vertices not in O to obtain a tour H' on O with c(H') \leq \OPT by the triangle inequality. Since |O| is even, H' can be partitioned into two perfect matchings whose costs sum to c(H'), so at least one has cost at most \frac{1}{2} c(H') \leq \frac{1}{2} \OPT. Thus, the minimum matching M has cost at most this value.[15]
The multigraph G' = (V, E(T) \cup E(M)) thus has total edge cost c(G') = c(T) + c(M) \leq \OPT + \frac{1}{2} \OPT = \frac{3}{2} \OPT. Since G' is Eulerian (all degrees even), it admits an Eulerian tour \tau of length exactly c(\tau) = c(G') \leq \frac{3}{2} \OPT.[15]
Finally, shortcutting \tau to eliminate repeated vertices produces a Hamiltonian cycle (tour) whose cost satisfies c(\tour) \leq c(\tau), because the triangle inequality ensures that replacing any subpath visiting intermediate vertices with a direct edge does not increase the total length. Therefore, c(\tour) \leq \frac{3}{2} \OPT.[15]
This \frac{3}{2}-approximation bound is tight, as there exist metric TSP instances where the algorithm's output achieves a ratio arbitrarily close to \frac{3}{2}.[15]
Computational Complexity
The Christofides algorithm operates in polynomial time, achieving an overall time complexity of O(n^3) for a complete graph with n vertices, where the dominant step is the computation of the minimum-weight perfect matching.[16]
This complexity arises from the breakdown of its core components. The minimum spanning tree (MST) is constructed using Prim's algorithm implemented with Fibonacci heaps, which runs in O(E + V \log V) time; for a dense complete graph where E = \Theta(n^2), this simplifies to O(n^2).[17] The minimum-weight perfect matching on the subgraph induced by the odd-degree vertices in the MST (at most n/2 vertices) employs an efficient implementation of Edmonds' blossom algorithm, achieving O(n^3) time for dense graphs.[18] Constructing the Eulerian tour in the augmented multigraph (with O(n) edges) via Hierholzer's algorithm takes O(n) time, as it traverses each edge a constant number of times.[19] Finally, shortcutting the Eulerian tour to eliminate duplicate vertices and form a valid TSP tour requires O(n^2) time in a naive implementation, due to pairwise distance lookups in the adjacency matrix to skip repeats while preserving the metric order.[20]
The space complexity is O(n^2), primarily to store the adjacency matrix of distances for the complete metric graph, with additional O(n) space for the MST, matching, and tour structures.[20]
In practical implementations, the O(n^3) barrier of exact matching is often mitigated by heuristic approximations, such as greedy matching or randomized variants, reducing runtime to O(n^2 \log n) or better while retaining near-optimal approximation guarantees for large-scale applications like vehicle routing.[21]
Illustrative Example
To illustrate the Christofides algorithm, consider a simple complete metric graph with 5 vertices labeled 0, 1, 2, 3, 4, where edge weights satisfy the triangle inequality (e.g., based on Euclidean distances with 0 at the center and others positioned such that MST edges are 1 unit). Assume the minimum spanning tree (MST) T consists of edges 0–1, 0–2, 0–3, 0–4, each of weight 1, for a total cost of 4. Vertex 0 has degree 4 (even), while vertices 1, 2, 3, 4 have degree 1 (odd), so the set O = {1, 2, 3, 4}.
The minimum-weight perfect matching M on the subgraph induced by O pairs 1–2 and 3–4, each of weight 1 (assuming these are the shortest edges among pairs in O), for a total cost of 2.
The multigraph G' = T ∪ M has edges 0–1, 0–2, 0–3, 0–4, 1–2, 3–4, with all degrees even. An Eulerian tour in G' is 0–1–2–0–3–4–0, of length 6 (traversing each edge exactly once).
Shortcutting the Eulerian tour to obtain a Hamiltonian cycle skips repeated visits to 0: from 2, instead of returning to 0 and then to 3, connect directly to 3 (using the metric property, where the distance 2–3 ≤ distance(2–0) + distance(0–3) = 2). The resulting TSP tour is 0–1–2–3–4–0. Assuming distance(2–3) = 1.5 for concreteness, the tour length is 1 + 1 + 1.5 + 1 + 1 = 5.5, which is at most 1.5 times the optimal tour length (here, suppose optimal is 4.5, then 5.5 ≤ 1.5 × 4.5 = 6.75).[2]
Extensions and Improvements
Variant Algorithms
One prominent variant of the Christofides algorithm is the Best-of-Many approach, which enhances performance by running the algorithm multiple times on spanning trees derived from the Held-Karp linear programming relaxation and selecting the tour with the lowest cost.[22] This method draws from derandomization techniques introduced by An, Kleinberg, and Shmoys in 2012 for the s-t path TSP variant and extends the randomization from Oveis Gharan, Saberi, and Singh (2011) to the standard metric TSP.[23] Spanning trees are sampled according to the fractional solution's decomposition into a convex combination of trees, and the process is repeated to yield the best outcome among them. For the standard metric TSP, experimental evaluations show that this variant achieves average approximation ratios significantly better than the original, often below 4% above optimal on TSPLIB instances.[22]
A related adaptation targets the s-t path variant of the TSP, where the goal is to find a minimum-cost Hamiltonian path between specified endpoints s and t rather than a cycle. The Best-of-Many Christofides algorithm for this setting computes a minimum T-join on the odd-degree vertices (excluding s and t) to form an Eulerian path, which is then shortcut to a Hamiltonian path, achieving an approximation ratio of $1 + \sqrt{5}/2 \approx 1.618.[24] This improves upon the 5/3 ratio of the direct path adaptation of the original Christofides algorithm and relies on the same sampling and selection mechanism to derandomize the process.[25]
Tours produced by the Christofides algorithm are frequently post-processed with local search heuristics to refine the solution further. Common methods include 2-opt, which iteratively swaps pairs of edges to eliminate crossings and reduce tour length, or the more advanced Lin-Kernighan heuristic, which generalizes 2-opt by allowing variable-depth exchanges. In implementations like the Lin-Kernighan-Helsgaun (LKH) solver, Christofides serves as one of several initial tour constructions, followed by local search to achieve near-optimal results in practice, often yielding solutions within 1-2% of optimal on benchmark instances.
For asymmetric metric TSP, where edge costs satisfy the triangle inequality but are not symmetric (c(u,v) ≠ c(v,u)), adaptations of the core ideas use a minimum-weight assignment problem to handle directionality. These yield approximations worse than 3/2, such as parameterized 2.5-approximations for moderately asymmetric instances.[26]
Empirically, the standard Christofides algorithm performs well beyond its 3/2 worst-case guarantee, with average approximation ratios of about 5.4% on non-Euclidean TSPLIB instances and 9.56% on Euclidean ones, relative to optimal solutions computed by exact solvers like Concorde.[22] These results highlight its practicality for real-world instances, where the actual ratios are typically below 1.2 when combined with basic shortcutting refinements.[22]
Recent Theoretical Advances
In 2011, Shayan Oveis Gharan, Amin Saberi, and Mohit Singh introduced the first approximation algorithm for metric TSP surpassing the 3/2 ratio of the original Christofides algorithm, achieving a (3/2 - \epsilon)-approximation for some constant \epsilon > 0. Their innovation lies in a randomized rounding scheme applied to the Held-Karp linear programming relaxation, where a minimum spanning tree is sampled from a maximum-entropy distribution over spanning trees in the support graph of the LP solution. To construct the tour, they employ an adaptive walk on this tree—traversing edges only as needed to visit all vertices—which allows bounding the expected tour cost by the LP value plus a small additive term, yielding the improved ratio. This breakthrough marked a significant theoretical advance by exploiting probabilistic methods to reduce the contribution from the matching step in Christofides' construction.[23]
Building on this, the Best-of-Many Christofides algorithm, analyzed theoretically in subsequent work and evaluated experimentally in 2015, demonstrates an expected approximation ratio strictly better than 3/2 when multiple independent runs are performed and the best tour is selected. By repeating the randomized choices of the minimum spanning tree and the minimum-weight perfect matching on odd-degree vertices, the approach mitigates worst-case instances through averaging, with the expected cost shown to be less than 1.5 times the optimum on average over the runs. This variant highlights how variance in Christofides' random components can be leveraged for practical and theoretical gains without altering the core structure.[22]
For special cases like bounded-degree graphs, further improvements have been achieved. In 2011, Tobias Mömke and Ola Svensson presented a 4/3-approximation algorithm for graphic TSP on subcubic graphs (degree at most 3), using a novel framework of patching Eulerian paths with matchings to shortcut odd-degree vertices while controlling the added cost. This result settles the approximation ratio for bounded-degree graphic instances at 4/3, but extending it to general metric TSP remains open, as the triangle inequality introduces additional challenges in bounding shortcutting costs. A refined analysis yields 1.461 for general graphic TSP.[27]
Theoretical lower bounds underscore the difficulty of further progress using Christofides-like techniques. In 2012, Andrei Sebő and Jens Vygen established that no approximation better than 7/5 ≈ 1.4 is possible for graphic TSP without novel methods beyond ear decompositions and matching-based patching, based on integrality gap constructions for the subtour LP relaxation. This bound is conjectured to hold more broadly for metric TSP under similar structural assumptions.
Key open questions persist, including whether a 1.4-approximation algorithm exists for general metric TSP and if a polynomial-time approximation scheme (PTAS) is feasible—though the latter faces strong inapproximability barriers unless P = NP. As of 2025, advances continue with slight improvements over 3/2, such as ratios of 3/2 minus minuscule constants (e.g., 10^{-36}) via refined LP rounding and max-entropy samplers, but significant progress toward 4/3 for general metric TSP remains elusive.[3]