Document

Maximum Flow

Maximum Flow
A flow network G=(V, E) is a DIRECTED graph where each has
edge (u,v)  E a nonnegative capacity c(u , v)  0
(c(u, v)  0 , if (u,v)  E)
s, t V s : source vertex
t : sink vertex
A flow in G is a real-valued function:
f : V V  R, satisfying:

1) Capacity constraint: u,v  V , f (u , v)  c(u , v)

2) Skew symmetry: u,v  V , f (u , v)   f (u , v)
3) Flow conservation: u  V -{s, t} ,
f (u , v)  0


vV
| f |  f ( s, u ) : value of a flow f
u
f (u , V )  0
vV
p2.

Maximum-flow problem
Given a flow network G with source s and sink t, we wish to
find a flow of maximum value from s to t
12
v1
11
12
v3
20
16
15
1
s
10
4
9
7
4
13
8
v2
14
v4
t
7
4
4
11
p3.

positive net flow entering a vertex v:

f (u, v)
uV , f ( u ,v ) 0
Networks with multiple source and sinks:
s1
s1
s2
t1
s3
t2
s4
t3
s5




s’


s2
t1
s3
t2
s4
t3



t’
s5
p4.
X

X , Y  V , f ( X , Y )    f ( x, y )
xX yY

Lemma 1
G  (V , E ) : flow network
f : a flow in G
Y
1
3
2
4
f (1 , 3 )  f (1 ,4 )
 f (2 , 3 )  f (2 ,4 )
. For X  V, f ( X , X )  0
. For X,Y  V, f ( X , Y )   f (Y , X )
. For X, Y, Z  V with X Y   ,
f ( X Y , Z )  f ( X , Z )  f (Y , Z ), and
f (Z , X Y )  f (Z , X )  f (Z , Y )
X
Y
Z
| f | f ( s,V )
V  {s} (V  s)
=f (V ,V )  f (V  s,V )
=f (V ,V  s)  f (V , t )  f (V ,V  s  t ) flow conservation
=f (V , t )
  f (V , u )
uV  s t
p5.

Ford-Fulkerson method
Ford-Fulkerson-Method(G, s, t)
{ initialize flow f to o;
while there exists an aumenting path p
do aument flow f along p
return f
}

Residual networks
(Given a flow network G  (V , E )
and a flow f )
Residual capacity of (u , v )
c f (u , v )  c (u , v )  f (u , v )
The residual network of G induced by f is :
G f  (V , E f ), where
E f  {(u , v)  V  V : c f (u , v )  0 }
| E f | 2 | E |,
(u, v )  E f or (v, u )  E
p6.

