The traveling salesman: easy to check, brutally hard to solve
When delivery companies plan which parcel van stops where, or a drill plans its path across a circuit board
What problem does it solve?
What's the shortest round trip that visits every city exactly once?
The big idea
Finding the shortest path between two places is easy (Dijkstra). But a round trip through every city is a different beast: the number of possible tours explodes like a factorial, and no one has ever found a method guaranteed to be fast for every map. Yet if someone hands you a tour and claims 'this is under 1000 km', you can check it instantly. That gap, between checking an answer and finding one, is the heart of P vs NP, the biggest open question in computer science.
How it works, step by step
- 1. Brute force: list every possible tour and measure each (only feasible for about a dozen cities).
- 2. Greedy start: from each city, go to the nearest unvisited city, which is fast but often 20–25% too long.
- 3. Improve: find two crossing edges and uncross them (2-opt), and repeat until no swap helps.
- 4. For proof of the best answer, use clever branch-and-bound methods that rule out huge families of tours at once.
The key formula
- the number of cities
- fix the starting city, then arrange the other n − 1 in any order
- a tour and its reverse are the same loop
How fast is it?
20 cities already gives about 6 × 10¹⁶ tours. The cleverest known exact method (Held–Karp, 1962) takes about n²·2ⁿ steps, which is still exponential. Real logistics uses fast heuristics that get within a few percent of the best tour. If anyone proves P = NP or P ≠ NP, the Clay Mathematics Institute will pay them $1,000,000.
Try it yourself
- Draw 5 dots and find the best tour by hand. How many tours did you have to consider? (12.)
- Why is a tour with two crossing edges never the shortest? (Hint: uncrossing them shortens it, by the triangle inequality.)
Fun fact
In 2006 the Concorde program proved the optimal tour through 85,900 points, from a real computer-chip wiring problem. And for maps where distances obey the triangle inequality, Christofides' 1976 algorithm guarantees a tour at most 1.5 times the best, in fast polynomial time.