Definition · The metric travelling salesmanDistances are given for every pair of cities, are symmetric, and satisfy the triangle inequality: D(a,b) ≤ D(a,c) + D(c,b) for all a, b, c. The problem is to find a shortest tour visiting every city once and returning. Distances that come from positions in space always satisfy the inequality, which is why the hypothesis is usually free.
The algorithm
- Build a minimum spanning tree of the cities.
- Walk it, using every edge exactly twice, returning to the start. The walk has weight exactly twice the tree.
- Traverse the walk and skip every city already visited, hopping directly to the next new one. What is left visits each city once: a tour.
Theorem · The doubled tree gives a tour within twice the optimumFor distances satisfying the triangle inequality, the tour produced has length at most 2 · MST ≤ 2 · OPT.
Deleting one step from an optimal tour leaves a connected acyclic spanning subgraph, that is, a spanning tree, of weight at most the tour's. So MST ≤ OPT.
The doubled walk has weight exactly 2 · MST and visits every city. Shortcutting replaces a sub-path from a to b through already-visited cities by the direct hop D(a,b); by the triangle inequality applied along that sub-path, the hop is no longer than the sub-path it replaces. So the tour is at most 2 · MST, and combining gives 2 · OPT.
□
The chain, as four numbers
the tree 5 a lower bound the algorithm computes
the optimum 7 by exhaustive search over the tours
the tour built 10 the doubled tree, shortcut
twice the tree 10 the promise
The loaded instance is four cities with the distances 1-2 2, 1-3 1, 1-4 3, 2-3 3, 2-4 2, 3-4 2, which satisfies the triangle inequality. The tree takes the edges of weight 1, 2 and 2 for a total of 5; the shortcut tour is 1, 2, 3, 4 at length 10; the optimum is 7, attained by 1, 2, 4, 3; and the realised ratio is 10/7. Notice that the tour equals 2 · MST exactly here, so the last link of the chain is an equality and all the slack in the promise lives in the gap between 5 and 7.
This instance was not chosen by hand. The panel enumerates every symmetric instance on four cities with distances from 1 to 3 — 729 of them — keeps the 482 that are metric, solves each exactly, and reports the worst ratio any produced. It is 10/7, and this is the instance attaining it. On three cities the same sweep reports a worst ratio of 1: the heuristic is exact there, because every tour on three cities is the same tour.
Example · Switching the hypothesis offLoad the instance with one distance raised: 1-2 50 with every other distance 1. The direct hop from 1 to 2 costs 50 while going round through 3 costs 2, so the triangle inequality fails by a factor of 25. The panel reports metric: no, a tree of 3, a promise of 6, an optimum of 4 — and a tour of 53, against a promise of 6. The answer is more than eight times the promise the algorithm made, because the shortcut step replaced a cheap path by an enormous hop and the proof's last line is simply false.
That is the most important thing on this page. A guarantee is a conditional, and when the condition fails there is no residual weaker guarantee: the algorithm can be arbitrarily bad, and the slider can make the ratio as large as you like. Raising the distance further raises the tour without limit while the optimum stays at 4.
And the general problem really is that bad, which was proved earlier on this course by putting ρ · n + 1 on the non-edges: no constant-factor approximation exists for the travelling salesman without a hypothesis, unless P = NP. So the triangle inequality is not a convenience that simplifies the analysis. It is the difference between a problem with a factor-2 algorithm and a problem with no constant-factor algorithm at all.