Lemma 2
Let f be a flow of a flow network G and G f be
the residual network of G induced by f
Let f ' be a flow in G f , then the flow sum
( f  f ')(u , v)  f (u , v )  f '(u , v ) is a flow in G with value
|f  f ' || f |  | f ' |
Pf:
(3 ) u  V  {s, t}
(1 )
(2 )
( f  f ')(u , v)
f '(u , v)  c f (u , v)
 ( f  f ')(u, v)
 f (u , v)  f '(u , v)
( f  f ')(u , v)
  f (v, u )  f '(v, u )
 f (u , v)  f '(u , v)
  ( f (u , v)  f '(u, v))
 ( f (v, u )  f '(v, u ))
 f (u, v)  (c(u , v)  f (u , v))
  f (u , v)   f '(u , v)
 ( f  f ')(v, u )
 c(u , v)
 0 0  0
vV
vV
vV
vV
| f  f ' |  ( f  f ')( s, v)  f ( s, v)   f '( s, v) | f |  | f ' |
uV
uV
uV
p7.

Augmenting paths:
Given a flow network G=(V,E) and a flow f an augmenting
path p is a simple path from s to t in the residual network
Gf
c f ( p)  min{c f (u, v) : (u, v) is on p}
residual capacity of p: the max amount of net flow that
can be shipped along the edges
of p
p8.

Lemma3:
Let p be an augment path in G f
Define f p : V  V  R by
if (u , v)  p,
c f ( p )

fp (u , v)  -c f ( p)
if (v, u )  p,
 0
otherwise
Then, fp is a flow in G f with value |f p | c f ( p )  0

Cor4:
Let f p be defined as above. Define a function
f ' : V  V  R by f '  f  f p . Then, f ' is a flow
in G with value | f ' || f |  | f p || f |
p9.
Flow network
(a)
v1
11/16
s
12/12
10
4
4/9
v3
15/20
7/7
8/13
v2
11/14
t
4/4
v4
Residual network
(b)
v1
5
11
11
5
s
8
v2
12
v3
4
3
5
3
11
7
5
15
t
4
v4
Flow network
(c)
11/16
s
12/12
v1
10
1/4 9
v3
19/20
7/7
12/13
v2
11/14
t
4/4
v4
Residual network
(d)
v1
5
11
11
1
s
12
v2
12
9
3
3
11
v3
7
1
19
t
4
v4
(a)
v1
16
s
12
10
4
v3
9
20
7
13
v2
v1
4/16
s
10
4
4
v4
14
4/12
4/9
v3
4/14
20
7
13
v2
t
v4
t
4/4
(b)
8
v1
12
4
s
10
4
4
s
v4
4
v1
7/10
4
t
4
10
v2
20
7
5
13
11/16
v3
4
4/12
4/9
v3
7/7
13
v2
11/14
7/20
v4
t
4/4
(c)
8
v1
5
11
s
3 11
13
s
4
11
v1
10
13
7
7
5
3
v2
11/16
v3
4
4
v4
12/12
1/4 4/9
v3
11/14
15/20
7/7
8/13
v2
t
v4
t
4/4
(d)
12
v1
5
11
s
5
4
3 3
3
v2
s
11
v1
10
5
15
7
5
13
11/16
v3
4
v4
12/12
1/4 9
v3
11/14
19/20
7/7
12/13
v2
t
v4
t
4/4
(e)
v1
5
11
11
1
s
12
v2
12
9
3
3
v3
7
1
19
t
4
v4

The basic Ford-Fulkerson algorithm
Ford-Fulkerson(G, s, t)
{ for each edge(u,v)  E[G]
do f[u,v]  0
f[v,u]  0
while (there exists a path p from s to t in the
residual network G f ) do
{ cf ( p)  min{cf (u, v) : (u, v) is in p}
for each edge(u,v) in p
do f[u,v]  f[u,v]+cf ( p)
f[v,u]  f[u,v]
}
}
Note: If the augmenting paths are chosen poorly
the algorithm may no terminate.
M
M
s
t
1
M
M
If all the capacity is integeral, then a
straightforward implementation runs in
O(E|f*|), where f* is the max. flow

Edmonds-karp algorithm
Implement the computation of the augmenting path p with a
breadth-first search.
That is the augmenting path is a shortest path from s to t in
the residual network, where each edge has unit distance.
p18.

Cuts of flow networks



A cut(S,T) of flow network G=(V,E) is a partition of V into S
and T=V-S such that s  S and t T
The net flow across the cut(S,T) is defined to be f(S,T). The
capacity of the cut(S,T) is c(S,T)
Eg:
S
16
s
v1
10 4
T
12
9
v3
7
13
v2
14
20
v4
t
4
p19.

Lemma 5
Let (S,T) be a cut of a flow network G with flow f.
Then the net flow across (S,T) is f(S,T)=|f|
Pf:
f(S,T)=f(S, V)-f(S,S)
=f(S, V)
=f(s, V)+f(S-s, V)
=f(s, V)
=|f|
p20.

Cor6
The value of any flow f in a flow network G is
bounded from above by the capacity of any cut
of G
Pf:
Let (S,T) be any cut of G and f be any flow.
By the above lemma and capacity constraints
|f| = f(S,T)
= f(u,v)  c(u,v)  c(S,T)
uS vT
uS vT
p21.

Thm7:
If f is a flow in a flow network G=(V,E) with source
s and sink t, then the following conditions are equivalent:
1. f is a maximum flow in G
2. The residual network G f contains no augmenting path
3. | f | = c(S,T) for some cut(S,T) of G
Pf:
(1)  (2)
By contradiction, suppose f is a maximum flow in G
but that G f has an augment path p
By cor4, the flow sum f+fp is a flow in G with value
strictly greater than | f |. 
p22.
(2)  (3)
Suppose G f has no augmenting path, that is, that G f has no
path from s to t
Define S={v  V: a path from s to v in G f }, and T=V-S
The partition (S,T) is a cut: we have s  S trivially
and t  S
there is no path from s to T in G f .
For each pair of vertices u  S and v  T, we have
f(u,v)=c(u,v)
otherwise (u, v)  Ef and v is in set S.
By lemma5, | f | = f(S,T)=c(S,T)
(3)  (1)
By cor6, | f |  c(S,T), for all cuts(S,T). The
condition | f |=c(S,T) thus implies that f is a
maximum flow
p23.
Lemma 8

If the Edmonds-karp algorithm is run on a flow
network G=(V,E) with source s and sink t, then
distance  (s,v) in the residual network G f
increases monotonically with each flow augmentation
Pf:
By contradiction, suppose that for some vertex v  V-{s,t},
there is a flow augmentation that cause  f (s,v) to decrease.
Let f be the flow just before the augmentation, and let f'
be the flow just afterward. Then  f' ( s, v)   f ( s, v)
Assume that  f' ( s, u )   f' ( s, u ), for all vertices u  V-{s,t}
such that  f' ( s, u )   f ( s, u ).(i.e. u  V-{s,t},  f' ( s, u )   f' ( s, v)
  f ( s, u )   f' ( s, u ))
p24.
Consider a shortest path p' in G f' of the form s u  v.
Then  f' ( s, u )   f' ( s, v)  1. By(*), we have  f ( s, u )   f' ( s, u )
Consider the net flow f from u to v before the augmentation
of flow in G f
(1) If f[u,v] < c(u,v), then we have
 f ( s, v)   f ( s, u)  1   f' ( s, v)  1   f' ( s, v) 
(2) Thus f[u,v]=c(u,v), which means (u,v)  Ef
Thus augmenting path p chosen in G f to produce G f'
must have the edge(v,u), since (u,v)  Ef' and (u,v)  Ef
This is augmenting flow along the path p pushes flow
back along (u,v). v appears before u on p
Thus  f ( s, u )   f ( s, v)  1
  f ( s, v )   f ( s, u )  1
  f' ( s, u )  1
=  f' ( s, v)  2
< f' ( s, v) 
p25.

Thm 9
If the Edmonds-Karp algorithm is run on a flow network
G=(V,E) with source s and sink t, then the total
number of flow augmentations performed by the
algorithm is at most O(VE)
Pf:
(u , v) is a residual network G f is critical on an
augmenting path p if cf ( p )  cf (u , v)
After each augmentation, any critical edge disappears from
the residual network. Moreover, at least one edge on
any augmenting path must be critical
Let (u,v)  E. Since augmenting paths are shortest
paths, when (u,v) is critical for the first time, we
have  f ( s, v)   f ( s, u )  1
p26.
(u, v) will reappear later on another augmenting path
only if (v,u) appears on an augmenting path
If f' is the flow in G when this event occurs, then we
have  f' ( s, u )   f' ( s, v)  1. Since  f ( s, u )   f' ( s, v)(lemma8 )
we have  f' ( s, u )   f' ( s, v)  1   f ( s, v)  1   f ( s, u )  2
 f ( s, u ) | V | 1  (u, v) can be critical at most O(V) times
p27.
There are at most O(E) pairs of vertices that can have an edge between them in a residual
graph, the total number of critical edges during the entire execution of the Edmonds-karp
algorithm is O(VE). Each awgmenting path has at least on critical edge, and hence the theorem
follows.
Each interation of Ford-Fulkerson can be impemented in O(E) time, when the owgmenting
Path is found by BFS.
Total running time of the Edmonds-karp algorithm is O(CE2).
Best to date:

O(VE lg( V 2 / E ))
determinis tic.

O(VE  V 2 lg 3 V )
randomized .

Preflow-push algorithms:

Preflow:a function f:V  V  R satisfies




(1) skew symmetry
(2) capacity constraints
(3) f (V , u )  0 for all vertices u V  {s}
Excess flow into u:e(u)  f (V , u)
u V  {s, t} is overflowin g if e(u)  0.

G=(V,E):
a flow network with source s and sink t, and let f be a preflow in
G.

Height function:
h :V  N
h( s)  V , h(t )  0
h(u)  h(v)  1 for every residual edge (u, v)  E f .
p29.

lemma13:
Let G=(V,E) be a flow network, f be a preflow in G, and let h be a
Height function on V. for any two vertices u, v V , if h(u)>h(v)+1,
Then (u,v) is not an edge in the residual graph.
p30.




The basic operation PUSH(u,v) can be applied if u is an
overflowing vertex, cf(u,v)>0, and h(u)=h(v)+1.
e[u]:the execess flow stored at u.
h[u]:the height of u.
df(u,v):the amount of flow can be pushed from u to v.
PUSH(u,v)
{
* Applies when : u is overflowing cf[u,v]>0 and h[u]=h[v]+1.
* Action : Push df(u,v)=min(e[u],cf(u,v)) units of flow from u to v.
d f (u, v)  min( e[u ], c f [u, v]))
f [u, v]  f [u, v]  d f (u, v)
f [v, u ]   f [u, v]
e[u ]  e[u ]  d f (u, v)
e[v]  e[v]  d f (u, v) }

Saturating push:
if (u,v) becomes saturated(cf(u,v)=0 afterward); otherwise, it
is a nonsaturating push.

The basic operation LIFT(w) applies if u is overflowing and if
cf(u,v)>0 implies h[u]  h[v] for all v.
LIFT(u)
{
* Applies when : u is overflowing and for all v V , (u, v)  E f implies h[u]  h[v].
* Action : Increase the height of u.
}


h[u]  1  min{ h[v] : (u, v)  E f }
When u is lifted, Ef must contain at least one edge that leaves
u.
E[u]=f[V,u]>0  there must be at least one vertex v s.t.
f[v,u]>0.
c f (u, v)  c(u, v)  f [u, v]
 c(u, v)  f [v, u ]  0
 (u, v)  E f
Initialize-Preflow(G,s)
{
for each vertex u V [G]
do h[u]  0
e[u]  0
for each vertex (u, v)  E[G]
do f [u, v]  0
f [u, v]  0
c(u, v)
 f [u, v]   c(v, u)
h[ s]  V [G]
for each vertex u  adj[s]
do f [ s, u ]  c( s, u )
}
f [u, s]  c( s, u)
e[u]  c(s, u)
0
}
if v=s,
otherwise
and
h[u] 
Generic-Preflow-Push(G)
{
if u=s,
Initialize-Preflow(G,s) ;
While there exists an applicable push or lift op.
do select an applicable push or lift op
and perform it;
V
if u=s,
0
otherwise

Lemma14:(An overflowing vertex can be either pushed or lifted)
Let G=(V,E) be a flow network with source s and sink t, let f be a
preflow, and let h be any height function for f. if u is any overflowing
vertex, then either a push or lift op applies to it.
Proof :
For any residual edge (u,v) we have h(u )  h(v)  1 because h is a height function.
If a push operation does not apply to u, then for all residual edges (u,v), we must
have h(u)<h(v)+1, which implies h(u )  h(v).
Thus, a lift operation can be applied to u.

Lemma15: (vertex height never decrease)
During the execution of Generic-Perflow-Push on a flow network
G=(V,E), for each u V , the height h[u] never decreases. Moreover,
whenever a lift operation is applied to a vertex u, its height h[u]
increase by at least 1.
Proof :
Note that vertex heights change only during lift operations. If u is lifted, then for all v with
(u, v)  E f , we have h[u ]  h[v]; this implies h[u ]  1  min{ h[v] : (u, v)  E f }, so the op
must increase h[u].

Lemma16:
G=(V,E): a flow network
S:source
t:sink
During the execution of Generic-Preflow-Push on G, the attribute h is
maintained as a height function.
Proof :
By induction on the number of basic operations performed.
Initially, h is a height function.
Claim:if h is a height function, then a operation LIFT(u) leaves h a height function.
(1) 
u

v
, (u, v)  E f .
The operation LIFT(u) ensures that h[u]  h[v]  1 afterward.
(2) 
w
 , ( w, u )  E f .
u
By lemma15, h[w]  h[u]  1 before the op. LIFT(u) implies h[w]<h[v]+1 afterward.
Thus, the operation LIFT(u) leaves h a height function.
Consider an operation PUSH(u,v):two possibilities:
(1) add the edge (v,u) to Ef:h[v]=h[u]-1, so h remains a height function.
(2) Remove (u,v) from Ef:
The removal of (u,v) from the residual network removes the corresponding constraint,
and h remains a height function.

Lemma17:
G=(V,E): flow network ; S:source ; t:sink ; f:preflow in G ; h: height
function on V.
Thus, there is no path from the source s to the sink t in the residual
network Gf.
Proof :
By contradiction, assume there is a path p=<v0=s,v1,…,vk=t> from s to t in Gf.
Assume p is a simple path, then k  V .
For i=0,1,…,k-1, edge (vi , vi 1 )  E f .
Because h is a height function, h(vi )  h(vi 1 )  1,
for i=0,1,…,k-1.
h(v0 )  h(v1 )  1
h(v1 )  h(v2 )  1
+) h(vk 1 )  h(vk )  1

h(v0 )  h(vk )  k
h( s)  h(t )  k  k  V
=
0
But h( s)  V in a height function.
Thus, there is no such path!


Lemma18: (correctness of the generic preflow-push algorithm)
If the algorithm Generic-Preflow-Push terminates when run on a flow
network G=(V,E) with source s and sink t, then the preflow f it
computes is a maximum flow for G.
Proof :
If the generic algorithm terminates, then each vertex in V-{s,t} must have an excess of 0,
 by lemma14 and lemma16 and the invariant that f is always a preflow, there are no
overflowing vertices.
Therefore, f is a flow. Because h is a height function, by lemma17, there is no path form
s to t in the residual network Gf.
By the max-flow-min-Cut thm, f is a max flow.
p37.

Analysis of the preflow-push method:
G,s,t,f:as above.

Lemma19:
For any overflowing vertex u, there is a simple path from u to s in the
residual network Gf.
Proof :
Let U={ v: there exists a simple path from u to u in Gf }
Let U  V  U .
By contradiction, assume s U .
Claim: For each pair v U and w U that f ( w, v)  0.
If f(w,v)>0, then f(v,w)<0, which implies that cf(v,w)=c(v,w)-f(v,w)>0.
P
 (v, w)  E f , and  a simple path u 
v  w in G f .
 w U . 
Thus f (U ,U )  0 (claim)
e(U )  f (V ,U )
 f (U ,U )  f (U ,U )
 f (U ,U )  0.
U  V  {s}  e(v)  0 for all vertices v U .
 e(u)  0
  we have assumed u is overflowin g.

Lemma20: G=(V,E), s,t.
At any time during the execution of Generic-Preflow-Push on G, we
have h[u]  2 V  1 for all u V .
Proof :
Height of s and t never change,  s,t never overflow by def. Thus,
h( s)  V , h(t )  0, always.
A vertex is lifted only when if is overflowing. Consider any overflowing vertex u V  {s, t}.
By lemma19, there is a simple path from u to s in Gf. Let p=<v0=s,v1,…,vk=t>, and
k  V  1,  p is simple.
For i=0,1,…,k-1, we have (vi , vi 1 )  E f , by lemma16
hvi   hvi1   1  hu   hv0   hvk   k  h[s]  ( V  1)  2 V  1.
p39.

Corollary21: (Bound on lift operations)
During the execution of Generic-Preflow-Push on G, the number of
lift operations is at most 2 V  1 per vertex and at most
(2 V  1)( V  2)  2 V
2
overall.
Proof :
Only V-{s,t,} can be lifted. ~ V  2 vertices.
Let u V  {s, t} . The op. LIFT(u) increases h[u]. The value of h[u] is initially 0.
By lemma20, each u V  {s, t} is lifted at most 2 V  1 times.
2
Thus, the total number of lift operations performed is at most (2 V  1)( V  2)  2 V .
p40.