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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Traveling Salesman Problem (TSP) Implementation
- Traveling Salesman Problem using Genetic Algorithm
- Travelling Salesman Problem | Set 1 (Naive and Dynamic Programming)
- Travelling Salesman Problem | Set 2 (Approximate using MST)
- Travelling Salesman Problem implementation using BackTracking
- Travelling Salesman Problem | Greedy Approach
- Difference between NP hard and NP complete problem
- Proof that Clique Decision problem is NP-Complete | Set 2
- Proof that Subgraph Isomorphism problem is NP-Complete
- Proof that Clique Decision problem 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
- Proof that Dominant Set of a Graph is NP-Complete
- Applications of Minimum Spanning Tree Problem
- Activity Selection Problem | Greedy Algo-1
- m Coloring Problem | Backtracking-5
- Ford-Fulkerson Algorithm for Maximum Flow Problem
- Stable Marriage 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 firstname.lastname@example.org. 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.