Edmonds-Karp Algorithm for a graph which has nodes with flow capacities

后端 未结 1 1853
旧巷少年郎
旧巷少年郎 2021-02-06 08:48

I am implementing this algorithm for a directed graph. But the interesting thing about this graph nodes have also their own flow capacities. I think, this subtle change of the o

1条回答
  •  借酒劲吻你
    2021-02-06 09:19

    There's a simple reduction from the max-flow problem with node capacities to a regular max-flow problem:

    For every vertex v in your graph, replace with two vertices v_in and v_out. Every incoming edge to v should point to v_in and every outgoing edge from v should point from v_out. Then create one additional edge from v_in to v_out with capacity c_v, the capacity of vertex v.

    So you just run Edmunds-Karp on the transformed graph.

    So let's say you have the following graph in your problem (vertex v has capacity 2):

    s --> v --> t
       1  2  1
    

    This would correspond to this graph in the max-flow problem:

    s --> v_in --> v_out --> t
       1        2         1
    

    It should be apparent that the max-flow obtained is the solution (and it's not particularly difficult to prove either).

    0 讨论(0)
提交回复
热议问题