开发者

Cheapest cost traversal on Complete graph

I was wondering if there is an algorithm which: given a fully connected graph of n-nodes (with different weigh开发者_StackOverflow社区ts)... 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.


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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