计算对向环上的发散路径

发布于 2024-09-01 06:13:28 字数 357 浏览 4 评论 0原文

我需要计算下图中从 A 到 B 的两条路径,限制路径不能共享任何边:

嗯,好吧,不能发布图像,这里有一个 链接

所有边都有正权重;对于这个例子,我认为我们可以假设它们是相等的。我的简单方法是使用 Djikstra 算法来计算第一条路径,如上图中的第二张图所示。

然后我从图中删除边缘并尝试计算第二条路径,但失败了。是否有 Djikstra、Bellman-Ford(或其他)的变体可以计算上面第三张图中所示的路径? (没有特殊知识并删除对向链接,这就是我的意思)

I need to calculate two paths from A to B in the following graph, with the constraint that the paths can't share any edges:

hmm, okay, can't post images, here's a link.

All edges have positive weights; for this example I think we can assume that they're equal. My naive approach is to use Djikstra's algorithm to calculate the first path, shown in the second graph in the above image.

Then I remove the edges from the graph and try to calculate the second path, which fails. Is there a variation of Djikstra, Bellman-Ford (or anything else) that will calculate the paths shown in the third diagram above? (Without special knowledge and removal of the subtending link, is what I mean)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-09-08 06:13:28

您正在寻找的是边不相交的路径。门格尔定理将为您提供边不相交路径的最大数量。要找到最短对,请查看边不相交最短对算法

  1. 对给定的顶点对运行最短对算法
  2. 将最短路径的每条边(相当于两个方向相反的弧)替换为指向源顶点的单条弧
  3. 将上述每条弧的长度设为负值
  4. 运行最短路径算法(注意:该算法应接受负成本)
  5. 擦除找到的两条路径的重叠边,并反转第一条最短路径上剩余弧的方向,使其上的每个弧现在都指向汇点顶点。生成所需的路径对。

What you are looking for is edge-disjoint paths. Menger's Theorem will give you the maximum number of edge-disjoint paths. To find the shortest pair, take a look at the Edge disjoint shortest pair algorithm:

  1. Run the shortest pair algorithm for the given pair of vertices
  2. Replace each edge of the shortest path (equivalent to two oppositely directed arcs) by a single arc directed towards the source vertex
  3. Make the length of each of the above arcs negative
  4. Run the shortest path algorithm (Note: the algorithm should accept negative costs)
  5. Erase the overlapping edges of the two paths found, and reverse the direction of the remaining arcs on the first shortest path such that each arc on it is directed towards the sink vertex now. The desired pair of paths results.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文