Lecture#7 - Flow Network Algorithm
Lecture#7 - Flow Network Algorithm
v 3
• The value of a flow f , denoted |f|, 6
1
7 t
is the total flow from the source, s 3
w
which is the same as the total flow 1 9 5
5
into the sink u z
2
0 e,
• Capacity Rule: For each edge f (e) c(e)
f (e) f (e )
• Conservation Rule: For each vertex evE
s,t
(v) eE
(v)
• A flow for a network N is said to be maximum if its value is the largest of all flows
for N
v 1/3 v 3/3
2/6 4/6
1/1 3/7 t 1/1 3/7 t
s 3/3 s 3/3
w w
1/1 2/9 4/5 1/1 2/9 4/5
3/5 3/5
u z u z
2/2 2/2
Flow of value 8 = 2 + 3 + 3 Flow (Maximum) of value 10 = 4 + 3 + 3
• The maximum flow problem consists of finding a maximum flow for a given
network N.
• Applications - Hydraulic Systems, Electrical Circuits, Traffic Movements etc
• Lemma : The flow f(c) across any cut c is equal to the flow value |f|
• Lemma : The flow f(c) across a cut c is less than or equal to the capacity c(c)
of the cut
12/12 12
v1 v3 v1 v3
s t s t
1/4
10
11
7/7
7
3
v2 v4 v2 v4
11/14 11
Flow network G and flow f Residual network induced by f
S S 7/9
7/10 7/7 T
7/11
T
14 6
8 3
1
10
1 5 = 0
7
Flow Networks
FORD-FULKERSON’S ALGORITHM
• Characteristics
• Single source, single sink
• Several algorithms are implementations of this method
• Requires integer capacities for steady progress
• Fastest implementation computes max flow in O(V^3) time
0/1
A 2 B
0/1 0/2
6 0
0/
S 0/1 4 0/ T
0/
0 7
9
0/1 0/
3 4
C D
0/1
• To begin, it turns out that the initial
4 RN is just the set of capacities of the graph.
• The routine is: Compute RN, find next augmenting path, recompute G and RN,
etc
12
A B
16
20
4
S 10 7 T
9
13 4
C D
14
12
A B
16
20
4
S 10 7 T
9
13 4
C D
14
12/12
A B
12/16 12/2
0
0/
S 0/1 0/ T
4 0/
0 7
9
0/1 0/
3 C D 4
0/1
4
• Resultant flow network having net flow 0+12 = 12
A B
16- 12 20-
12=4 12=8
12 4
S 10 12 T
7
9
1 4
3 C D
14
A B
16- 12 20-
12=4 12=8
12 4 12
S 10 7 T
9
1 4
3 C D
14
12/12
A B
16/16 16/2
0
0/
S 4/1 4/ T
4 0/
0 7
9
0/1 0/
3 C D 4
4/1
4
• Resultant flow network having net flow 12+4 = 16
A B
12 20-
16=4
16 8
S 6 16 T
9 4 7-4=3
1 4
4
3 C D
14-
4=10
• Find another augmenting path with DFS or BFS.
A B
12 20-
16=4
16 8
S 6 16 T
9 4 7-4=3
1 4
4
3 C D
14-
4=10
• Minimum flow network through this path is 3
12/12
A B
16/16 19/2
0
0/
S 4/1 7/ T
4 0/
0 7
9
3/1 0/
3 C D 4
7/1
4
• Resultant flow network having net flow 16+3 = 19
A B
12 20-
19=1
16 8
S 6 19 T
9 7
3
1 4
7
0 C D
14-
7=7
• Find another augmenting path with DFS or BFS.
A B
12 20-
19=1
16 8
S 6 19 T
9 7
3
1 4
7
0 C D
14-
7=7
• Minimum flow network through this path is 4
12/12
A B
16/16 19/2
0
0/
S 4/1 7/ T
4 0/
0 7
9
7/1 4/
3 C D 4
11/1
4
• Resultant flow network having net flow 19+4 = 23
A B
12 20-
19=1
16 8
S 6 19 T
9 7
7
13- 4
11
7=6 C D
14-
11=3
• Find another augmenting path with DFS or BFS.
A B
12 20-
19=1
16 8
S 6 19 T
9 7
7
13- 4
11
7=6 C D
14-
11=3
• Min Cut : 0 Max Flow : 23
Flow Networks
EDMONDS-KARP ALGORITHM
Flow Networks
MAXIMUM BIPARTITE MATCHING
M=1 M=2
V1 V2
• Solution is non-unique
• Followings graphs - all are maximum,(M=2) V1 V2
• f(e) = 1 e M
• Set M is a matching: rom graph G(V1,V2,E):
• The flow through e is 0 or 1 (capacity is 1)
• Each vertex in V1 has exactly one incoming edge: by flow conservation rule there is at
most one outgoing edge for v V1
• Each vertex in V2 has exactly one outgoing edge: there is at most one incoming edge
for v V2
V V
• Hence, each vertex in V1 will be paired in M by at most one vertex in V2 ., hence M is
1 2
the matching. t
s
• Finally, size of M = |f|.
• Job Scheduling : you have a set of people, and a set of jobs. Each person
is certified to handle 1+ jobs, but can only perform 1 job. Is there a way to
assign jobs to maximize how many jobs get done, e.g. all of them?
• Example: P1 J1; P2 J1, J2; P3 J2, J3; P4 J2, J3; P5 J3, J4, J5
• Solution : Introduce a source and sink vertex.