Non-cycle path to all nodes

前端 未结 2 497
有刺的猬
有刺的猬 2021-01-12 23:31

Is there an algorithm or set of algorithms that would let you find the shortest walking distance from an arbitrary start node so that every node gets visited in a weight, un

相关标签:
2条回答
  • 2021-01-12 23:40

    From Wikipedia's article on Travelling Salesman Problem:

    Removing the condition of visiting each city "only once" does not remove the NP-hardness, since it is easily seen that in the planar case there is an optimal tour that visits each city only once (otherwise, by the triangle inequality, a shortcut that skips a repeated visit would not increase the tour length).

    0 讨论(0)
  • 2021-01-12 23:48

    Not sure what the etiquette is to add an answer to a question with an already accepted answer.

    I am adding this answer just for the sake of not having to jump to another page, to not have to deal with planar graphs and triangle inequality and the fact that this is simple and probably easier to understand.

    Hamiltonian Path problem can be reduced to this:

    Suppose we had a polynomial time algorithm to solve our problem of finding a least weight walk which visits all vertices.

    Given a graph of which we need to decide a hamiltonian path exists or not, we just feed it as it is, to the problem algorithm at hand, setting edge weights = 1. If the algorithm returns a value > n-1, then there is no hamiltonian path in the original graph, else there is.

    So this problem is NP-Hard.

    0 讨论(0)
提交回复
热议问题