Missing some paths in edmonds karp max flow algorithm

与世无争的帅哥 提交于 2019-12-04 15:22:13

The way to choose paths is not important.

You have to add edges of the path in reverse order with path capacity and reduce capacity of edges of the path by that value.

In fact this solution works:

while there is a path with positive capacity from source to sink{
    find any path with positive capacity from source to sink, named P with capacity C.
    add C to maximum_flow_value.
    reduce C from capacity of edges of P.
    add C to capacity of edges of reverse_P.
}

Finally the value of maximum-flow is sum of Cs in the loop.

If you want to see the flow in edges in the maximum-flow you made, you can retain the initial graph somewhere, the flow in edge e would be original_capacity_e - current_capacity_e.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!