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 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 O(|V||E|^2) is found by showing that each augmenting path can be found in O(|E|) time, that every time at least one of the 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 |V|. Another property of this algorithm is that the length of the shortest augmenting path increases monotonically. A proof outline using these properties is as follows: The proof first establishes that distance of the shortest path from the source node to any non-sink node in a residual flow network increases monotonically after each augmenting iteration (Lemma 1, proven below). Then, it shows that each of the |E| edges can be critical at most \frac{2} times for the duration of the algorithm, giving an upper-bound of O\left( \frac{2} \right) = O(|V||E|) augmenting iterations. Since each iteration takes O(|E|) time (bounded by the time for finding the shortest path using Breadth-First-Search), the total running time of Edmonds-Karp is O(|V||E|^2) as required. To prove Lemma 1, one can use
proof by contradiction by assuming that there is an augmenting iteration that causes the shortest path distance from to to
decrease. Let be the flow before such an augmentation and f' be the flow after. Denote the minimum distance in a residual flow network from nodes u, v as \delta_f (u, v). One can derive a contradiction by showing that \delta_f (s, v) \leq \delta _{f'} (s, v), meaning that the shortest path distance between source node and non-sink node did not in fact decrease. ==Pseudocode==