Hamiltonian Cycle — Definition, Formula & Examples
A Hamiltonian cycle is a path through a graph that starts at one vertex, visits every other vertex exactly once, and returns to the starting vertex. A graph that contains such a cycle is called Hamiltonian.
Given a graph with , a Hamiltonian cycle is a cycle such that every vertex in appears exactly once in the sequence and each consecutive pair as well as is an edge in .
How It Works
To check whether a graph has a Hamiltonian cycle, you look for a way to traverse all vertices exactly once and return to your starting point using only existing edges. There is no known efficient (polynomial-time) algorithm for this in general — determining whether a Hamiltonian cycle exists is a classic NP-complete problem. For small graphs, you can attempt a systematic search or backtracking. Sufficient conditions exist: Dirac's theorem states that if every vertex in a simple graph on vertices has degree at least , then the graph is Hamiltonian.
Worked Example
Problem: Determine whether the complete graph (four vertices, each connected to every other) has a Hamiltonian cycle.
Label the vertices: Call the four vertices , , , and . Every pair of distinct vertices shares an edge.
Construct a cycle visiting each vertex once: Start at , go to , then , then , and return to . The path is .
Verify: Each vertex appears exactly once before returning to , and every consecutive pair is an edge in . This is a valid Hamiltonian cycle.
Answer: Yes, has a Hamiltonian cycle, for example .
Why It Matters
The Hamiltonian cycle problem is a foundational example in computational complexity, used to prove NP-completeness of other problems. It also underpins the Traveling Salesman Problem, which has direct applications in logistics, circuit board drilling, and DNA sequencing.
Common Mistakes
Mistake: Confusing a Hamiltonian cycle with an Eulerian circuit.
Correction: A Hamiltonian cycle visits every vertex exactly once; an Eulerian circuit traverses every edge exactly once. They impose fundamentally different requirements on the graph.
