有向图中的 Prims 和 Bellman-Ford 算法
请推荐资源来学习如何使用 Prim 算法在有向图中查找最小生成树,以及如何使用 Bellman-Ford 算法计算有向图中的最短路径。
Please suggest resources to learn how to find a minimal spanning tree in a directed graph using Prim's algorithm, as well as Bellman-Ford algorithm to calculate the shortest path in a directed graph.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从有向图中查找 MST 是一个不同的问题,您不能简单地采用 Prim 的方法。您应该使用Edmond 算法。
Bellman Ford 已经可以处理有向图了。无需改变任何东西。
提供的链接应该可以帮助您入门。如有必要,请谷歌获取更多资源。
Finding an MST from a directed graph is a different problem, for which you cannot simply adapt Prim's. You should instead use Edmond's algorithm.
Bellman Ford already works on directed graphs. No need to alter anything.
The links provided should get you started. Google for additional resources if necessary.
如果您想要一些算法的实际代码,我最近对这两种算法进行了编码。
这些文件顶部的注释包含从正确性和运行时角度对两种算法的分析,以及我希望他们能够阐明他们的工作方式。
If you'd like some actual code for the algorithms, I recently coded both of these algorithms up.
The comments at the top of these files contains an analysis of the two algorithms both from a correctness and runtime perspective, and I hope they can shed some light on how they work.
alsuwaiyel 教科书在 Google 图书上非常好,并且提供了该书的大部分内容。
The alsuwaiyel textbook on Google Books is very good and has most of the book available.