NP-completeness proofs (2): Hamiltonian path, cycle, and Travelling Salesman Problem
This post gives you the proofs of three classical NP-complete problems—Hamiltonian path, Hamiltonian cycle, and Travelling Salesman Problem (TSP).
Note. The Hamiltonian cycle problem is a special case of TSP, where distance between two cities are set to 0 if they are adjacent and 1 otherwise, and the total distance are bounded by . These two problems are way too close in this regard. Therefore, if you want to prove the NP-completeness of TSP on an exam, I recommend reducing from the Hamiltonian path problem (or using a two-step proof by TSP ≥ HC ≥ HP) to ensure full grades.
Definitions
Definitions.
Hamiltonian cycle decision problem: Given a graph , does there exist a cycle that visits each vertex exactly once?
Hamiltonian path decision problem: Given a graph , does there exist a path that visits each vertex exactly once?
Travelling Salesman decision problem: Given a list of cities and the distances between each pair of cities, does there exist a route of length at most that visits each city exactly once and returns to the origin city?
Proofs
P1: Hamiltonian cycle
Proof by reduction from Hamiltonian path.
Certificate: Verifying the cycle visits all vertices, costing , which is in polytime. Thus the problem is NP.
Reduction: Construct a new graph by create a new vertex that connects all vertices in . If we can find a Hamiltonian cycle in , it gives us a Hamiltonian path in .

Construction from iterating all vertices costs , which is in polytime. In conclusion, the Hamiltonian cycle problem is NP-complete.
P2: Hamiltonian path
Proof by reduction from Hamiltonian cycle.
Certificate: Verifying the path visits all vertices, costing , which is in polytime. Thus the problem is NP.
Reduction: Let be a vertex in . Create a new vertex that mirrors all edges connected to . Create a new vertex that connects , and a new vertex that connects .

If a given algorithm finds a Hamiltonian path in the new graph , it must start with and ends with since both only have 1 degree. Then the original must have a Hamiltonian cycle that starts and ends with .
By iterating through all possible , this construction can use the solution of Hamiltonian path to deduce Hamiltonian cycle.
The construction is at most if all edges are directly connected to . Iterating all possible breakpoints would make the total reduction , which is still in polytime. In conclusion, the Hamiltonian path decision problem is NP-complete.
P3: Travelling Salesman Problem
Proof by reduction from Hamiltonian cycle.
Certificate: Verifying the route visits all cities, costing , which is in polytime. Thus the problem is NP.
Reduction: Given a graph in Hamiltonian cycle problem, we can construct a new graph in TSP, where . The distances between cities is then defined as
Given an algorithm to find a solution of TSP with , we can directly get the solution to the Hamiltonian cycle.
Construction of costs for iteration of all vertex pairs, which is in polytime. In conclusion, the TSP is NP-complete.