0% found this document useful (0 votes)
19 views2 pages

Edmonds-Karp Algorithm Analysis: January 20, 2017

The Edmonds-Karp algorithm finds the maximum flow in a flow network. It is similar to the Ford-Fulkerson algorithm but chooses the shortest augmenting path at each step. [1] The algorithm runs in O(m^2n) time where n is the number of vertices and m is the number of edges. [2] This bound comes from showing the number of phases is O(n) and each phase contains O(m) iterations. [3]

Uploaded by

Victor Purice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
19 views2 pages

Edmonds-Karp Algorithm Analysis: January 20, 2017

The Edmonds-Karp algorithm finds the maximum flow in a flow network. It is similar to the Ford-Fulkerson algorithm but chooses the shortest augmenting path at each step. [1] The algorithm runs in O(m^2n) time where n is the number of vertices and m is the number of edges. [2] This bound comes from showing the number of phases is O(n) and each phase contains O(m) iterations. [3]

Uploaded by

Victor Purice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Edmonds-Karp Algorithm Analysis

January 20, 2017

The algorithm is defined exactly like the Ford-Fulkerson algorithm, except for one change: in every
iteration, among all simple s-t paths in the residual graph Gf , we choose the shortest one (the one
with fewest edges) as the augmenting path P . The correctness proof of Ford-Fulkerson algorithm
carries over to this version. We only need to analyze the running time.
It is easy to verify that each iteration takes time O(m) - this includes computing the residual graph,
finding the shortest s-t path via BFS, and updating the flow. It now remains to bound the number of
iterations.
We break the algorithm’s execution into phases. Each phase lasts as long as the length of the augment-
ing path stays the same. For instance, if the lengths of augmenting paths throughout the algorithm
were 2, 2, 3, 3, 3, 3, 2, 4, 4, 5, 5, 4 we would have 6 phases. The first phase comprises the first 2 iterations;
the second phase - the next 4 iterations, the third phase a single iteration, and so on. The key to
bounding the number of iterations is the following two claims.
Claim 1 The length of the augmenting path P does not decrease from iteration to iteration.

(in particular the sequence we showed above cannot arise because there the length of the augmenting
path decreases sometimes).
Claim 2 Every phases lasts O(m) iterations.

The first claim implies that the number of phases is at most n, and the second one implies that each
phase contains O(m) iterations. We then obtain a bound of O(mn) on the total number of iterations,
and a bound of O(m2 n) on the running time of the algorithm. Before we prove the two claims, we
make the following observation (its proof will be a part of homework).
Observation 3 Consider some flow network G; let f be any flow in G, let Gf be its corresponding
residual network, and let P an augmentation path in Gf . Suppose we run one iteration of the algorithm,
where we augment the flow along P , to obtain a new flow f 0 , and the corresponding residual network
Gf 0 . Then:

• If e ∈ E(Gf ) but e 6∈ E(Gf 0 ), then e is an edge of P ;

• At least one edge of P does not belong to Gf 0 ; and

• If e = (u, v) ∈ E(Gf 0 ), but e 6∈ E(Gf ), then (v, u) is an edge of P .

We are now ready to prove Claims 1 and 2.


Proof of Claim 1.

1
Consider an iteration of the algorithm, where we start from some flow f , compute the residual network
Gf , and choose an augmenting path P of length d in Gf . We build a layered BFS graph, where the
first layer contains only the vertex s. If Li denotes all vertices in layer i, then Li+1 contains all vertices
v, such that (i) v 6∈ L1 ∪ · · · ∪ Li ; and (ii) there is a vertex u ∈ Li with (u, v) ∈ E(Gf ). Notice that
vertex t lies in layer Ld+1 .
We can now partition the edges of Gf into three types. Let e = (u, v) be an edge of Gf . Assume that
u ∈ Li , v ∈ Lj Then:

• e is forward-looking if i < j. Notice that in this case j = i + 1 must hold;

• e is sideways-looking if i = j;

• otherwise, i > j, and e is backward-looking.

We say that e is a shortcut edge iff j > i + 1. As observed above, no shortcut edges exist in Gf .
Since path P contains d edges, it must visit each of the d + 1 layers in turn, and all edges on P
must be forward-looking edges. Once we augment the flow and compute the new residual graph, from
Observation 3, we may delete some edges of P , and introduce some backward-looking edges, but we
will not introduce any shortcut edges. This means that in the new residual network Gf 0 , in order to go
from s to t, we still need to visit vertices in each set L1 , L2 , . . . , Ld+1 in turn, and so the augmenting
path length cannot decrease. 

Proof of Claim 2. We consider the residual graph Gf at the beginning of the phase. We build a
layered BFS graph exactly as in the proof of Claim 1, and use the same classification of the edges. We
assume that all augmenting paths in the current phase have length d, so vertex t lies in layer Ld+1 .
Throughout the phase, the residual graph will change, but we will not change the partition of the
vertices into layers.
We claim that throughout the phase, the only edges added to the residual graph are backward-looking
edges, and at least one forward-looking edge is deleted in each iteration.
The proof of this claim is done by induction on the number of iterations. The claim is clearly true
before the phase starts.
Assume that the claim was still true before the beginning of the current iteration. Let P be a length-d
augmenting path in the current residual graph, that is used in the current iteration. The only way
for the path to have length d is to visit every layer L1 , L2 , . . . , Ld+1 in turn (as there are no shortcut
edges), and only use forward-looking edges (because the path length is d, so we cannot afford to go
backward or sideways). Since P only uses forward-looking edges, from Observation 3 we may only
create backward-looking edges, and at least one forward-looking edge must disappear. So the claim
remains true after the end of the current iteration.
Since at least one forward-looking edge is deleted in every iteration of the phase, and no new forward-
looking edges are created, the phase may last at most O(m) iterations. 

You might also like