[英]Given undirected weighted connected graph, s,t. Find path from s to t that its most weighted edge is low as possible
Given: undirected weighted connected graph. 给定:无向加权连通图。 s,t are vertices. s,t是顶点。
Question: Find an algorithm as efficient as possible that returns a path from s to t. 问题:找到一个尽可能高效的算法,它返回从s到t的路径。 In that path, the edge that has the highest weight, will has the least weight as possible. 在该路径中,具有最高重量的边缘将具有尽可能最小的重量。 So if we have 5 paths from s,t and for every path we have the heaviest edge, so the minimum edge of these 5. 因此,如果我们有来自s,t的5条路径,并且对于每条路径,我们都有最重的边缘,所以这些路径的最小边缘为5。
What I've tried: 我尝试过的:
I'm struggling to find an algorithm that can be ran in (1), Bellman ford won't work - because it has to be directed graph. 我很难找到一个可以在(1)中运行的算法,Bellman ford将不起作用 - 因为它必须是有向图。 Dijkstra won't work because we don't know if it has negative circles or negative edges. Dijkstra不会工作,因为我们不知道它是否有负圆或负边。 And Prim is for finding MST which I'm not aware of how it can help us in finding the shortest path. Prim用于寻找MST,我不知道它如何帮助我们找到最短的路径。 Any ideas? 有任何想法吗?
And other from that, If you have an algorithm in mind that can solve this question, would be much appreciated. 除此之外,如果你有一个可以解决这个问题的算法,我将不胜感激。
You can solve this with Kruskal's algorithm . 你可以用Kruskal算法解决这个问题。 Add edges as usual and stop as soon as s and t are in the same cluster. 像往常一样添加边缘,并在s和t位于同一群集中时立即停止。
The idea is that at each stage of the algorithm we have effectively added all edges below a certain weight threshold. 我们的想法是,在算法的每个阶段,我们都有效地将所有边缘添加到特定权重阈值以下。 Therefore, if s and t are in the same cluster then there is a route between them consisting entirely of edges with weight less than the threshold. 因此,如果s和t在同一簇中,则它们之间存在一条完全由重量小于阈值的边组成的路径。
您可以通过转换为MST问题来解决它,基本上MST中从s到t的路径将是具有最小可能最大权重的路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.