首页 > 其他 > 详细

The Bell-Ford algorithm

时间:2014-04-14 14:31:41      阅读:451      评论:0      收藏:0      [点我收藏+]

bubuko.com,布布扣

This algorithm deals with the general case, where G is a directed, weight graph, and it can contains negative edge weigths, cycles and even negative-weight cycles. It runs in O(VE) time, which means O(V^3) when the graph is dense. 

This algorithm detects cycles by checking "v.d > u.d + w(u, v)", this is viable because if there are no negative-weight cycles,  and there is an edge which satisfies "v.d > u.d + w(u, v)", v.d would be replaced by u.d + w(u, v) which is exactly what Relax(u,v, w) does. Thus at the time of checking all edges would satisfiy "v.d <= u.d + w(u, v)". Consider the Relax(u,v,w) procedure as "If there are still space for optimizing, then optimize it." 

If there are negative-weight cycles, we can consider this as there are infinite optimizing space which can never be fulled exploited. So there will always be some edge whose shortest distance can still be optimized after the "enough" Relax process.

The Bell-Ford algorithm,布布扣,bubuko.com

The Bell-Ford algorithm

原文:http://www.cnblogs.com/Antech/p/3663176.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!