Fact-checked by Grok 2 weeks ago

Christofides algorithm

The Christofides algorithm, also known as the Christofides–Serdyukov algorithm, is a polynomial-time for the metric traveling salesman problem (TSP), which seeks a minimum-length Hamiltonian cycle in a where edge weights satisfy the , non-negativity, and symmetry. 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. Developed by Nicos Christofides in a at , the algorithm was independently discovered around the same time by Soviet mathematician A. I. Serdyukov, whose work was submitted in January but published in 1978. Christofides' approach improved upon earlier 2-approximation heuristics, such as twice traversing a (MST) and shortcutting repeats, by addressing the parity issue in degrees to better bound the tour cost. 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 M on the induced by O, with cost at most half of OPT; (4) forming a 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. 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 . For nearly five decades, this 3/2 factor represented the best known polynomial-time approximation ratio for metric TSP, underscoring its foundational role in . 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 for its simplicity, provable performance, and influence on subsequent TSP heuristics.

Background

Traveling Salesman Problem

The traveling salesman problem (TSP) is a fundamental problem in and . 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. The TSP is -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. Exact solutions are possible through methods like dynamic programming, exemplified by the Held-Karp algorithm, which achieves optimality in O(2^n n^2) but becomes computationally infeasible for instances with more than about 20-30 cities due to exponential growth. The problem is classified as symmetric if the distance between any two cities is the same in both directions (i.e., undirected ), or asymmetric otherwise, where directional differences apply (i.e., ). A notable variant is the TSP, which assumes distances obey the and is addressed in subsequent sections.

Metric TSP Variant

The traveling salesman problem (TSP) is a restricted version of the TSP where the input is a complete undirected with edge weights representing s that form a . 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 : for any cities u, v, and w, d(u,v) \leq d(u,w) + d(w,v). 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. The metric TSP is particularly relevant for modeling practical applications, such as or board , where distances approximate geometries or actual road networks that inherently obey the . 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. 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. Metric TSP instances are formulated on complete graphs, ensuring every pair of cities is connected by an edge weighted by the distance, which facilitates the assumption of direct accessibility while maintaining the problem's combinatorial challenge.

Algorithm Description

High-Level Overview

