WIPIVERSE All articles

Hamiltonian path problem

The Hamiltonian path problem is a decision problem in graph theory and theoretical computer science. It asks whether a given graph (directed or undirected) contains a Hamiltonian path—a path that visits each vertex exactly once.

Definition Formally, given a graph $G = (V, E)$, the problem is to determine if there exists a sequence of vertices $v_1, v_2, \dots, v_n$ such that:

  1. Every vertex in $V$ appears exactly once in the sequence.
  2. For every $i$ from 1 to $n-1$, the edge $(v_i, v_{i+1})$ belongs to $E$.

Computational Complexity The Hamiltonian path problem is NP-complete. This was proven by Richard Karp in 1972 as one of his 21 NP-complete problems. The proof typically involves a reduction from the Vertex Cover problem or the 3-SAT problem.

  • The problem remains NP-complete for directed graphs, undirected graphs, planar graphs, bipartite graphs, and chordal graphs.
  • It can be solved in polynomial time for certain restricted graph classes, such as trees, interval graphs, and properly interval graphs.

Relation to Hamiltonian Cycle Problem The Hamiltonian path problem is closely related to the Hamiltonian cycle problem (determining if a graph contains a cycle visiting every vertex exactly once). The two problems are polynomial-time reducible to each other:

  • To reduce Hamiltonian Path to Hamiltonian Cycle: Add a new universal vertex connected to all existing vertices. The new graph has a Hamiltonian cycle if and only if the original graph has a Hamiltonian path.
  • To reduce Hamiltonian Cycle to Hamiltonian Path: Make copies of a vertex or split a vertex to force the path endpoints.

Algorithms

  • Exact Algorithms: Due to NP-completeness, no polynomial-time algorithm is known for general graphs (assuming P ≠ NP). Exact algorithms typically use backtracking, dynamic programming (e.g., the Held-Karp algorithm running in $O(n^2 2^n)$ time), or integer linear programming.
  • Approximation: The decision version does not have a standard approximation ratio. The optimization variant (finding the longest path) is APX-hard and difficult to approximate within any constant factor.
  • Parameterized Complexity: The problem is fixed-parameter tractable (FPT) when parameterized by the path length (trivially, as the parameter equals $n-1$) or treewidth. It is W[1]-hard when parameterized by the size of a feedback vertex set or clique-width.

Applications The problem has applications in:

  • Logistics and Routing: Vehicle routing problems where each location must be visited once.
  • Bioinformatics: Genome assembly (finding a path through a De Bruijn graph or overlap graph) and protein folding.
  • Network Design: Testing network connectivity and vulnerability.
  • Computer Science: Register allocation, code optimization, and Gray code generation.

History The problem is named after Sir William Rowan Hamilton, who invented the "Icosian Game" in 1857. The game involved finding a Hamiltonian cycle on the vertices of a dodecahedron. The general graph problem was studied extensively in the 20th century, becoming a cornerstone of NP-completeness theory in the 1970s.

Browse

More topics to explore

    Browse all articles