Cheapest cost traversal on Complete graph

亡梦爱人 提交于 2020-01-05 11:54:22

问题


I was wondering if there is an algorithm which: given a fully connected graph of n-nodes (with different weights)... will give me the cheapest cycle to go from node A (a start node) to all other nodes, and return to node A? Is there a way to alter an algorithm like Primm's to accomplish this?

Thanks for your help

EDIT: I forgot to mention I'm dealing with a undirected graph so the in-degree = out-degree for each vertex.


回答1:


Can you not modify Dijkstra, to find you the shortest path to all other nodes, and then when you have found it, the shortest path back to A?




回答2:


You can try the iterative deepening A star search algorithm. It is always optimal. You need to define a heuristic though and this will depend on the problem you are trying to solve.




回答3:


There need not be any such path. It exists if and only if the in-degree of every node equals its out-degree.

What you want is the cheapest Eulerian path. The problem of finding it is called the Traveling Salesman Problem. There is not, and cannot be, a fast algorithm to solve it.

Edit: On second thought: The Traveling Salesman Problem searches for a tour that visits every node exactly once. You're asking for a tour that visits every node at least once. Thus, your problem might just be in P. I doubt it, though.



来源:https://stackoverflow.com/questions/6944580/cheapest-cost-traversal-on-complete-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!