[英]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? 为什么这两个问题,即TSP和哈密顿路径问题都不是NP完全?
They seem identical. 它们似乎相同。
For a problem X to be NP-complete , it has to satisfy: 对于问题X是NP完全的 ,它必须满足:
There are two versions of the The Travelling Salesman Problem (TSP) : 旅行商问题(TSP)有两个版本:
The definitions of NP-hardness and NP-completeness are related but different. NP-硬度和NP-完整性的定义是相关的但不同。 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.
具体来说,如果NP中的每个问题在多项式时间内都减少,那么问题就是NP难,如果它既是NP难的又是NP本身的问题就是NP完全问题。
The class NP consists of decision problems, problems that have a yes/no answer. NP类由决策问题,有/无答案的问题组成。 As a result, TSP cannot be in NP because the expected answer is a number rather than yes or no.
因此,TSP不能在NP中,因为预期的答案是数字而不是是或否。 Therefore, TSP can be NP-hard, but it can't be NP-complete.
因此,TSP可以是NP难的,但它不能是NP完全的。
On the other hand, the Hamiltonian path problem asks for a yes/no answer, and it happens to be in NP. 另一方面,汉密尔顿路径问题要求是/否答案,它恰好在NP中。 Therefore, since it's NP-hard as well, it's NP-complete.
因此,既然它也是NP难的,它就是NP完全的。
Now, you can take TSP and convert it to a decision problem by changing the question from "what's the cheapest path?" 现在,您可以通过更改“最便宜的路径是什么?”中的问题来将TSP转换为决策问题。 to "is there a path that costs X or less?," and that latter formulation is in NP and also happens to be NP-complete.
“是否存在成本为X或更低的路径?”,后一种配方在NP中也恰好是NP完全的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.