在Floyd-Warshall中添加带负重检查的周期

发布于 2025-02-10 06:57:39 字数 257 浏览 2 评论 0原文

这是用于最短路径检测的Floyd-Warshall算法的伪代码:

我想知道是否可以添加检查是否会测试是否没有负重的周期?

我认为这是可能的,但我不知道该如何检查。

This is the pseudo-code for the Floyd-Warshall algorithm for shortest paths detection:
enter image description here

I was wondering if it would be possible to add a check that will test if there are no cycles with negative weights?

I think it is possible, but I do not know how to check.

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

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

发布评论

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

评论(1

夏至、离别 2025-02-17 06:57:39

取图中所有负权重的总和。

当且仅当您找到低于该最小值的重量的路径时,您就会有一个负周期。

Take the sum of all negative weights in the graph.

You have a negative cycle if and only if you find a path to a weight that is below that minimum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文