Professional Documents
Culture Documents
CSE 5311
Lecture 23 Maximum Flow
∑ p(u, v) −∑ p(v, u) = 0
v∈V v∈V
∀ u ∈ V- { s,t }
• total positive flow leaving a vertex = total positive flow entering the vertex
2/2
v1 v3
1/3 2/3
1/3 1/1
s 0/1 2/3 1/2 t
2/2 1/2
v2 v4
2/3
p = ( p ( s, v1 ) + p( s, v2 ) ) − p (v2 , s ) = (1 + 2) − 0 = 3
p = p (v3 , t ) + p (v4 , t ) = 2 + 1 = 3
for i=1,2,...,m
for i=1,2,...,n
s1 10 s1 10
6 v1 14 ∞ 6 v1 14
s2 4 6 t1 ∞ s1 4 6 t1 ∞
7 v1 s 7 v1
∞ t
s3 5 4 s1 5 4
t1 t1 ∞
v1 7 ∞ v1 7
s4 3 s1 3
f(x,y)
X X Y
f(y,x)
X∪Y f(x,z)
X
Z
Y f(y,z)
f(X∪Y,Z) = f(X,Z) + f(Y,Z)
Dept. CSE, UT Arlington CSE5311 Design and Analysis of Algorithms 13
CUTS OF FLOW NETWORKS & UPPER
BOUND ON MAX FLOW
• def: A cut (S, T) of a flow network is a partition of V into
S and T = V-S such that s ∈ S and t ∈ T
– Similar to the cut definition given for MST
– Differences: G is a directed graph here & we insist that s ∈ S and t ∈
T
• def: f(S, T) is the net flow across the cut (S, T) of G for a flow f on G
– Add all edges S T and negative of all edges T S due to skew
symmetry
(2) (u, v)∈ E but (v, u) ∉ E and f(u, v) ≥ 0: (v, u) becomes an edge of Ef
5/5 5 cf (u, v) = 5 – 5 = 0 ≤ 0 ×
u v u v
cf (v, u) = 0 – (– 5) = 5 > 0 √
2
3/5 cf (u, v) = 5 – 3 = 2 > 0 √
u v u v
3 cf (v, u) = 0 – (– 3) = 3 > 0 √
• |Ef| ≤ 2|E|, since (u,v)∈Ef only if at least one of (u,v) and (v,u)
is in E
• note: cf (u, v) + cf (v, u) = c(u, v) + c(v, u)
Dept. CSE, UT Arlington CSE5311 Design and Analysis of Algorithms 18
AUGMENTING PATHS
• For a flow f on G
– augmenting path p is a simple path from s to t in Gf
• cf (p): residual capacity of a path p = min {c f (u, v)}
( u ,v )∈ p
– i.e., cf (p) = max. amount of the flow we can ship along edges of
p on Gf
0 otherwise
then, f’ = f+fp is a flow on G with value
| f’ | = | f | + | fp | > | f |
(c) The flow in G that results from augmenting along path p by its residual
capacity 4. Edges carrying no flow, such as (v3, v2) are labeled only by their
capacity, another convention we follow throughout.
A cut (S, T) in the flow network, where S={s, v1, v2 } and T ={v3, v4 , t }.
The vertices in S are black, and the vertices in T are white.
The net flow across (S, T) is f (S,T)=19, and the capacity is c(S, T)= 26.
FORD-FULKERSON-METHOD(G, s, t)
initialize flow f to 0
while ∃ an augmenting path p do
augment flow f along path p
return f
The left side of each part shows the residual network Gf from line 3 with a shaded
augmenting path p. The right side of each part shows the new flow f that results from
augmenting f by fp.
Dept. CSE, UT Arlington CSE5311 Design and Analysis of Algorithms 32
FORD-FULKERSON ALGORITHM
(f) The residual network at the last while loop test. It has no augmenting paths, and the flow
f shown in (e) is therefore a maximum flow. The value of the maximum flow found is 23.
Dept. CSE, UT Arlington CSE5311 Design and Analysis of Algorithms 33
FORD-FULKERSON ALGORITHM
u1 1
u1
v1 1 1 v1
u2 1
u2 1 1 1
v2 v2 1
1
u3 s u3 1 t
1 1 v3 1
v3
u4 1 u4 1 1
v4 1
v4
u5 u5
u1 u1
v1 1 v1
u2 u2 1
1 1
v2 v2 1
1
u3 s u3 t
v3 v3 1
u4 1 u4
v4 1
v4
u5 u5