0% found this document useful (0 votes)
15 views30 pages

Lect4 2

The Edmonds-Karp algorithm finds the maximum flow in a flow network by performing augmenting path searches on the residual graph. It repeatedly finds the shortest augmenting path from the source to the sink and increments the flow along this path until no more augmenting paths exist. Each iteration takes O(E) time and there can be at most O(V*E) iterations since each edge can be critical at most (V+1)/2 times, so the overall runtime is O(V*E^2). The algorithm can also be applied to find a maximum matching in bipartite graphs by treating the edges as a flow network with unit capacities.

Uploaded by

nada abdelrahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views30 pages

Lect4 2

The Edmonds-Karp algorithm finds the maximum flow in a flow network by performing augmenting path searches on the residual graph. It repeatedly finds the shortest augmenting path from the source to the sink and increments the flow along this path until no more augmenting paths exist. Each iteration takes O(E) time and there can be at most O(V*E) iterations since each edge can be critical at most (V+1)/2 times, so the overall runtime is O(V*E^2). The algorithm can also be applied to find a maximum matching in bipartite graphs by treating the edges as a flow network with unit capacities.

Uploaded by

nada abdelrahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

Lecture 14

Edmonds-Karp Algorithm
Edmonds-Karp Algorithm

The augmenting path is a shortest path from s to t in the


residual graph (here, we count the number of edges for
the shortest path).
Ford-Fulkerson Max Flow

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

Choose a shortest path from


s to t.
Ford-Fulkerson Max Flow

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

Given a bipartite graph G  (V ,U , E ), a matching is a subset


of edges in which any two edges have no endpoint in
common.

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?

2. Can we do those augmentation


in the same time?

You might also like