The following slideshow shows that an instance of the 3-CNF
Satisfiability (3-SAT) problem can be reduced to an instance of
Hamiltonian Cycle in polynomial time.
A trivial change in the construction will allow reduction from 3-SAT
to the Hamiltonian Path problem.
This slideshow explains the reduction (in polynomial time) of an instance of 3CNF Satisfiability (3-SAT) to an instance of the Hamiltonian Cycle problem.
x1
. . .
x2
. . .
x3
. . .
s
t
C1
C2
s
t
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
C1
C2
x1
x2
x3
1. Any Hamiltonian Cycle in the constructed graph (G) traverses Pi either from right-to-left or left-to-right. This is because any path entering a node vi,j has to exit from vi,j+1 either immediately or via one clause-node in between, in order to maintain Hamiltonian property Similarly all paths entering at vi,j−1 has to exit from vi,j.
2. Since each path Pi can be traversed in 2 possible ways and we have n paths mapping to n variables, there can be 2n Hamiltonian cycles in the graph G - {C1, C2⋯Ck}. Each one of this 2n Hamiltonian cycles corresponds to a particular assignment for variables x1, x2⋯xn.
3. This graph can be constructed in polynomial time.
1. If there exists a Hamiltonian cycle H in the graph G, If H traverses Pi from left to right, assign xi=True If H traverses Pi from right to left, assign xi=False
Since H visits each clause node Cj, at least one of Pi was traversed in the right direction relative to the node Cj The assignment obtained here satisfies the given 3 CNF.
2. If there exists a satisfying assignment for the 3 CNF, Select the path that traverses Pi from left-to-right if xi=True or right-to-left if xi=False Include the clauses in the path wherever possible. Connect the source to P1, Pn to target and Pi to Pi+1 appropriately so as to maintain the continuity of the path Connect the target to source to complete the cycle
Since the assignment is such that every clause is satisfied, all the clause-nodes are included in the path. The Pi nodes and source and target are all included and since the path traverses unidirectional, no node is repeated twice The path obtained is a Hamiltonian Cycle