Discrete MathGraph Theory

Hamilton Paths and Cycles

Visit every vertex exactly once; there is no quick test, but Dirac's theorem guarantees a cycle when every degree is at least n/2.

Not started Jump to practice

Euler circuits use every edge once, and a quick degree count decides whether one exists. Ask instead for a route that visits every vertex once, and everything changes: no quick test is known, only good sufficient conditions and good reasons for failure.

Key idea

A Hamilton path visits every vertex exactly once; a Hamilton cycle also returns to its start. Dirac's theorem: if a simple graph has $n \ge 3$ vertices and every vertex has degree at least $n/2$, it has a Hamilton cycle. The condition is sufficient, not necessary.

Why it works

Why can't we just count degrees as for Euler? A Hamilton cycle is a global object: whether one exists depends on how the whole graph fits together, not on each vertex separately. Some local facts do block it. A vertex of degree $1$ cannot be inside a cycle. If removing one vertex splits the graph, a cycle through everything would need to pass through that vertex twice. In a bipartite graph a cycle alternates sides, so the two sides must have equal size. Dirac's theorem works in the other direction: with that many edges at every vertex, there is always room to reroute and close a cycle.
The cube graph. Click vertices to visit each exactly once, then close the cycle back to the start.

Worked examples

Worked example: The cube

Does the cube graph (vertices of a cube, edges along the cube's edges) have a Hamilton cycle?
  1. Label the top face $A, B, C, D$ in order and the bottom face $E, F, G, H$ below them.
  2. Try $A \to B \to C \to D \to H \to G \to F \to E \to A$.
  3. Every consecutive pair is an edge, each vertex appears once, and $E$ is joined to $A$. Yes.

Answer: Yes: $A, B, C, D, H, G, F, E$, back to $A$

Worked example: A graph that cannot

Does $K_{2,3}$ have a Hamilton cycle?
  1. A cycle in a bipartite graph alternates sides, so it uses equally many vertices from each side.
  2. The sides have $2$ and $3$ vertices, so no cycle can use all $5$.

Answer: No

Worked example: Using Dirac's theorem

A graph has $6$ vertices, and every vertex has degree at least $3$. Must it have a Hamilton cycle? What if the minimum degree is only $2$?
  1. $n/2 = 3$, and every degree is at least $3$: Dirac guarantees a Hamilton cycle.
  2. With minimum degree $2$, the theorem says nothing. The cycle $C_{6}$ has every degree $2$ and is itself a Hamilton cycle; two separate triangles also have every degree $2$ and have none.

Answer: Yes; with degree $2$ it may or may not

Common mistake

Treating Dirac's condition as necessary. "Not every degree is at least $n/2$, so there is no Hamilton cycle" is wrong: $C_{6}$ has all degrees $2 < 3$ and is a Hamilton cycle. Check: when Dirac's condition fails, try to build a cycle or look for a real obstacle (a degree-$1$ vertex, a cut vertex, unequal bipartite sides).
The Petersen graph has $10$ vertices of degree $3$ and no Hamilton cycle, a fact found by checking every route. Try to visit all ten.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

This is one of the top rungs of Discrete Math.

Sources and further reading

  • Oscar Levin, Discrete Mathematics: An Open Introduction (3rd ed.), section "Euler Paths and Circuits" (Hamilton paths)
  • MIT OpenCourseWare 6.042J Mathematics for Computer Science (Lehman, Leighton and Meyer), chapter "Simple Graphs"
@teddyrookbook GitHub