Lect4 2
Lect4 2
Edmonds-Karp Algorithm
Edmonds-Karp Algorithm
4
2 5
3 1 1 1
2 2
s 4 t
3 2
1
3
This is the original network.
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 2
s 4 t
3 2
1
4
2 5
3 1 1 1
2 2
s 4 t
3 2
1
3
This is residual graph after
the 1st augmentation.
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 2
s 4 t
3 2
1
3
Choose a shortest path from
s to t.
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 2
s 4 t
1
1 2
2
3
The residual graph after the
2nd augmentation.
Ford-Fulkerson Max Flow
4
2 5
3 1 1 1
2 2
s 4 t
1
1 2
2
3
Choose a shortest path from
s to t.
Ford-Fulkerson Max Flow
3
2 5
1
2 1 1
1 1
2 2
s 4 t
1
1 2
2
3
The residual graph after the
3rd augmentation.
Let f ( s, x) the shortest path distance from s to x in the residual
network G f , where each edge has unit distance.
Lemma
When Edmonds - Karp algorithm runs, f ( s, x) increases
monotonically with each flow augmentation.
Proof Denote f ( x) f ( s, x).
For contradiction, suppose flow f ' is obtained from flow f
through an augmentation and f ' (v) f (v) for some node v.
W.l.g., assume f ' (v) is the smallest among such v, i.e.,
f ' (u ) f ' (v) f ' (u ) f (u ).
Suppose (u, v ) is on the shortest path from s to v in G f ' .
Case 1. (u , v) G f .
f (v) f (u ) 1 f ' (u ) 1 f ' (v), ().
Case 2. (u , v) G f . Then (v, u ) must be on augmenting path in G f .
f (v) f (u ) 1 f ' (u ) 1 f ' (v) 2 f ' (v), ().
u v
s in G f '
u v
s in G f
(u , v) is critical in G f if (u , v) has the smallest capacity in
augmenting path p in G f .
Lemma
Each (u , v) can be critical at most (n 1) / 2 times.
Proof
Suppose (u , v) is critical in G f . Then (u, v) will dispear in next
residual graph. Before (u , v) appears again, (v, u ) has to appear
in augmenting path of a residual graph G f ' . Thus, we have
f ' (u ) f ' (v) 1.
Since f (v) f ' (v), we have
f ' (u ) f ' (v) 1 f (v) 1 f (u ) 2.
Theorem
Edmonds - Karp algorithm runs in time O(| V | | E |2 ).
Proof
In every augmentati on, there exists an arc critical.
Since each arc can be critical at most (n 1) / 2 times,
there are at most O (| V | | E |) augmentati ons.
In each augmentati on, finding the shortest path
takes O (| E |) time.
Matching in Bipartite Graph
Maximum Matching
Given a bipartite graph G (V , E ), find a matching with
maximum cardinality.
1
1
Note: Every edge has capacity 1.
1. Can we do augmentation directly
in bipartite graph?