Held–Karp algorithm
Dynamic programming algorithm for exact TSP solution.
It finds the exact solution to this problem, and to several related problems including the Hamiltonian cycle problem, in exponential time.
- field
- Computer science, operations research
- known_for
- Held–Karp algorithm for the traveling salesman problem
Lore & Background
The algorithm numbers cities 1,2,…,n, with 1 designated arbitrarily as a starting city. It calculates, for each set of cities S ⊆ {2,…,n} and every city e ≠ 1 not contained in S, the shortest one-way path from 1 to e that passes through every city in S in some order. This distance is denoted g(S,e), with d(u,v) representing the length of the direct edge from u to v. Values of g(S,e) are computed starting with the smallest sets S and finishing with the largest.
Reader's Guide
The Held–Karp algorithm is significant as an exact solution method for the traveling salesman problem, a classic NP-hard problem. Its dynamic programming approach systematically computes optimal subpaths, reducing the number of paths that must be examined. For sets S with two or fewer elements, calculation requires looking at one or two possible shortest paths. For larger sets, only a few paths need examination because the optimal substructure property holds: if the shortest path from 1 through S to e has a particular second-to-last city, then removing the final edge gives the shortest path from 1 to that city through the remaining set. This algorithm also applies to the Hamiltonian cycle problem. Its legacy lies in demonstrating that exact exponential-time solutions are feasible for small instances, and it remains a foundational technique in combinatorial optimization.
Did You Know?
- It finds the exact solution to the traveling salesman problem in exponential time.
- The algorithm also solves the Hamiltonian cycle problem.
- It computes shortest one-way paths from a starting city through subsets of other cities.
Problem Definition and Scope
The subgraph isomorphism problem asks whether a given graph G contains a subgraph that is structurally identical to another graph H. This is a foundational question in theoretical computer science, and it subsumes several well-known tasks: finding the largest clique in a graph and determining whether a graph possesses a Hamiltonian cycle are both special cases. Because of this generalization property, the problem inherits NP-completeness from those underlying questions. The terminology can be slightly confusing—some researchers call it "subgraph matching" when the emphasis is on actually identifying and returning the matching subgraph rather than merely answering a yes-or-no decision query. Despite its intractability in full generality, certain restricted instances can be resolved in polynomial time, making the problem a rich area where computational hardness and tractability coexist in interesting tension.
NP-Completeness and Reductions
To establish NP-completeness, the problem must be cast as a decision question: given graphs G and H, does there exist a subgraph of G isomorphic to H? The formal statement involves finding a subset of vertices and edges in G that, under some bijection, preserve exactly the adjacency structure of H. The standard proof reduces from the clique problem—simply set H to be the complete graph on k vertices, and the subgraph isomorphism question becomes equivalent to asking whether G contains a k-clique. An alternative reduction uses the Hamiltonian cycle problem, where H is a cycle with the same vertex count as G; since Hamiltonicity remains NP-complete even for planar graphs, this demonstrates that subgraph isomorphism is hard in the planar setting as well. Notably, subgraph isomorphism generalizes the graph isomorphism problem, whose exact placement in the complexity hierarchy is still unresolved.
Algorithmic Landscape
The algorithmic history of subgraph isomorphism spans nearly five decades of refinement. Ullmann's 1976 paper introduced a recursive backtracking method that, while exponential in the worst case, runs in polynomial time when H is held fixed. In 2004, Cordella proposed VF2, which refined Ullmann's approach with different heuristics and notably reduced memory consumption. It employs a constraint programming framework combined with bit-parallel data structures and specialized propagation techniques to achieve strong performance on hard cases.
Theoretical Boundaries and Open Questions
Beyond the standard NP-completeness result, subgraph isomorphism sits at the intersection of several deep theoretical questions. It is a strict generalization of graph isomorphism, yet the latter's placement within the complexity hierarchy remains one of the most prominent open problems in computer science. This query-complexity result provides a meaningful barrier even for randomized or adaptive strategies. Meanwhile, structural restrictions on the input—such as requiring G to be planar or more generally of bounded expansion—can collapse the running time to linear when H is fixed, illustrating how geometric constraints can tame otherwise intractable search.
Frequently Asked Questions
What problem does the Held–Karp algorithm actually solve?
It finds the shortest Hamiltonian cycle that visits every node exactly once, giving a guaranteed optimal answer to the traveling salesman problem. The same framework can be adapted to other related problems, such as the general Hamiltonian cycle problem.
How fast is the Held–Karp algorithm in practice?
It runs in exponential time, roughly O(n²·2ⁿ), so it is only tractable for relatively small instance sizes. Even so, it remains the standard method whenever a provably optimal TSP tour is required rather than a heuristic approximation.
Why does the Held–Karp algorithm still matter?
It was among the first rigorous exact methods for TSP and cemented dynamic programming as a core tool in combinatorial optimization. More than six decades later it continues to serve as the benchmark against which approximation and heuristic approaches are measured.
More in Algorithms And Data Structures 25-38
Elsewhere in the Algorithms And Data Structures universe
Spotted an error? Know more?
This is a living reference — every entry is fact-audited, and reader corrections feed straight into our audit queue. Suggest an edit · See this site's audit record
