Ford-Fulkerson algorithm with “weighted” edges

纵然是瞬间 提交于 2019-12-04 11:22:39

There are two common generalisations that I know of to add weights.

Min cost flow

Suppose you had a weight for each edge and wanted to compute the flow that satisfied the constraints and had minimum cost. (Cost = sum of weight * units flowing along associated edge)

This problem is called minimum cost flow.

An implementation can be found in networkx called min-cost-flow.

Here is a good topcoder tutorial on a primal-dual approach.

My favorite algorithm for this was actually invented by Fulkerson himself in 1961 and is called the out of kilter algorithm.

Max flow min cost

Suppose you definitely wanted the maximum flow, but wanted to choose the flow with least weight.

This differs from the first interpretation, in that a min-cost-flow may not give the maximum possible flow. For example, suppose we have a single edge start->end with the constraint that the flow is in the range 0 to 1, and a weight of 1.

The min-cost-flow will be a flow of 0, while the max-flow-min-cost will have a flow of 1.

An implementation for this can be found in networkx called max_flow_min_cost.

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