How to fix the start and end points in Travelling Salesmen Problem?

前端 未结 2 988
轻奢々
轻奢々 2021-02-07 23:46

I have a solver that solves normal symmetric TSP problems. The solution means the shortest path via all the nodes with no restriction on which nodes are the first and the last o

2条回答
  •  醉酒成梦
    2021-02-08 00:09

    You can add a dummy node, which connects to start and end node with edges with weight 0. Since the TSP must contain the dummy node, the final result must contain the sequence start - dummy node - end (there is no other way to reach the dummy node). Therefore, you can get the shortest Hamilton path with specified start and end node. This solution should work even if the edges in the graph are negative.

提交回复
热议问题