Académique Documents
Professionnel Documents
Culture Documents
6.046J/18.401J LECTURE 20
Network Flow I
Flow networks
Maximum-flow problem Flow notation
Properties of flow Cuts Residual networks Augmenting paths Prof. Charles E. Leiserson
Flow networks
Definition. A flow network is a directed graph G = (V, E) with two distinguished vertices: a source s and a sink t. Each edge (u, v) E has a nonnegative capacity c(u, v). If (u, v) E, then c(u, v) = 0.
Introduction to Algorithms
L20.2
Flow networks
Definition. A flow network is a directed graph G = (V, E) with two distinguished vertices: a source s and a sink t. Each edge (u, v) E has a nonnegative capacity c(u, v). If (u, v) E, then c(u, v) = 0. Example:
3 2 3 1 2
20014 by Charles E. Leiserson
s s
2 2
tt
3
Introduction to Algorithms
L20.3
Flow networks
p(u, v) p(v,
u ) = 0 .
vV
Introduction to Algorithms
L20.4
Flow networks
vV
p(u, v) p(v, u ) = 0 .
vV
The value of a flow is the net flow out of the source: p( s, v) p(v, s) .
vV vV
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.5
A flow on a network
positive flow s s
2:2
capacity
2:2 1:3 0:1 1:3 1:1 2:3 2:3
1:2 1:2
2:3
tt
Introduction to Algorithms
L20.6
A flow on a network
positive flow s s
2:2
capacity
2:2 1:3 0:1 1:3 1:1 2:3 1:2 1:2
2:3
tt
2:3
s s
tt
Flow cancellation
v v
0:2
u u
u u
The capacity constraint and flow conservation are preserved by this transformation. INTUITION: View flow as a rate, not a quantity.
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.9
A notational simplification
vV
A notational simplification
Equivalence of definitions
Introduction to Algorithms
L20.12
Equivalence of definitions
vV
= p (u , v) p (v, u )
vV vV vV
Skew symmetry: f (u, v) = p(u, v) p(v, u) = (p(v, u) p(u, v)) = f (v, u).
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.13
Proof (continued)
() Let
p(u, v) = f (u, v) if f(u, v) > 0,
0 if f(u, v) 0.
Capacity constraint: By definition, p(u, v) 0. Since f (u, v) c(u, v), it follows that p(u, v) c(u, v). Flow conservation: If f (u, v) > 0, then p(u, v) p(v, u) = f (u, v). If f (u, v) 0, then p(u, v) p(v, u) = f (v, u) = f (u, v) by skew symmetry. Therefore,
vV vV vV
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.14
Notation
= f ( s, V ) .
Implicit summation notation: A set used in an arithmetic formula represents a sum over the elements of the set. Example flow conservation:
f (u, V) = 0 for all u V {s, t}.
vV
Introduction to Algorithms
L20.16
Proof.
|f| = = = = = f (s, V) f (V, V) f (Vs, V) Omit braces. f (V, Vs) f (V, t) + f (V, Vst) f (V, t).
Introduction to Algorithms November 24, 2004 L20.17
s s
tt
| f | = f (s, V) = 4
f (V, t) = 4
Introduction to Algorithms
L20.18
Cuts
Definition. A cut (S, T) of a flow network G = (V, E) is a partition of V such that s S and t T. If f is a flow on G, then the flow across the cut is f (S, T).
2:2 2:3 2:3 0:1 2:2 0:3 1:1 1:3 3:3 0:2 2:2
s s
tt
S T
f (S, T) = (2 + 2) + ( 2 + 1 1 + 2) =4
Introduction to Algorithms
L20.19
Introduction to Algorithms
L20.20
Introduction to Algorithms
L20.21
Capacity of a cut
2:2 2:3 2:3 0:1 2:2 0:3 1:1 1:3 3:3 0:2 2:2
s s
tt
S T
c(S, T) = (3 + 2) + (1 + 2 + 3) = 11
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.22
Introduction to Algorithms
L20.23
uS vT uS vT
Introduction to Algorithms
L20.24
Residual network
Definition. Let f be a flow on G = (V, E). The residual network Gf (V, Ef ) is the graph with strictly positive residual capacities cf (u, v) = c(u, v) f (u, v) > 0. Edges in Ef admit more flow.
Introduction to Algorithms
L20.25
Residual network
Definition. Let f be a flow on G = (V, E). The residual network Gf (V, Ef ) is the graph with strictly positive residual capacities cf (u, v) = c(u, v) f (u, v) > 0. Edges in Ef admit more flow. Example:
0:1 4
G:
u u
3:5
v v
Gf :
u u
2
v v
Introduction to Algorithms
L20.26
Residual network
Definition. Let f be a flow on G = (V, E). The residual network Gf (V, Ef ) is the graph with strictly positive residual capacities cf (u, v) = c(u, v) f (u, v) > 0. Edges in Ef admit more flow. Example:
0:1 4
G:
u u
3:5
v v
Gf :
u u
2
v v
Lemma. | Ef | 2| E |.
20014 by Charles E. Leiserson Introduction to Algorithms November 24, 2004 L20.27
Augmenting paths
Definition. Any path from s to t in Gf is an augmenting path in G with respect to f. The flow value can be increased along an augmenting path p by c f ( p) = min {c f (u , v)}.
(u ,v )p
Introduction to Algorithms
L20.28
Augmenting paths
Definition. Any path from s to t in Gf is an augmenting path in G with respect to f. The flow value can be increased along an augmenting path p by c f ( p) = min {c f (u , v)}.
(u ,v )p
Ex.:
3:5
2:6
0:2
2:5
G: cf (p) = 2 Gf :
ss
2 4 5:5 7 2:3 2 3
tt
ss
3 2
Introduction to Algorithms
tt
1 2
L20.29 November 24, 2004
Introduction to Algorithms
L20.30
Introduction to Algorithms
L20.31