Given a set of cities and the distance between each pair of cities, the travelling salesman problem finds the path between these cities such that it is the shortest path and traverses every city once, returning back to the starting point.
Problem – Given a graph G(V, E), the problem is to determine if the graph has a TSP consisting of cost at most K.
In order to prove the Travelling Salesman Problem is NP-Hard, we will have to reduce a known NP-Hard problem to this problem. We will carry out a reduction from the Hamiltonian Cycle problem to the Travelling Salesman problem.
Every instance of the Hamiltonian Cycle problem consists of a graph G =(V, E) as the input can be converted to a Travelling Salesman problem consisting of graph G’ = (V’, E’) and the maximum cost, K. We will construct the graph G’ in the following way:
For all the edges e belonging to E, add the cost of edge c(e)=1. Connect the remaining edges, e’ belonging to E’, that are not present in the original graph G, each with a cost c(e’)= 2.
And, set .
The new graph G’ can be constructed in polynomial time by just converting G to a complete graph G’ and adding corresponding costs. This reduction can be proved by the following two claims:
- Let us assume that the graph G contains a Hamiltonian Cycle, traversing all the vertices V of the graph. Now, these vertices form a TSP with Since it uses all the edges of the original graph having cost c(e)=1. And, since it is a cycle, therefore, it returns back to the original vertex.
- We assume that the graph G’ contains a TSP with cost, . The TSP traverses all the vertices of the graph returning to the original vertex. Now since none of the vertices are excluded from the graph and the cost sums to n, therefore, necessarily it uses all the edges of the graph present in E, with cost 1, hence forming a hamiltonian cycle with the graph G.
Thus we can say that the graph G’ contains a TSP if graph G contains Hamiltonian Cycle. Therefore, any instance of the Travelling salesman problem can be reduced to an instance of the hamiltonian cycle problem. Thus, the TSP is NP-Hard.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Traveling Salesman Problem (TSP) Implementation
- Traveling Salesman Problem using Genetic Algorithm
- Difference between NP hard and NP complete problem
- Travelling Salesman Problem | Set 2 (Approximate using MST)
- Travelling Salesman Problem implementation using BackTracking
- Travelling Salesman Problem | Set 1 (Naive and Dynamic Programming)
- Proof that Clique Decision problem is NP-Complete
- Proof that Subgraph Isomorphism problem is NP-Complete
- Proof that Clique Decision problem is NP-Complete | Set 2
- Proof that Dominant Set of a Graph is NP-Complete
- Proof that Hamiltonian Path is NP-Complete
- Proof that vertex cover is NP complete
- Proof that Hamiltonian Cycle is NP-Complete
- Proof that Independent Set in Graph theory is NP Complete
- Job Sequencing Problem
- 2-Satisfiability (2-SAT) Problem
- Water Jug problem using BFS
- Water drop problem
- Level Ancestor Problem
- Extended Knapsack Problem
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.