Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is TSP NP-hard while the Hamiltonian path NP-complete?

Why aren't these 2 problems, namely TSP and Hamiltonian path problem, both NP-complete?

They seem identical.

like image 656
User Avatar asked Jul 28 '16 20:07

User


People also ask

Why is TSP NP-hard?

In fact, TSP belongs to the class of combinatorial optimization problems known as NP-complete. This means that TSP is classified as NP-hard because it has no “quick” solution and the complexity of calculating the best route will increase when you add more destinations to the problem.

Is TSP NP-hard or Complete?

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.

What is the difference between TSP and Hamiltonian cycle?

The Hamiltonian Cycle Problem (HCP) and Travelling Salesman Problem (TSP) are long-standing and well-known NP-hard problems. The HCP is concerned with finding paths through a given graph such that those paths visit each node exactly once after the start, and end where they began (i.e., Hamiltonian cycles).

Is Hamilton Cycle & traveling salesman problem NP-Complete?

The edges it uses are from E (given the cost function we created), hence we can say for sure that there is a Hamiltonian Cycle in G. Given that Hamiltonian Cycle is NP-Complete, the decision version of TSP is NP-Complete, hence TSP is NP-Hard.


2 Answers

For a problem X to be NP-complete, it has to satisfy:

  1. X is in NP, given a solution to X, the solution can be verified in polynomial time.
  2. X is in NP-hard, that is, every NP problem is reduceable to it in polynomial time (you can do this through a reduction from a known NP-hard problem (e.g. Hamiltonian Path)).

There are two versions of the The Travelling Salesman Problem (TSP):

  1. The optimization version (probably the one you are looking at), namely, find the optimum solution to the TSP. This is not a decision problem, and hence cannot be in NP, but it is however in NP-hard which can be proven via a Hamiltonian Path reduction. Therefore this isn't an NP complete problem.
  2. The decision version - given an integer K is there a path through every vertex in the graph of length < K? This is a decision (yes/no) problem, and a solution can be verified in polynomial time (just traverse the path and see if it touches every vertex) and so it is in NP, but it is also in NP-hard (by an identical proof as above). Since it satisfies both requirements for NP-completeness, it is an NP-complete problem.
like image 67
ifma Avatar answered Sep 29 '22 23:09

ifma


The definitions of NP-hardness and NP-completeness are related but different. Specifically, a problem is NP-hard if every problem in NP reduces to it in polynomial time, and a problem is NP-complete if it's both NP-hard and itself in NP.

The class NP consists of decision problems, problems that have a yes/no answer. As a result, TSP cannot be in NP because the expected answer is a number rather than yes or no. Therefore, TSP can be NP-hard, but it can't be NP-complete.

On the other hand, the Hamiltonian path problem asks for a yes/no answer, and it happens to be in NP. Therefore, since it's NP-hard as well, it's NP-complete.

Now, you can take TSP and convert it to a decision problem by changing the question from "what's the cheapest path?" to "is there a path that costs X or less?," and that latter formulation is in NP and also happens to be NP-complete.

like image 37
templatetypedef Avatar answered Sep 29 '22 23:09

templatetypedef