The following slideshow shows that an instance of Hamiltonian Cycle
problem can be reduced to an instance of Traveling Salesman problem in
polynomial time.
This slideshow shows how to reduce an input instance to HAMILTONIAN CYCLE to an equivalent instance of TSP in polynomial time
For a given graph $G = ( V , E )$ , the HAMILTONIAN CYCLE problem is to find whether $G$ contains a Hamiltonian Cycle that is, a cycle that passes through all the vertices of the graph exactly once.
For a given weighted graph $G' = ( V' , E' )$, with non-negative weights, and integer $k'$, the TRAVELING SALESMAN problem is to find whether $G'$ contains a simple cycle of length $\leq k$ that passes through all the vertices. [The length of a cycle is the sum of weights of all the edges in the cycle.]
To reduce HAMILTONIAN CYCLE to TSP for a given graph $G = (V , E)$, first complete $G$ by adding edges between all pairs of vertices that were not connected in $G$.
Let the new graph be $G'=(V',E')$ where $V' = V$ and $E' = \{(u,v)\}$ for any $u, v \in V'$.
For edges in $G'$ that were also present in $G$ , we assign a weight of $0$. For the new edges we assign weight $1$
That is , $\forall e=(u,v) \in E'$, $ W(e) = 0$, if $(u,v) \in E$. $W(e) = 1$, if $(u,v) \not\in E$.
Construction of the complimentary graph can be done in polynomial time.
A
B
C
D
E
F
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
Let graph $G$ be an input to HAMILTONIAN CYCLE.
The constructed graph $G'$ is as below. The blue edges were not present in $G$ and so have weight of 1.
The graph $G$ has a Hamiltonian Cycle if and only if there exists a cycle in $G'$ passing through all vertices exactly once, and that has a length $= 0$ (i.e., has a solution for the instance of TRAVELING SALESMAN where $k = 0$.
1. If there is a cycle that passes through all vertice exactly once, and has length $= 0$ in $G'$, the cycle contains only edges that were originally present in graph $G$. (The new edges in $G'$ have weight $1$ and hence cannot be part of a cycle of length $= 0$.) Hence there exists a Hamiltonian cycle in $G$.
2. If there exists a Hamiltonian Cycle in $G$, it forms a cycle in $G'$ with length $= 0$, since the weights of all the edges is $0$. Hence there exists a solution for TRAVELING SALESMAN in $G'$ with length $= 0$.
$G'$ has a cycle passing through all vertices exactly once with length $= 0$.