Hamiltonian Cycle Problem (HAMILTONIAN)
The Hamiltonian Cycle Problem (HAMILTONIAN) takes an input of:
- an undirected graph
It provides an output of if and only if contains a Hamiltonian cycle.
Link to original
Theorem: Hamiltonian Cycle Problem belongs to NP
Input: Given an undirected graph
- Decide whether contains a Hamiltonian cycle by checking every permutation of the vertices. However there are possible permutations which is not polynomial.
- However, an NDTM can check each permutation in parallel. Since each permutation requires us to only check edges, this is in polynomial time.
Theorem: The SAT problem is polynomially reducible to the Hamiltonian cycle problem, .
Input: Formula in CNF.
- We want to construct a graph such that is satisfiable if and only if has a Hamiltonian cycle.
- We make use of the following “gadget”:

This gadget has only two possible Hamiltonian paths through:
e.g. let’s construct a graph for .
- We start by placing one gadget for each variable.
- We connect the bottom of each gadget to the top of the next gadget (looping back around at the last one).
- We create a vertex for each clause.

- Let’s assume that going down the left path of the gadget means the variable is true, otherwise it is false.
- We connect the first vertex going left to right to indicate that the variable () must be true to satisfy the vertex.

- We continue to wire up the rest of the variables from each vertex corresponding to the desired value.

- We can make sastifiable when:
| are true is false | are false |
|---|---|
![]() | ![]() |
- Hence, we have that is satisfiable contains a Hamiltonian cycle. Therefore .
Theorem: HAMILTONIAN is NP-complete
Since SAT is NP-hard, it follows that the Hamiltonian Cycle Problem must also be NP-hard. This gives us our lower-bound which proves HAMILTONIAN is NP-complete.


