简体   繁体   English

给定无向加权连通图,s,t。 找到从s到t的路径,其最大加权边缘尽可能低

[英]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: 我尝试过的:

  1. Use some algorithm to find the shortest path between s and t. 使用一些算法来找到s和t之间的最短路径。
  2. Delete all the edges that are not part of the shortest paths we've found 删除不属于我们找到的最短路径的所有边
  3. Use BFS with some modification, We run BFS depending on the number of paths from s to t. 使用BFS进行一些修改,我们根据从s到t的路径数运行BFS。 Every time we find a maximum edge and store it in an array, then we find the minimum of the array. 每当我们找到最大边并将其存储在数组中时,我们就会找到数组的最小值。

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的路径将是具有最小可能最大权重的路径

  1. find the most negative edge in the graph 找到图中最负的边缘
  2. add that (weight+1) to every edge. 将(重量+ 1)添加到每个边缘。
  3. Now all edge are positive so you can apply Dijkstra's algorithm 现在所有边缘都是正面的,因此您可以应用Dijkstra的算法
  4. you can get the shortest_path between source and destination 你可以得到源和目的地之间的最短路径
  5. Now count the number of edges between source and destination (say x) 现在计算源和目标之间的边数(比如x)
  6. Real shortest path will be: shortest_path - x * (weight+1) 真正的最短路径是:shortest_path - x *(weight + 1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 给定有一个负边(u,v)的有向加权图,找到最短路径(s,t) - Given directed weighted graph that has one negeative edge (u,v), find shortest path (s,t) 给定一个加权图和自然数 k,如何找到可以除以 k 的从节点 s 到 t 的最便宜的路径? - Given a weighted graph and natural number k how to find the cheapest path from node s to t that can be divided by k? 如果向无向加权图 G 添加新边,则查找 MST T 是否仍然是新图 G' 的 MST - Find if MST T is still a MST for new graph G' if a new edge is added to undirected weighted graph G 加权无向图上的最长路径 - Longest path on weighted undirected graph 给定加权无向图,如何找到总权重接近给定值的路径? - Given a weighted undirected graph, how do I find a path which has the total weights close to a given value? 对于通过实加权无向图的单对最短路径,最简单的算法/解决方案是什么? - What's the simplest algorithm/solution for a single pair shortest path through a real-weighted undirected graph? 在 O(V + E) 时间内在加权无向图中找到从源到目标的最短路径 - Find the shortest path from source to target in a weighted-undirected graph in O(V + E) time 如何在加权无向图中找到包含两个给定节点的最小加权循环? - How to find the minimum weighted cycle containing two given nodes in a weighted undirected graph? 无向图的最小加权路径树 - Minimum Weighted Path Tree of an Undirected Graph 无向加权图中2个顶点之间的最短路径 - shortest path between 2 vertices in undirected weighted graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM