Content deleted Content added
Balloonguy (talk | contribs) m Updating reference styles with Ref converter |
m ISBN formatting &/or general fixes using AWB |
||
Line 3:
==Algorithm==
The algorithm is identical to the [[Ford-Fulkerson algorithm]], except that the search order when finding the augmenting path is defined. The path found must be the shortest path which has available capacity. This can be found by a [[breadth-first search]], as we let edges have unit length. The running time of <math>O(V^2 E)</math> is found by showing that the length of the augmenting path found never decreases, that for every time one of the <math>E</math> edge becomes saturated the augmenting path must be longer than last time it was saturated, that a path is at most <math>V</math> long, and can be found in <math>O(E)</math> time. There is an accessible proof in <ref>{{cite book | author = [[Thomas H. Cormen]], [[Charles E. Leiserson]], [[Ronald L. Rivest]] and [[Clifford Stein]] | title = [[Introduction to Algorithms]] | publisher = MIT Press and McGraw-Hill | year = 2001 | id = ISBN
==Sample implementation==
Line 11:
'''def''' edmonds_karp(C, source, sink):
n = len(C) ''# C is the capacity matrix''
F = [[0]] * n '''for''' i '''in''' xrange(n)]
''# residual capacity from u to v is C[u][v] - F[u][v]''
Line 98:
</table>
Notice how the length of the [[augmenting path]] found by the algorithm never decreases. The paths found are the shortest possible. The flow found is equal to the capacity across the [[
==References==
|