Reduction Goal
Source and Target Problems
Today we build a polynomial-time map \(\varphi \mapsto G_{\varphi}\) such that
High-Level Idea
- Each variable gadget forces the Hamiltonian cycle to choose one of two consistent traversals.
- Those two traversals encode \(x_i = \text{true}\) or \(x_i = \text{false}\).
- Clause gadgets can be visited only through a literal that is made available by the chosen traversal.
- Thus the cycle exists exactly when every clause has at least one satisfied literal.
Why Hamiltonian Constructions Look Complicated
For independent set or clique reductions, a solution is just a selected subset. For Hamiltonian cycle, a solution must visit every vertex exactly once and return to the start. So the reduction must enforce a very rigid global traversal pattern.
Most textbook proofs first show \[ \operatorname{3SAT} \le_p \operatorname{Directed\ Hamiltonian\ Cycle}, \] and then use a standard gadget conversion from directed Hamiltonian cycle to the undirected Hamiltonian cycle problem.
Variable and Clause Gadgets
Variable Gadget
For each variable \(x_i\), construct a directed path \[ p_{i,0}, p_{i,1}, p_{i,2}, \dots, p_{i,3m+2}, \] so each variable gadget has exactly \(3m+3\) vertices.
For clause \(C_j\), the interaction with the \(x_i\)-gadget takes place at the consecutive vertices \(p_{i,3j}\) and \(p_{i,3j+1}\). Whether the clause node attaches above or below that slot depends on whether the literal is \(x_i\) or \(\neg x_i\).
- if \(x_i \in C_j\), the clause attachment is usable when the gadget is traversed left-to-right,
- if \(\neg x_i \in C_j\), the clause attachment is usable when the gadget is traversed right-to-left.
Clause Gadget
For each clause \(C_j = (\ell_{j1} \vee \ell_{j2} \vee \ell_{j3})\), create one clause node \(c_j\) and attach it to the three relevant variable gadgets at their \(j\)-th slots.
The clause node always uses the pair of vertices indexed \(3j\) and \(3j+1\) inside each involved variable gadget. What changes from literal to literal is whether the attachment matches the left-to-right direction or the right-to-left direction.
Consistency Enforced by the Gadget Design
| Chosen traversal direction | Clause attachments that become usable |
|---|---|
| left to right | attachments corresponding to occurrences of \(x_i\) |
| right to left | attachments corresponding to occurrences of \(\neg x_i\) |
So a clause can be integrated into the Hamiltonian cycle only through a literal whose attachment matches the direction selected for that variable path.
Formal Construction
Input Formula
Let
with variables \(x_1,\dots,x_n\).
Construction Steps
Create one \(3m+3\)-vertex variable path for each \(x_i\), to be traversed in one of two directions.
Connect the variable gadgets in sequence so the cycle must pass through all of them.
For each clause \(C_j\), create a clause gadget and connect it to the three literal occurrences \(\ell_{j1}, \ell_{j2}, \ell_{j3}\).
Add connector vertices so that every vertex has to be covered by the Hamiltonian cycle and the cycle closes back to the start.
Size Bound
Each variable contributes a gadget of size polynomial in its number of occurrences, and each clause contributes a constant-size gadget. Therefore
What Must Be Checked in a Reduction Proof
- The graph is built in polynomial time.
- Every satisfying assignment yields a Hamiltonian cycle.
- Every Hamiltonian cycle determines a satisfying assignment.
Why the Reduction Works
Forward Direction
If \(\varphi\) is satisfiable, choose a satisfying assignment \(a\).
- Traverse each variable gadget in the direction prescribed by \(a\).
- For every clause \(C_j\), choose one literal made true by \(a\).
- Use the corresponding literal attachment at the \((3j,3j+1)\)-slot to detour through the clause gadget and return to the main cycle.
Because each clause has at least one true literal, every clause gadget can be inserted. The gadget design ensures that the whole walk visits every vertex once and closes into a directed Hamiltonian cycle.
Backward Direction
Suppose \(G_{\varphi}\) has a directed Hamiltonian cycle \(H\).
- In each variable gadget, \(H\) must choose exactly one of the two traversal directions; otherwise some gadget vertex would be missed or revisited.
- Set \(x_i=1\) if \(H\) uses the left-to-right direction and \(x_i=0\) if \(H\) uses the right-to-left direction.
- Each clause gadget must be entered through one of its three literal attachments.
The only usable attachments are those exposed by the chosen direction, so the literal used for clause \(C_j\) is true under the derived assignment. Hence every clause is satisfied and \(\varphi\) is satisfiable.
Core Invariant
The Hamiltonian constraint is doing two jobs simultaneously:
- it forces a globally consistent truth assignment across all occurrences of a variable, and
- it forces every clause gadget to be serviced by at least one satisfied literal.
NP-Completeness Consequences
Membership in NP
Directed Hamiltonian Cycle belongs to \(NP\): a certificate is an ordering of the vertices. The verifier checks in polynomial time that consecutive vertices form directed edges and that every vertex appears exactly once.
Conclusion
so Directed Hamiltonian Cycle is NP-complete.
From Directed to Undirected Hamiltonian Cycle
There is also a polynomial-time reduction
obtained by replacing each directed vertex with a small undirected gadget that forces any Hamiltonian cycle to respect the original entry and exit directions. Combining this with the reduction above shows that the standard undirected Hamiltonian Cycle problem is NP-complete as well.
How This Leads to TSP (Decision)
Given a graph \(G\), define a complete weighted graph where edges of \(G\) get weight \(1\) and missing edges get weight \(2\). Then
This gives the standard NP-hardness reduction from Hamiltonian Cycle to the decision version of TSP.
Takeaway
Hamiltonian reductions encode logical choices as forced traversal choices. The same pattern reappears in many path and routing problems.