Edmonds–Karp algorithm: Difference between revisions

Content deleted Content added
Algorithm: I'll start filling in some details of the proof so that readers can make sense of the various properties mentioned here and why they are necessary.
Algorithm: giving an outline of the proof
Line 5:
 
==Algorithm==
The algorithm is identical to the [[Ford–Fulkerson algorithm]], except that the search order when finding the [[Flow network#Augmenting paths|augmenting path]] is defined. The path found must be a shortest path that has available capacity. This can be found by a [[breadth-first search]], where we apply a weight of 1 to each edge. The running time of <math>O(|V||E|^2)</math> is found by showing that each augmenting path can be found in <math>O(|E|)</math> time, that every time at least one of the <math>E</math> edges becomes saturated (an edge which has the maximum possible flow), that the distance from the saturated edge to the source along the augmenting path must be longer than last time it was saturated, and that the length is at most <math>|V|</math>. Another property of this algorithm is that the length of the shortest augmenting path increases monotonically. <ref>{{citeA bookproof |author=[[Thomasoutline H.using Cormen]],these [[Charlesproperties E.is Leiserson]],as [[Ronald L. Rivest]] and [[Clifford Stein]] |title=Introduction to Algorithms |publisher=MIT Press | year = 2009 |isbn=978-0-262-03384-8 |edition=third |chapter=26.2 |pages=727–730 |title-link=Introduction to Algorithms }}</ref>follows:
 
The proof first establishes that distance of the shortest path from the source node <math>s</math> to any non-sink node <math>v</math> in a residual flow network increases monotoically after each augmenting iteration. Then, it shows that the each of the <math>|E|</math> edges can be critical at most <math>\frac{|V|}{2}</math> times for the duration of the algorithm, giving an upper-bound of <math>O( \frac{|V||E|}{2} ) \in O(|V||E|)</math> augmenting iterations. Since each iteration takes O(|E|) time (finding the shortest path using Breadth-First-Search), the total running time of Edmonds-Karp is <math>O(|V||E|^2)</math> as required. <ref>{{cite book |author=[[Thomas H. Cormen]], [[Charles E. Leiserson]], [[Ronald L. Rivest]] and [[Clifford Stein]] |title=Introduction to Algorithms |publisher=MIT Press | year = 2009 |isbn=978-0-262-03384-8 |edition=third |chapter=26.2 |pages=727–730 |title-link=Introduction to Algorithms }}</ref>
 
==Pseudocode==