The Christofides algorithm is a polynomial-time for the traveling salesman problem (TSP), in which the goal is to find a minimum-length cycle in a where edge weights satisfy the . 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. The core idea combines a of the with a minimum-weight 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. The approach leverages the properties of MSTs and matchings to ensure the tour remains efficient under the metric assumption. The algorithm guarantees a tour whose total length is at most 1.5 times that of the optimal TSP tour. 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.
This pseudocode captures the essential steps without implementation specifics.

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 (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 or . 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 on which a minimum-weight can be computed. This matching is found by solving the on the restricted to these odd-degree vertices, ensuring that each is paired exactly once with minimum total edge weight. The edges of this minimum-weight are then added to the MST, resulting in a where all vertices now have even degree, thereby making the Eulerian. An Eulerian tour of this , 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. Finally, the Eulerian tour is transformed into a Hamiltonian cycle—a TSP tour that visits each exactly once—by shortcutting: whenever the tour revisits a previously visited , the path between repeats is replaced by a direct edge to the next unvisited . 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.

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. 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. 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. 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. 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. This \frac{3}{2}-approximation bound is tight, as there exist metric TSP instances where the algorithm's output achieves a arbitrarily close to \frac{3}{2}.

Computational Complexity

The Christofides algorithm operates in polynomial time, achieving an overall of O(n^3) for a with n vertices, where the dominant step is the computation of the minimum-weight . This complexity arises from the breakdown of its core components. The (MST) is constructed using implemented with heaps, which runs in O(E + V \log V) time; for a dense where E = \Theta(n^2), this simplifies to O(n^2). The minimum-weight on the subgraph induced by the odd-degree vertices in the MST (at most n/2 vertices) employs an efficient implementation of Edmonds' , achieving O(n^3) time for dense graphs. Constructing the Eulerian tour in the augmented (with O(n) edges) via Hierholzer's algorithm takes O(n) time, as it traverses each edge a constant number of times. 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 to skip repeats while preserving the metric order. 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. 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.

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 (e.g., based on distances with 0 at the center and others positioned such that MST edges are 1 unit). Assume the (MST) T consists of edges 0–1, 0–2, 0–3, 0–4, each of weight 1, for a total cost of 4. 0 has 4 (even), while vertices 1, 2, 3, 4 have 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' = TM 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).

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. 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. 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. A related adaptation targets the s-t path variant of the TSP, where the goal is to find a minimum-cost 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 , which is then shortcut to a , achieving an approximation ratio of $1 + \sqrt{5}/2 \approx 1.618. This improves upon the 5/3 ratio of the direct adaptation of the original Christofides algorithm and relies on the same sampling and selection mechanism to derandomize the process. Tours produced by the Christofides algorithm are frequently post-processed with local search heuristics to refine the solution further. Common methods include , which iteratively swaps pairs of edges to eliminate crossings and reduce tour length, or the more advanced Lin-Kernighan heuristic, which generalizes 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 but are not symmetric (c(u,v) ≠ c(v,u)), adaptations of the core ideas use a minimum-weight to handle directionality. These yield approximations worse than , such as parameterized 2.5-approximations for moderately asymmetric instances. Empirically, the standard Christofides algorithm performs well beyond its worst-case guarantee, with average approximation ratios of about 5.4% on non- TSPLIB instances and 9.56% on ones, relative to optimal solutions computed by exact solvers like . These results highlight its practicality for real-world instances, where the actual ratios are typically below 1.2 when combined with basic shortcutting refinements.

Recent Theoretical Advances

In 2011, Shayan Oveis Gharan, Amin Saberi, and Mohit Singh introduced the first for metric TSP surpassing the ratio of the original Christofides algorithm, achieving a ( - \epsilon)-approximation for some constant \epsilon > 0. Their innovation lies in a randomized rounding scheme applied to the Held-Karp , where a 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. 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. For special cases like bounded-degree graphs, further improvements have been achieved. In 2011, Tobias Mömke and Ola Svensson presented a 4/3- algorithm for graphic TSP on subcubic graphs (degree at most ), 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 introduces additional challenges in bounding shortcutting costs. A refined analysis yields 1.461 for general graphic TSP. 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.

References

  1. [1]
    [PDF] Worst-Case Analysis of a New Heuristic for the Travelling Salesman ...
    The worst-case analysis shows the ratio of the answer to the optimal solution is strictly less than 3/2, a 50% improvement over previous results.
  2. [2]
    [PDF] Christofides's -Approximation for Metric TSP
    The object is to find a Hamiltonian cycle of minimum length. First construct a minimum spanning tree M. Starting at an arbitrary point of X, ...
  3. [3]
    Traveling salesman problem - Optimization Wiki
    Sep 25, 2020 · The traveling salesman problem (TSP) is a widely studied combinatorial optimization problem, which, given a set of cities and a cost to travel from one city to ...Missing: definition | Show results with:definition
  4. [4]
    [PDF] 1 The Traveling Salesperson Problem (TSP)
    Jan 21, 2011 · TSP is known to be NP-Hard. Moreover, we cannot hope to find a good approximation al- gorithm for it unless P = NP. This is because if one ...
  5. [5]
    A Dynamic Programming Approach to Sequencing Problems - jstor
    This procedure of suc- cessive approximations is developed in detail in ?2 with specific reference to the traveling-salesman problem, and ?3 summarizes ...
  6. [6]
    [PDF] Traveling salesman problem
    The TSP problem belongs in the class of such problems known as NP-complete. Specifically, if one can find an efficient (i.e., polynomial-time) algorithm for the ...
  7. [7]
    [PDF] Lecture 4-5 1 Euclidean TSP - Theory @ EPFL
    Mar 5, 2013 · approximation scheme (PTAS) for metric TSP (the precise statement is: there cannot be a 220/219- approximation unless P=NP [PV00]). Hence, we ...
  8. [8]
    [PDF] Approximation algorithms for the traveling salesman problem with ...
    Abstract. We prove that the Christofides algorithm gives a | approx- imation ratio for the special case of traveling salesman problem (TSP).Missing: original | Show results with:original
  9. [9]
    Vehicle routing on road networks: How good is Euclidean ...
    We have seen that, on the whole, using Euclidean distances instead of real road distances gives acceptable results for the Steiner TSP and Steiner CVRP.
  10. [10]
    [PDF] Polynomial Time Approximation Schemes for Euclidean Traveling ...
    In metric TSP the nodes lie in a metric space (i.e., the distances satisfy the triangle inequality). In Euclidean TSP the nodes lie in ℜ2 (or more generally, in ...Missing: world | Show results with:world
  11. [11]
    On The Approximability Of The Traveling Salesman Problem
    We show that the traveling salesman problem with triangle inequality cannot be approximated with a ratio better than 117 116 when the edge lengths are ...
  12. [12]
    [PDF] Lecture 14 1 Overview 2 Metric Traveling Salesman
    Oct 23, 2015 · The key property for our approximation algorithms will be the triangle inequality. To summarize, we will list the key differences in metric TSP ...
  13. [13]
    Worst-Case Analysis of a New Heuristic for the Travelling Salesman ...
    An O(n3) heuristic algorithm is described for solving d-city travelling salesman problems (TSP) whose cost matrix satisfies the triangularity condition and ...
  14. [14]
    Worst-Case Analysis of a New Heuristic for the Travelling Salesman ...
    Mar 3, 2022 · Worst-Case Analysis of a New Heuristic for the Travelling Salesman Problem ... Christofides N (1975) Graph theory – an algorithmic approach ...
  15. [15]
    A historical note on the 3/2-approximation algorithm for the metric ...
    In a combinatorial optimization textbook, Christofides (1979) describes his algorithm without proving the approximation factor, referring to an article in ...Missing: original paper
  16. [16]
    [PDF] State-of-the-Art Algorithms for Minimum Spanning Trees∗
    ... graphs where Prim's is optimal for dense graphs m = Ω(nlog n), then Prim's algorithm using Fibonacci heaps uses time O(m). Since any correct algorithm must ...
  17. [17]
    An Efficient Implementation of Edmonds' Algorithm for Maximum ...
    This paper presents an efficient implementation of Edmonds' algorithm for finding a maximum matching. The computation time is proportional to V 3.<|separator|>
  18. [18]
    Hierholzer's Algorithm for directed graph - GeeksforGeeks
    Aug 28, 2025 · Time Complexity : O(V + E), where V is the number of vertices and E is the number of edges in the graph. The reason for this is because the ...
  19. [19]
    Approximate solution for Travelling Salesman Problem using MST
    Jul 23, 2025 · Time Complexity: O(n ^ 3), the time complexity of triangleInequality() function is O(n ^ 3) as we are using 3 nested loops, and all other ...
  20. [20]
    An extension of the Christofides heuristic for the generalized ...
    Mar 16, 2017 · Here, we improve on these algorithms by providing a new non-trivial extension of the well-known Christofides heuristic of the TSP (Christofides ...Missing: implementations | Show results with:implementations
  21. [21]
    [1110.4604] Improving Christofides' Algorithm for the s-t Path TSP
    Oct 20, 2011 · We present a deterministic (1+sqrt(5))/2-approximation algorithm for the st path TSP for an arbitrary metric.
  22. [22]
    Improving christofides' algorithm for the s-t path TSP
    We present a deterministic (1+√5/2)-approximation algorithm for the s-t path TSP for an arbitrary metric. Given a symmetric metric cost on n vertices including ...
  23. [23]
    An Experimental Evaluation of the Best-of-Many Christofides ... - arXiv
    Jun 25, 2015 · Recent papers on approximation algorithms for the traveling salesman problem (TSP) have given a new variant on the well-known Christofides' ...
  24. [24]
    From symmetry to asymmetry: Generalizing TSP approximations by ...
    For TSP it was known for over 40 years that a 3 2 -approximation is possible with the famous algorithm of Christofides [2] (or Christofides-Serdyukov, see [3]).
  25. [25]
    [PDF] A Randomized Rounding Approach to the Traveling Salesman ...
    Similar to Christofides, our algorithm finds a spanning tree whose cost is upper bounded by the optimum, then it finds the minimum cost Eulerian augmentation ( ...
  26. [26]
    [1104.3090] Approximating Graphic TSP by Matchings - arXiv
    Apr 15, 2011 · This paper presents a framework for approximating metric TSP using matchings, achieving a 1.461-approximation for graph-TSP, and 1.586 for pre- ...
  27. [27]
    A (Slightly) Improved Approximation Algorithm for Metric TSP - arXiv
    Jul 2, 2020 · A (Slightly) Improved Approximation Algorithm for Metric TSP. Authors:Anna R. Karlin, Nathan Klein, Shayan Oveis Gharan.Missing: Saberi Vazirani 2011