Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
A tour at most 1.5 times the shortest
Travelling salesman tour at most 1.5 times the shortest: spanning tree, matching of odd vertices, Euler circuit, shortcuts
Select an algorithm and generate steps to begin visualization
The Christofides algorithm finds a travelling salesman tour that is guaranteed to be at most 1.5 times as long as the shortest possible tour, whenever the distances obey the triangle inequality. Nicos Christofides published it in 1976, and Anatoliy Serdyukov found it independently. For more than forty years no polynomial-time algorithm had a better guarantee for the metric TSP.
Start with a minimum spanning tree: removing one edge from the best tour leaves a spanning tree, so the tree is cheaper than the best tour. The vertices of odd degree in the tree are then paired by a minimum-weight perfect matching, which costs at most half the best tour. Tree plus matching has only even degrees, so it has an Euler circuit, of weight at most 1.5 times the optimum. Finally the circuit is shortcut: vertices already visited are skipped, which by the triangle inequality never makes the walk longer. When the graph is not complete, distances are shortest-path distances. With Edmonds' blossom algorithm for the matching it runs in O(V³) time.
Christofides is used where an exact TSP solution is too slow: vehicle routing, drilling holes in circuit boards, ordering warehouse picks and planning delivery rounds, often as a starting tour that local search such as 2-opt then improves. In algorithms courses it is the classic approximation algorithm with a proven guarantee, and it shows how spanning trees, matchings and Euler circuits fit together.
Christofides builds a travelling salesman tour from a minimum spanning tree, repairs the odd degrees with a cheapest perfect matching, walks an Euler circuit and shortcuts repeated cities. On metric distances the tour is never more than 1.5 times the optimum.
Christofides(cities, d): // d obeys the triangle inequality
T = minimum spanning tree of the complete graph
O = the vertices of odd degree in T
M = minimum weight perfect matching on O
H = T + M // every degree is now even
C = an Euler circuit of H
tour = C with every repeated city skipped
return tourThe guarantee comes from two lower bounds on the optimal tour OPT. Deleting one edge of OPT leaves a spanning tree, so the MST weighs at most OPT. Shortcutting OPT to the odd vertices gives a cycle of length at most OPT through them, which splits into two perfect matchings, so the cheaper one, and hence M, weighs at most OPT / 2. The circuit weighs at most 1.5 OPT, and by the triangle inequality skipping cities can only shorten it.
Run Christofides from A on the example this page loads: seven cities, every pair connected, with distances taken from the drawing.
Example graph: A complete graph on A to G. The distances used below are A-B 12, A-F 13, B-G 10, C-D 11, C-G 11, D-E 11, E-G 10, F-G 12, B-E 20, B-C 12 and E-F 13. G sits in the middle of the map, with the other six cities around it.
Christofides returns a tour of length 90. The optimal tour on these distances is A-B-C-D-E-G-F-A with length 81, found by checking all 360 tours, so the approximation is 11 percent above optimal, well inside the guaranteed factor of 1.5. A 2-opt pass on the Christofides tour would be the natural next step in practice, since it removes crossings that the construction leaves behind.
Time: O(n^3) · Space: O(n^2)
On a complete graph of n cities the minimum spanning tree costs O(n^2) with the array version of Prim. The minimum weight perfect matching on the odd vertices, at most n of them, costs O(n^3) with the Edmonds blossom algorithm and dominates the running time. The Euler circuit and the shortcut pass are linear in the number of edges of H, which is O(n). The distance matrix itself takes O(n^2) memory. In practice the matching is the bottleneck, and large implementations replace it by a greedy matching, which is faster but no longer carries the 1.5 guarantee.
Christofides is the classical approximation with a proven bound. Other methods are faster, more accurate in practice, or exact on small inputs.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Nearest neighbour | You need a tour instantly. It has no constant factor guarantee and is typically about 25 percent above optimal. | O(n^2) |
| Double tree | A simpler bounded method is enough. Doubling the MST instead of matching gives a factor of 2. | O(n^2) |
| 2-opt and Lin-Kernighan | Tour quality matters more than a worst-case proof. Local search usually lands within a few percent of optimal. | O(n^2) per pass |
| Held-Karp dynamic programming | The instance has at most about 20 cities and you want the exact optimum. | O(n^2 2^n) |
| Branch and cut (Concorde) | You need proven optimal tours on instances with thousands of cities. | exponential worst case |
Read the full article: Traveling Salesperson Problem (TSP)
Read the full article: Hamiltonian Paths and Cycles Explained
Related algorithms: Traveling Salesman Problem, Prim's MST Algorithm, Chinese Postman, Hamiltonian Path