Held–Karp Traveling Salesman
Solve a tiny traveling-salesman instance through subsets and reconstruct the best tour.
Free theory articleSolve a tiny traveling-salesman instance through subsets and reconstruct the best tour.
Concept & interpretation
The Traveling Salesman Problem (TSP) asks for the shortest possible route that visits each city exactly once and returns to the origin city. The Held-Karp algorithm uses dynamic programming to solve TSP exactly in O(n2 2n) time, which is much faster than the O(n!) brute-force search.
Experiment
You can interactively explore different instances:
- Open the Held-Karp module.
- Observe the optimal tour and cost for the default Square instance.
- Change the Instance to Asymmetric. Notice how the distances depend on the direction.
- Change to Disconnected to see what happens when no Hamiltonian tour is possible. The cost will be Unavailable.