Lec-17-20-Network-Flow
Lec-17-20-Network-Flow
Definition of a flow: An s-t is a flow that maps each edge e in E to a non-negative real
number.
Value of a flow on edge e =(u,v) in E, f(e) // another notation f(u,v)
A flow must satisfy
Capacity Constraint: For each edge e=(u,v), f(e) ≤ c(e).
Backward/reverse edge 6
At every intermediate stage of the Ford-Fulkerson Algorithm, the flow values {f (e)} and the
residual capacities in Gf are integers.
Let f be a flow in G, and let P be a simple s-t path in Gf. Then ν(f ‘) = ν(f ) + bottleneck(P, f );
and since bottleneck(P, f) > 0, we have ν(f ‘) > ν(f ).
Suppose, as above, that all capacities in the flow network G are integers.
Then the Ford-Fulkerson Algorithm terminates in at most C iterations of the While loop.
Suppose, as above, that all capacities in the flow network G are integers.
Then the Ford-Fulkerson Algorithm can be implemented to run in O(mC) time
G: 0 0 0
10 2 0 8 6 0 10
0 0 0
s 10 3 9 5 10 t
Flow value = 0
Example
0
2 4 4
G 8×
0 ×
0 8 0
10 2 0 8 6 0 10
0 0 ×
0 8
s 10 3 9 5 10 t
Flow value =×
0
Gf
2 4 4 8
10 2 8 6 10
s 10 3 9 5 10 t
Example
0
2 4 4
G 10 ×
8 8 0
10 2 0 × 8 6 0 10
2
0 ×
0 2 ×
8 10
s 10 3 9 5 10 t
Flow value =×
8
2 4 4 10
Gf 8
2 2 8 6 10
s 10 3 9 5 2 t
8
Example
0
2 4 4
G 10 8 ×
0 6
10 2 2 8 6 0 × 10
6
×
0 6 ×
2 8 10
s 10 3 9 5 10 t
Flow value = ×
10
2 4 4 16
Gf 10
2 8 6 10
s 10 3 7 5 t
2 10
Example
×
0 2
2 4 4
G 10 8 ×
6 8
10 2 2 × 8 6 6 10
×
6 8 0
8 10
s 10 3 9 5 10 t
Flow value = ×
16
2 4 4 18
Gf 10 6
2 8 6 4
s 4 3 1 5 t
6 8 10
Example
×
2 3
2 4 4
G 10 ×
8
7 ×
8 9
10 2 0 8 6 6 10
×
8 9 ×
8 9 10
s 10 3 9 5 10 t
2 Flow value = ×
18
2 2 4 19
Gf 10 8
2 8 6 2
s 2 3 1 5 t
8 8 10
Example
3
2 4 4
G 10 7 9
10 2 0 8 6 6 10
9 9 10
s 10 3 9 5 10 t
max flow = 19 3
2 1 4
Gf 10 9
2 7 6 1
1
s 1 3 5 t
9 9 10
Optimality of the
algorithm
Cuts
t
A s B
Capacity of an s-t cut
t
A s B
The capacity of a cut (A, B) is c(A,B)=Σc (e)
e out of A
Capacity of an s-t cut
An s-t cut is a part it ion (A, B) of V wit h s A and t
B.
The capacity of a cut (A, B) is c(A,B) = Σ c (e)
e out of A
B
2 9 5
A 10 4 15 15 10
source s 5 3 8 6 10 t sink
4 6 15 10
15
capacity of
cut = 30 4 30 7
Capacity of an s-t cut
capacit y of cut = 9 + 15 + 8 + 30 = 62 (Capacity is
sum of weights on edges leaving A.)
A 5
B
2 9
10 4 15 15 10
source
s 5 3 8 6 10 t sink
4 6 15 10
15
4 30 7
Flow of an s-t cut
An s-t cut is a part it ion (A, B) of V wit h s A and t B.
t
A s B
Let f be any flow, and let (A, B) be any s-t cut.
Then, the net flow sent across the cut is
∑ f(e) - ∑ f(e)
e out of A e into A
Flow of an s-t cut
An s-t cut is a part it ion (A, B) of V wit h s A and t B.
s
let (A, B) be any s-t
value = 24 2
9
9 5 B
A 10 10 4
1
15
0
1
0 9
10
5
4 6 6
source s 5 3 8 6 10 t sink
0
10 4 1 6 1 9
15 10
50
4 7
10 30
Flow of an s-t cut
Flow value lemma. Let f be any flow, and let (A, B)
be any s-t cut. Then, the net flow sent across the
cut is equal to the amount leaving s.
∑ f (e) - ∑ f (e) = v(f )
e out of a e into a
Flow of an s-t cut
Flow value lemma. Let f be any flow, and let (A, B)
be any s-t cut. Then, the net flow sent across the
cut is equal to the amount leaving s.
∑ f (e) - ∑ f (e) = v(f )
e out of a e into a
9
value = 24 2 9 5
A 1 0 9
10 10 0
4 15 1 10
5
4 6 6
t sink
B
source s 5 3 8 6 10
0
10 4 1 6 15 9
15 10
0
4 7
10 30
Flow of an s-t cut
Flow value lemma. Let f be any flow, and let (A, B)
be any s- t cut. Then ∑ f(e) - ∑ f(e) = v(f ).
e out of A e into A
Proof: ∑ f(e) - ∑ f(e)
e out of A e into A
e out of A e into A
≤ ∑ f(e)
e out of A
≤ ∑ c(e) = c(A,B)
e out of A
Corollary: Let f be any flow, and let ( A, B)
be any s-t cut. Then v(f ) ≤ c( A, B).
Interpretation: every cut gives an upper bound
on the value of every flow, and hence the value
of the maximum flow.
2 9 5
A
10 4 15 1 10
5
source s 5 3 8 6 10 t sink
4 6 1 10
15
5
4 30 7
Augmenting path theorem.
Pf. The following three conditions are equivalent for any flow f :
Pf. The following three conditions are equivalent for any flow f :
[ iii ⇒ i ]
Let f be a flow with no augmenting paths.
Let A = set of nodes reachable from s in residual network Gf.
By definition of A: s ∈ A.
By definition of flow f: t ∉ A.
t
A s B
i There exists a cut (A, B) such that c(A, B) = v( f ).
ii f is a max flow.
iii There is no augmenting path with respect to f.
[ iii ⇒ i ]
Let f be a flow with no augmenting paths.
Let A = set of nodes reachable from s in residual network Gf.
By definition of A: s ∈ A.
By definition of flow f: t ∉ A.
t
s B
val(f ) = ∑ f(e) - ∑ f(e)
e out of A e into A
A
flow
value
lemma
i There exists a cut (A, B) such that c(A, B) = v( f ).
ii f is a max flow.
iii There is no augmenting path with respect to f.
[ iii ⇒ i ]
Let f be a flow with no augmenting paths.
Let A = set of nodes reachable from s in residual network Gf.
By definition of A: s ∈ A.
By definition of flow f: t ∉ A.
t
s B
val(f ) = ∑ f(e) - ∑ f(e)
v w
e out of A e into A
A
flow
value
= ∑ c (e) - edge e = (v, w) in G with v A, w B must have
e out of A
lemma f(e)= c(e)
otherwise there exist a residual capacity on e in Gf,
and v is reachable form s, which is a contradiction
i There exists a cut (A, B) such that c(A, B) = v( f ).
ii f is a max flow.
iii There is no augmenting path with respect to f.
edge e = (x, y) in G with x B, y A
[ iii ⇒ i ] must have f (e) = 0, if not then
・Let f be a flow with no augmenting paths. There exist residual capacity on edge (y,x) in Gf
which means x reachable from y in Gf, but it is
・ Let A = set of nodes reachable from s in residual network Gf. not possible
・By definition of A: s ∈ A.
x
・By definition of flow f: t ∉ A. y
t
s B
val(f ) = ∑ f(e) - ∑ f(e)
v w
e out of A e into A
A
flow
value
= ∑ c (e) - 0 edge e = (v, w) in G with v A, w B must have
e out of A f(e)= c(e)
lemma
= c(A , B ) otherwise there exist a residual capacity on e in Gf,
and v is reachable form s, which is a contradiction
Network Flow
APPLICATIONS of FF
2 5
s 3 6 t
4 7
2 5
s 3 6 t
4 7
s 3 6 t
4 7
1
1 1
1 1
1
s 1 1 t
1
1 1 1 1
1
1 1
1 1
1
s 1 1 t
1
1 1 1 1
1
1 1
1 1
1
s 1 1 t
1
1 1 1 1
Theorem. There are k edge-disjoint paths from s to t iff the max flow value is k.
Proof. ( )
Suppose there are k edge-disjoint paths P1, . . . , Pk.
Set f(e) = 1 if e participates in some path Pi ; otherwise, set f(e) = 0.
Since paths are edge-disjoint, f is a flow of value k.
1
1 1
1 1
1
s 1 1 t
1
1 1 1 1
Theorem. There are k edge-disjoint paths from s to t iff the max flow value is k.
Proof. ( )
Suppose max flow value is k. By integrality theorem, there exists {0, 1} flow f of value k.
Consider edge (s,v) with f(s,v) = 1.
–by conservation, there exists an arc (v,w) with f(v,w) = 1
–continue until reach t, always choosing a new edge
Produces k edge-disjoint paths.
12
1 1'
2 2' matching
1-2', 3-1', 4-5'
3 3'
4 4'
L 5 5' R
1 1'
2 2' matching
1-1, 2-2, 3-3,5-5
3 3'
4 4'
L 5 5' R
G' 1 1 1'
1 1
2 2'
s 3 3' t
4 4'
L 5 5' R
1 1' 1 1 1'
1 1
2 2' 2 2'
3 3' s 3 3' t
4 4' 4 4'
G G'
5 5' 5 5'
1 1
2 2' 2 2'
s 3 3' t 3 3'
4 4' 4 4'
G'
5 5' 5 5'
Prepared by Pawan K. Mishra 18
Perfect Matching
Def. A matching M E is perfect if each node appears in
exactly one edge in M.
1 1'
4 4'
L 5 5' R
Prepared by Pawan K. Mishra 20
Marriage Theorem (HALLS THEOREM)
Marriage Theorem.[Frobenius 1917, Hall 1935]
Let G = (L R, E) be a bipartite graph with |L| = |R|.
Then, G has a perfect matching iff