1. Iris Hui-Ru Jiang Fall 2014
CHAPTER 7
NETWORK FLOW
IRIS H.-R. JIANG
Outline
¨ Content:
¤ Network flow
¤ Bipartite matching: a special case of network flow
¨ Reading:
¤ Chapter 7
Network flow
2
IRIS H.-R. JIANG
Flow Network (1/2)
¨ Abstraction for material flowing through the edges.
¤ Water pipes: water
¤ Transportation network: traffic
Network flow
3
Harris & Ross, 1955
The Soviet and
Eastern European
railways network:
44 nodes and 105
undirected edges
Maximum flow:
163,000 from Russia
to Eastern Europe
=
Bottleneck (cut of
capacity): 163,000
¤ Computer network: packets
¤ Circuit network (wires): current
IRIS H.-R. JIANG
Flow Network (2/2)
¨ A flow network G = (V, E) is a directed graph
¤ ce ³ 0: capacity of edge e.
¤ Source s Î V: generates the flow
¤ Sink t Î V: absorbs the flow
n Internal node: u Î V {s, t}
Network flow
4
a
b
3
s
1
2
t
2
1
capacity
internal node
3
1
t
2
1
2
s
a
b
2. Iris Hui-Ru Jiang Fall 2014
CHAPTER 7
NETWORK FLOW
IRIS H.-R. JIANG
Outline
¨ Content:
¤ Network flow
¤ Bipartite matching: a special case of network flow
¨ Reading:
¤ Chapter 7
Network flow
2
IRIS H.-R. JIANG
Flow Network (1/2)
¨ Abstraction for material flowing through the edges.
¤ Water pipes: water
¤ Transportation network: traffic
Network flow
3
Harris & Ross, 1955
The Soviet and
Eastern European
railways network:
44 nodes and 105
undirected edges
Maximum flow:
163,000 from Russia
to Eastern Europe
=
Bottleneck (cut of
capacity): 163,000
¤ Computer network: packets
¤ Circuit network (wires): current
IRIS H.-R. JIANG
Flow Network (2/2)
¨ A flow network G = (V, E) is a directed graph
¤ ce ³ 0: capacity of edge e.
¤ Source s Î V: generates the flow
¤ Sink t Î V: absorbs the flow
n Internal node: u Î V {s, t}
Network flow
4
a
b
3
s
1
2
t
2
1
capacity
internal node
3
1
t
2
1
2
s
a
b
3. Iris Hui-Ru Jiang Fall 2014
CHAPTER 7
NETWORK FLOW
IRIS H.-R. JIANG
Outline
¨ Content:
¤ Network flow
¤ Bipartite matching: a special case of network flow
¨ Reading:
¤ Chapter 7
Network flow
2
IRIS H.-R. JIANG
Flow Network (1/2)
¨ Abstraction for material flowing through the edges.
¤ Water pipes: water
¤ Transportation network: traffic
Network flow
3
Harris & Ross, 1955
The Soviet and
Eastern European
railways network:
44 nodes and 105
undirected edges
Maximum flow:
163,000 from Russia
to Eastern Europe
=
Bottleneck (cut of
capacity): 163,000
¤ Computer network: packets
¤ Circuit network (wires): current
IRIS H.-R. JIANG
Flow Network (2/2)
¨ A flow network G = (V, E) is a directed graph
¤ ce ³ 0: capacity of edge e.
¤ Source s Î V: generates the flow
¤ Sink t Î V: absorbs the flow
n Internal node: u Î V {s, t}
Network flow
4
a
b
3
s
1
2
t
2
1
capacity
internal node
3
1
t
2
1
2
s
a
b
4. Iris Hui-Ru Jiang Fall 2014
CHAPTER 7
NETWORK FLOW
IRIS H.-R. JIANG
Outline
¨ Content:
¤ Network flow
¤ Bipartite matching: a special case of network flow
¨ Reading:
¤ Chapter 7
Network flow
2
IRIS H.-R. JIANG
Flow Network (1/2)
¨ Abstraction for material flowing through the edges.
¤ Water pipes: water
¤ Transportation network: traffic
Network flow
3
Harris & Ross, 1955
The Soviet and
Eastern European
railways network:
44 nodes and 105
undirected edges
Maximum flow:
163,000 from Russia
to Eastern Europe
=
Bottleneck (cut of
capacity): 163,000
¤ Computer network: packets
¤ Circuit network (wires): current
IRIS H.-R. JIANG
Flow Network (2/2)
¨ A flow network G = (V, E) is a directed graph
¤ ce ³ 0: capacity of edge e.
¤ Source s Î V: generates the flow
¤ Sink t Î V: absorbs the flow
n Internal node: u Î V {s, t}
Network flow
4
a
b
3
s
1
2
t
2
1
capacity
internal node
3
1
t
2
1
2
s
a
b
5. IRIS H.-R. JIANG
2
1
2
Pushing Flow
¨ Start with zero flow
¨ Push a flow of value 2
¨ Þ Flow = 2
¨ Q: Can we push more?
¨ Start with zero flow
¨ Push a flow of value 2
¨ Push a flow of value 1
¨ A: Yes. Flow = 3
¨ Undo flow
Greedy General
5
Network flow
3
1
t
2
1
2
s
a
b
1
2
3
1
t
2
1
2
s
a
b
IRIS H.-R. JIANG
a
b
3
s
1
2
t
2
1
n(f) = 3
3
1
t
2
1
2
s
a
b
The Maximum Flow Problem
¨ Given: A flow network
¨ Goal: Find a flow of max possible value
¨ Flow definition:
¤ s-t flow f: E ® Â+
¤ A function f that maps each edge e to
a nonnegative real number
n f(e): flow carried by edge e
¤ n(f): the value of a flow f
n n(f) = åe out of s f(e) (flow generated at s)
¨ Flow properties
1. Capacity conditions:
n "eÎE , 0 £ f(e) £ ce
2. Conservation conditions:
n "uÎV {s, t}, åe into v f(e) = åe out of v f(e)
Network flow
6
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
IRIS H.-R. JIANG
Upper Bounds of the Maximum s-t Flow
¨ Q: Can we find the upper bound of the s-t flow?
¨ A: Yes!
¤ Divide the nodes into two sets, A and B, so that s Î A and t Î B.
¤ Any s-t flow must cross from A into B at some point.
¤ The s-t flow uses up some of the edge capacity from A to B.
¨ Each “cut” places an upper bound on the maximum value of an
s-t flow. Þ Find cuts of minimum capacity = find maximum flow
Network flow
7
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
A B
IRIS H.-R. JIANG
Ford-Fulkerson: Residual Graph
¨ Pushing flow:
¤ Push forward on edges with leftover capacity
¤ Push backward on edges with flow
¨ The residual graph Gf of G w.r.t. f:
¤ V(Gf ) = V(G)
¤ For each e = (u, v) Î E(G)
n f(e) < ce: Forward edge: e’ = (u, v), c’e = ce - f(e)
n 0 < f(e): Backward edge: e”= (v, u), c”e = f(e)
Network flow
8
1
2
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
3
1
t
2
1
2
s
a
b
1
1
1
residual
capacity
Gf records the
remaining capacity to
push more flow
2
2
2
6. IRIS H.-R. JIANG
2
1
2
Pushing Flow
¨ Start with zero flow
¨ Push a flow of value 2
¨ Þ Flow = 2
¨ Q: Can we push more?
¨ Start with zero flow
¨ Push a flow of value 2
¨ Push a flow of value 1
¨ A: Yes. Flow = 3
¨ Undo flow
Greedy General
5
Network flow
3
1
t
2
1
2
s
a
b
1
2
3
1
t
2
1
2
s
a
b
IRIS H.-R. JIANG
a
b
3
s
1
2
t
2
1
n(f) = 3
3
1
t
2
1
2
s
a
b
The Maximum Flow Problem
¨ Given: A flow network
¨ Goal: Find a flow of max possible value
¨ Flow definition:
¤ s-t flow f: E ® Â+
¤ A function f that maps each edge e to
a nonnegative real number
n f(e): flow carried by edge e
¤ n(f): the value of a flow f
n n(f) = åe out of s f(e) (flow generated at s)
¨ Flow properties
1. Capacity conditions:
n "eÎE , 0 £ f(e) £ ce
2. Conservation conditions:
n "uÎV {s, t}, åe into v f(e) = åe out of v f(e)
Network flow
6
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
IRIS H.-R. JIANG
Upper Bounds of the Maximum s-t Flow
¨ Q: Can we find the upper bound of the s-t flow?
¨ A: Yes!
¤ Divide the nodes into two sets, A and B, so that s Î A and t Î B.
¤ Any s-t flow must cross from A into B at some point.
¤ The s-t flow uses up some of the edge capacity from A to B.
¨ Each “cut” places an upper bound on the maximum value of an
s-t flow. Þ Find cuts of minimum capacity = find maximum flow
Network flow
7
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
A B
IRIS H.-R. JIANG
Ford-Fulkerson: Residual Graph
¨ Pushing flow:
¤ Push forward on edges with leftover capacity
¤ Push backward on edges with flow
¨ The residual graph Gf of G w.r.t. f:
¤ V(Gf ) = V(G)
¤ For each e = (u, v) Î E(G)
n f(e) < ce: Forward edge: e’ = (u, v), c’e = ce - f(e)
n 0 < f(e): Backward edge: e”= (v, u), c”e = f(e)
Network flow
8
1
2
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
3
1
t
2
1
2
s
a
b
1
1
1
residual
capacity
Gf records the
remaining capacity to
push more flow
2
2
2
7. IRIS H.-R. JIANG
2
1
2
Pushing Flow
¨ Start with zero flow
¨ Push a flow of value 2
¨ Þ Flow = 2
¨ Q: Can we push more?
¨ Start with zero flow
¨ Push a flow of value 2
¨ Push a flow of value 1
¨ A: Yes. Flow = 3
¨ Undo flow
Greedy General
5
Network flow
3
1
t
2
1
2
s
a
b
1
2
3
1
t
2
1
2
s
a
b
IRIS H.-R. JIANG
a
b
3
s
1
2
t
2
1
n(f) = 3
3
1
t
2
1
2
s
a
b
The Maximum Flow Problem
¨ Given: A flow network
¨ Goal: Find a flow of max possible value
¨ Flow definition:
¤ s-t flow f: E ® Â+
¤ A function f that maps each edge e to
a nonnegative real number
n f(e): flow carried by edge e
¤ n(f): the value of a flow f
n n(f) = åe out of s f(e) (flow generated at s)
¨ Flow properties
1. Capacity conditions:
n "eÎE , 0 £ f(e) £ ce
2. Conservation conditions:
n "uÎV {s, t}, åe into v f(e) = åe out of v f(e)
Network flow
6
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
IRIS H.-R. JIANG
Upper Bounds of the Maximum s-t Flow
¨ Q: Can we find the upper bound of the s-t flow?
¨ A: Yes!
¤ Divide the nodes into two sets, A and B, so that s Î A and t Î B.
¤ Any s-t flow must cross from A into B at some point.
¤ The s-t flow uses up some of the edge capacity from A to B.
¨ Each “cut” places an upper bound on the maximum value of an
s-t flow. Þ Find cuts of minimum capacity = find maximum flow
Network flow
7
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
A B
IRIS H.-R. JIANG
Ford-Fulkerson: Residual Graph
¨ Pushing flow:
¤ Push forward on edges with leftover capacity
¤ Push backward on edges with flow
¨ The residual graph Gf of G w.r.t. f:
¤ V(Gf ) = V(G)
¤ For each e = (u, v) Î E(G)
n f(e) < ce: Forward edge: e’ = (u, v), c’e = ce - f(e)
n 0 < f(e): Backward edge: e”= (v, u), c”e = f(e)
Network flow
8
1
2
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
3
1
t
2
1
2
s
a
b
1
1
1
residual
capacity
Gf records the
remaining capacity to
push more flow
2
2
2
8. IRIS H.-R. JIANG
2
1
2
Pushing Flow
¨ Start with zero flow
¨ Push a flow of value 2
¨ Þ Flow = 2
¨ Q: Can we push more?
¨ Start with zero flow
¨ Push a flow of value 2
¨ Push a flow of value 1
¨ A: Yes. Flow = 3
¨ Undo flow
Greedy General
5
Network flow
3
1
t
2
1
2
s
a
b
1
2
3
1
t
2
1
2
s
a
b
IRIS H.-R. JIANG
a
b
3
s
1
2
t
2
1
n(f) = 3
3
1
t
2
1
2
s
a
b
The Maximum Flow Problem
¨ Given: A flow network
¨ Goal: Find a flow of max possible value
¨ Flow definition:
¤ s-t flow f: E ® Â+
¤ A function f that maps each edge e to
a nonnegative real number
n f(e): flow carried by edge e
¤ n(f): the value of a flow f
n n(f) = åe out of s f(e) (flow generated at s)
¨ Flow properties
1. Capacity conditions:
n "eÎE , 0 £ f(e) £ ce
2. Conservation conditions:
n "uÎV {s, t}, åe into v f(e) = åe out of v f(e)
Network flow
6
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
IRIS H.-R. JIANG
Upper Bounds of the Maximum s-t Flow
¨ Q: Can we find the upper bound of the s-t flow?
¨ A: Yes!
¤ Divide the nodes into two sets, A and B, so that s Î A and t Î B.
¤ Any s-t flow must cross from A into B at some point.
¤ The s-t flow uses up some of the edge capacity from A to B.
¨ Each “cut” places an upper bound on the maximum value of an
s-t flow. Þ Find cuts of minimum capacity = find maximum flow
Network flow
7
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
A B
IRIS H.-R. JIANG
Ford-Fulkerson: Residual Graph
¨ Pushing flow:
¤ Push forward on edges with leftover capacity
¤ Push backward on edges with flow
¨ The residual graph Gf of G w.r.t. f:
¤ V(Gf ) = V(G)
¤ For each e = (u, v) Î E(G)
n f(e) < ce: Forward edge: e’ = (u, v), c’e = ce - f(e)
n 0 < f(e): Backward edge: e”= (v, u), c”e = f(e)
Network flow
8
1
2
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
3
1
t
2
1
2
s
a
b
1
1
1
residual
capacity
Gf records the
remaining capacity to
push more flow
2
2
2
9. IRIS H.-R. JIANG
Augmenting Paths in a Residual Graph
¨ Pushing flow
¤ Gf records the remaining capacity to push flow
¤ Let P be a simple s-t path in Gf
n bottleneck(P, f) = min res. cap on P
¤ Push bottleneck(P, f) units of flow
¤ New s-t flow: n(f) + bottleneck(P, f)
n Increase f(e) by bottleneck(P, f) for forward edge
n Decrease f(e) by bottleneck(P, f) for backward edge
Network flow
9
¨ Pushing flow = augmenting path in residual graphs
1
2
3
1
t
2
1
2
s
a
b
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
1
1
1
2
2
2
a
b
s t
1
1
2
1
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
G
IRIS H.-R. JIANG
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
Ford-Fulkerson: Example (1/5)
Network flow
10
G a
b d t
c
0/4
0/8
0/2
0/9 0/10
s 0/10
0/10 0/6 0/10
f(e) / ce
flow value = 0
a
b d t
c
4
8
2
9 10
s 10
10 6 10
Gf
8
10
10
8/8
8/10
8/10
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
IRIS H.-R. JIANG
Ford-Fulkerson: Example (2/5)
Network flow
11
G a
b d t
c
0/4
8/8
0/2
0/9 8/10
s 0/10
8/10 0/6 0/10
f(e) / ce
flow value = 8
a
b d t
c
4
2
9 2
s 10
2 6 10
Gf
8
8
8
9
10
6 10
6/9
6/10
6/6 6/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (3/5)
Network flow
12
G a
b d t
c
0/4
8/8
0/2
6/9 8/10
s 6/10
8/10 6/6 6/10
f(e) / ce
flow value = 14
a
b d t
c
4
2
3 2
s 4
2 6 4
Gf
8
8
8
6
6
6
4
3
4
4
8
3/4
5/8
9/9
9/10
9/10
10. IRIS H.-R. JIANG
Augmenting Paths in a Residual Graph
¨ Pushing flow
¤ Gf records the remaining capacity to push flow
¤ Let P be a simple s-t path in Gf
n bottleneck(P, f) = min res. cap on P
¤ Push bottleneck(P, f) units of flow
¤ New s-t flow: n(f) + bottleneck(P, f)
n Increase f(e) by bottleneck(P, f) for forward edge
n Decrease f(e) by bottleneck(P, f) for backward edge
Network flow
9
¨ Pushing flow = augmenting path in residual graphs
1
2
3
1
t
2
1
2
s
a
b
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
1
1
1
2
2
2
a
b
s t
1
1
2
1
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
G
IRIS H.-R. JIANG
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
Ford-Fulkerson: Example (1/5)
Network flow
10
G a
b d t
c
0/4
0/8
0/2
0/9 0/10
s 0/10
0/10 0/6 0/10
f(e) / ce
flow value = 0
a
b d t
c
4
8
2
9 10
s 10
10 6 10
Gf
8
10
10
8/8
8/10
8/10
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
IRIS H.-R. JIANG
Ford-Fulkerson: Example (2/5)
Network flow
11
G a
b d t
c
0/4
8/8
0/2
0/9 8/10
s 0/10
8/10 0/6 0/10
f(e) / ce
flow value = 8
a
b d t
c
4
2
9 2
s 10
2 6 10
Gf
8
8
8
9
10
6 10
6/9
6/10
6/6 6/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (3/5)
Network flow
12
G a
b d t
c
0/4
8/8
0/2
6/9 8/10
s 6/10
8/10 6/6 6/10
f(e) / ce
flow value = 14
a
b d t
c
4
2
3 2
s 4
2 6 4
Gf
8
8
8
6
6
6
4
3
4
4
8
3/4
5/8
9/9
9/10
9/10
11. IRIS H.-R. JIANG
Augmenting Paths in a Residual Graph
¨ Pushing flow
¤ Gf records the remaining capacity to push flow
¤ Let P be a simple s-t path in Gf
n bottleneck(P, f) = min res. cap on P
¤ Push bottleneck(P, f) units of flow
¤ New s-t flow: n(f) + bottleneck(P, f)
n Increase f(e) by bottleneck(P, f) for forward edge
n Decrease f(e) by bottleneck(P, f) for backward edge
Network flow
9
¨ Pushing flow = augmenting path in residual graphs
1
2
3
1
t
2
1
2
s
a
b
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
1
1
1
2
2
2
a
b
s t
1
1
2
1
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
G
IRIS H.-R. JIANG
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
Ford-Fulkerson: Example (1/5)
Network flow
10
G a
b d t
c
0/4
0/8
0/2
0/9 0/10
s 0/10
0/10 0/6 0/10
f(e) / ce
flow value = 0
a
b d t
c
4
8
2
9 10
s 10
10 6 10
Gf
8
10
10
8/8
8/10
8/10
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
IRIS H.-R. JIANG
Ford-Fulkerson: Example (2/5)
Network flow
11
G a
b d t
c
0/4
8/8
0/2
0/9 8/10
s 0/10
8/10 0/6 0/10
f(e) / ce
flow value = 8
a
b d t
c
4
2
9 2
s 10
2 6 10
Gf
8
8
8
9
10
6 10
6/9
6/10
6/6 6/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (3/5)
Network flow
12
G a
b d t
c
0/4
8/8
0/2
6/9 8/10
s 6/10
8/10 6/6 6/10
f(e) / ce
flow value = 14
a
b d t
c
4
2
3 2
s 4
2 6 4
Gf
8
8
8
6
6
6
4
3
4
4
8
3/4
5/8
9/9
9/10
9/10
12. IRIS H.-R. JIANG
Augmenting Paths in a Residual Graph
¨ Pushing flow
¤ Gf records the remaining capacity to push flow
¤ Let P be a simple s-t path in Gf
n bottleneck(P, f) = min res. cap on P
¤ Push bottleneck(P, f) units of flow
¤ New s-t flow: n(f) + bottleneck(P, f)
n Increase f(e) by bottleneck(P, f) for forward edge
n Decrease f(e) by bottleneck(P, f) for backward edge
Network flow
9
¨ Pushing flow = augmenting path in residual graphs
1
2
3
1
t
2
1
2
s
a
b
a
b
2/3
s
0/1
2/2
t
2/2
0/1
f(e) / ce
G
a
b
s t
Gf
1
1
1
2
2
2
a
b
s t
1
1
2
1
a
b
1/3
s
1/1
2/2
t
2/2
1/1
f(e) / ce
G
IRIS H.-R. JIANG
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
Ford-Fulkerson: Example (1/5)
Network flow
10
G a
b d t
c
0/4
0/8
0/2
0/9 0/10
s 0/10
0/10 0/6 0/10
f(e) / ce
flow value = 0
a
b d t
c
4
8
2
9 10
s 10
10 6 10
Gf
8
10
10
8/8
8/10
8/10
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
IRIS H.-R. JIANG
Ford-Fulkerson: Example (2/5)
Network flow
11
G a
b d t
c
0/4
8/8
0/2
0/9 8/10
s 0/10
8/10 0/6 0/10
f(e) / ce
flow value = 8
a
b d t
c
4
2
9 2
s 10
2 6 10
Gf
8
8
8
9
10
6 10
6/9
6/10
6/6 6/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (3/5)
Network flow
12
G a
b d t
c
0/4
8/8
0/2
6/9 8/10
s 6/10
8/10 6/6 6/10
f(e) / ce
flow value = 14
a
b d t
c
4
2
3 2
s 4
2 6 4
Gf
8
8
8
6
6
6
4
3
4
4
8
3/4
5/8
9/9
9/10
9/10
13. IRIS H.-R. JIANG
Ford-Fulkerson: Example (4/5)
Network flow
13
G a
b d t
c
3/4
5/8
0/2
9/9 8/10
s 9/10
8/10 6/6 9/10
f(e) / ce
flow value = 17
a
b d t
c
1
2
2
s 1
2 6 1
Gf
8
5
8
9
9
9
3
3
2
2 3
7/8
10/10
10/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (5/5)
Network flow
14
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
flow value = 19
a
b d t
c
1
2
s 1
6 1
Gf
10
7
10
9
9
9
3
1
No s-t path in Gf!!
Done!
A B
A B
flow value = 19
cut capacity = 19
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
15
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
¨ Procedure
1. Start with f(e) = 0 for all edge e Î E and construct the residual
graph.
2. Find an s-t path P in the residual graph.
3. Augment flow along path P and update the residual graph.
4. Repeat steps 2-3 until you get stuck.
¨ Optimal
IRIS H.-R. JIANG
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
a
b d t
c
4
8
2
9 10
s 10
10 6 10
The Max-Flow Min-Cut Theorem
¨ The value of the max flow is equal to the value of the min cut.
¤ Cut: Divide V into two disjoint sets, A and B, s.t. s Î A and t Î B.
¤ Min-cut: minimize the sum of the capacities of the cut edges
directed from A to B
¨ Observation:
¤ Any s-t flow must cross from A into B at some point and uses up
some of the capacities of the cut edges.
¤ Each cut places an upper bound on the max value of an s-t flow.
Network flow
16
G
A B
27
2
21
19
max flow = min cut
14. IRIS H.-R. JIANG
Ford-Fulkerson: Example (4/5)
Network flow
13
G a
b d t
c
3/4
5/8
0/2
9/9 8/10
s 9/10
8/10 6/6 9/10
f(e) / ce
flow value = 17
a
b d t
c
1
2
2
s 1
2 6 1
Gf
8
5
8
9
9
9
3
3
2
2 3
7/8
10/10
10/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (5/5)
Network flow
14
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
flow value = 19
a
b d t
c
1
2
s 1
6 1
Gf
10
7
10
9
9
9
3
1
No s-t path in Gf!!
Done!
A B
A B
flow value = 19
cut capacity = 19
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
15
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
¨ Procedure
1. Start with f(e) = 0 for all edge e Î E and construct the residual
graph.
2. Find an s-t path P in the residual graph.
3. Augment flow along path P and update the residual graph.
4. Repeat steps 2-3 until you get stuck.
¨ Optimal
IRIS H.-R. JIANG
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
a
b d t
c
4
8
2
9 10
s 10
10 6 10
The Max-Flow Min-Cut Theorem
¨ The value of the max flow is equal to the value of the min cut.
¤ Cut: Divide V into two disjoint sets, A and B, s.t. s Î A and t Î B.
¤ Min-cut: minimize the sum of the capacities of the cut edges
directed from A to B
¨ Observation:
¤ Any s-t flow must cross from A into B at some point and uses up
some of the capacities of the cut edges.
¤ Each cut places an upper bound on the max value of an s-t flow.
Network flow
16
G
A B
27
2
21
19
max flow = min cut
15. IRIS H.-R. JIANG
Ford-Fulkerson: Example (4/5)
Network flow
13
G a
b d t
c
3/4
5/8
0/2
9/9 8/10
s 9/10
8/10 6/6 9/10
f(e) / ce
flow value = 17
a
b d t
c
1
2
2
s 1
2 6 1
Gf
8
5
8
9
9
9
3
3
2
2 3
7/8
10/10
10/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (5/5)
Network flow
14
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
flow value = 19
a
b d t
c
1
2
s 1
6 1
Gf
10
7
10
9
9
9
3
1
No s-t path in Gf!!
Done!
A B
A B
flow value = 19
cut capacity = 19
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
15
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
¨ Procedure
1. Start with f(e) = 0 for all edge e Î E and construct the residual
graph.
2. Find an s-t path P in the residual graph.
3. Augment flow along path P and update the residual graph.
4. Repeat steps 2-3 until you get stuck.
¨ Optimal
IRIS H.-R. JIANG
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
a
b d t
c
4
8
2
9 10
s 10
10 6 10
The Max-Flow Min-Cut Theorem
¨ The value of the max flow is equal to the value of the min cut.
¤ Cut: Divide V into two disjoint sets, A and B, s.t. s Î A and t Î B.
¤ Min-cut: minimize the sum of the capacities of the cut edges
directed from A to B
¨ Observation:
¤ Any s-t flow must cross from A into B at some point and uses up
some of the capacities of the cut edges.
¤ Each cut places an upper bound on the max value of an s-t flow.
Network flow
16
G
A B
27
2
21
19
max flow = min cut
16. IRIS H.-R. JIANG
Ford-Fulkerson: Example (4/5)
Network flow
13
G a
b d t
c
3/4
5/8
0/2
9/9 8/10
s 9/10
8/10 6/6 9/10
f(e) / ce
flow value = 17
a
b d t
c
1
2
2
s 1
2 6 1
Gf
8
5
8
9
9
9
3
3
2
2 3
7/8
10/10
10/10
IRIS H.-R. JIANG
Ford-Fulkerson: Example (5/5)
Network flow
14
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
flow value = 19
a
b d t
c
1
2
s 1
6 1
Gf
10
7
10
9
9
9
3
1
No s-t path in Gf!!
Done!
A B
A B
flow value = 19
cut capacity = 19
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
15
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
¨ Procedure
1. Start with f(e) = 0 for all edge e Î E and construct the residual
graph.
2. Find an s-t path P in the residual graph.
3. Augment flow along path P and update the residual graph.
4. Repeat steps 2-3 until you get stuck.
¨ Optimal
IRIS H.-R. JIANG
G a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
f(e) / ce
a
b d t
c
4
8
2
9 10
s 10
10 6 10
The Max-Flow Min-Cut Theorem
¨ The value of the max flow is equal to the value of the min cut.
¤ Cut: Divide V into two disjoint sets, A and B, s.t. s Î A and t Î B.
¤ Min-cut: minimize the sum of the capacities of the cut edges
directed from A to B
¨ Observation:
¤ Any s-t flow must cross from A into B at some point and uses up
some of the capacities of the cut edges.
¤ Each cut places an upper bound on the max value of an s-t flow.
Network flow
16
G
A B
27
2
21
19
max flow = min cut
17. Bipartite Matching
17
Network flow
IRIS H.-R. JIANG
If You Were a Matchmaker…
¨ Imagine you are a matchmaker
¤ One hundred female clients, and one hundred male clients
¤ Each woman has given you a list of qualities of her prince
charming
¤ Each man has given you a list of qualities of his princess snow
white
¤ Your job is to arrange one hundred suitable marriages
n Neither singlehood nor polygamy
n (The more marriages, the more money)
Network flow
18
IRIS H.-R. JIANG
Bipartite Matching
¨ Given: n men, m women and their feasible partners, G = (X, Y, E)
¨ Goal: Find the matching MÍE with the max number of marriages
¨ Perfect matching: Everyone is matched monogamously.
¤ Each man gets exactly one woman
¤ Each woman gets exactly one man
Network flow
19
X Y
matching: 3
X Y
max macthing: 4
X Y
G = (X, Y, E)
IRIS H.-R. JIANG
Bipartite Matching via Network Flow (1/2)
¨ Bipartite matching can be solved via reduction to max flow.
¤ All edges are directed from X to Y.
¤ Add nodes s and t
¤ Add edges (s, x) for all x Î X, (y, t) for all y Î Y
¤ All capacities are set to 1.
¤ Flow corresponds to matched pairs.
Network flow
20
X Y
s t
1
1
1
X Y
G = (X, Y, E)
Graph model
X Y
s t
1
1
1
18. Bipartite Matching
17
Network flow
IRIS H.-R. JIANG
If You Were a Matchmaker…
¨ Imagine you are a matchmaker
¤ One hundred female clients, and one hundred male clients
¤ Each woman has given you a list of qualities of her prince
charming
¤ Each man has given you a list of qualities of his princess snow
white
¤ Your job is to arrange one hundred suitable marriages
n Neither singlehood nor polygamy
n (The more marriages, the more money)
Network flow
18
IRIS H.-R. JIANG
Bipartite Matching
¨ Given: n men, m women and their feasible partners, G = (X, Y, E)
¨ Goal: Find the matching MÍE with the max number of marriages
¨ Perfect matching: Everyone is matched monogamously.
¤ Each man gets exactly one woman
¤ Each woman gets exactly one man
Network flow
19
X Y
matching: 3
X Y
max macthing: 4
X Y
G = (X, Y, E)
IRIS H.-R. JIANG
Bipartite Matching via Network Flow (1/2)
¨ Bipartite matching can be solved via reduction to max flow.
¤ All edges are directed from X to Y.
¤ Add nodes s and t
¤ Add edges (s, x) for all x Î X, (y, t) for all y Î Y
¤ All capacities are set to 1.
¤ Flow corresponds to matched pairs.
Network flow
20
X Y
s t
1
1
1
X Y
G = (X, Y, E)
Graph model
X Y
s t
1
1
1
19. Bipartite Matching
17
Network flow
IRIS H.-R. JIANG
If You Were a Matchmaker…
¨ Imagine you are a matchmaker
¤ One hundred female clients, and one hundred male clients
¤ Each woman has given you a list of qualities of her prince
charming
¤ Each man has given you a list of qualities of his princess snow
white
¤ Your job is to arrange one hundred suitable marriages
n Neither singlehood nor polygamy
n (The more marriages, the more money)
Network flow
18
IRIS H.-R. JIANG
Bipartite Matching
¨ Given: n men, m women and their feasible partners, G = (X, Y, E)
¨ Goal: Find the matching MÍE with the max number of marriages
¨ Perfect matching: Everyone is matched monogamously.
¤ Each man gets exactly one woman
¤ Each woman gets exactly one man
Network flow
19
X Y
matching: 3
X Y
max macthing: 4
X Y
G = (X, Y, E)
IRIS H.-R. JIANG
Bipartite Matching via Network Flow (1/2)
¨ Bipartite matching can be solved via reduction to max flow.
¤ All edges are directed from X to Y.
¤ Add nodes s and t
¤ Add edges (s, x) for all x Î X, (y, t) for all y Î Y
¤ All capacities are set to 1.
¤ Flow corresponds to matched pairs.
Network flow
20
X Y
s t
1
1
1
X Y
G = (X, Y, E)
Graph model
X Y
s t
1
1
1
20. Bipartite Matching
17
Network flow
IRIS H.-R. JIANG
If You Were a Matchmaker…
¨ Imagine you are a matchmaker
¤ One hundred female clients, and one hundred male clients
¤ Each woman has given you a list of qualities of her prince
charming
¤ Each man has given you a list of qualities of his princess snow
white
¤ Your job is to arrange one hundred suitable marriages
n Neither singlehood nor polygamy
n (The more marriages, the more money)
Network flow
18
IRIS H.-R. JIANG
Bipartite Matching
¨ Given: n men, m women and their feasible partners, G = (X, Y, E)
¨ Goal: Find the matching MÍE with the max number of marriages
¨ Perfect matching: Everyone is matched monogamously.
¤ Each man gets exactly one woman
¤ Each woman gets exactly one man
Network flow
19
X Y
matching: 3
X Y
max macthing: 4
X Y
G = (X, Y, E)
IRIS H.-R. JIANG
Bipartite Matching via Network Flow (1/2)
¨ Bipartite matching can be solved via reduction to max flow.
¤ All edges are directed from X to Y.
¤ Add nodes s and t
¤ Add edges (s, x) for all x Î X, (y, t) for all y Î Y
¤ All capacities are set to 1.
¤ Flow corresponds to matched pairs.
Network flow
20
X Y
s t
1
1
1
X Y
G = (X, Y, E)
Graph model
X Y
s t
1
1
1
21. IRIS H.-R. JIANG
Bipartite Matching via Network Flow (2/2)
¨ Residual graph Gf simplifies to:
¤ If (x, y) Ï M, then (x, y) is in Gf.
¤ If (x, y) Î M, the (y, x) is in Gf.
¨ Augmenting path simplifies to:
¤ Edge from s to an unmatched x Î X.
¤ Alternating unmatched/matched edges.
¤ Edge from unmatched y Î Y to t.
Network flow
21
X Y
s t
1/1
0/1
G Gf
X Y
s t
1
1
1
X Y
s t
1
1
1
Maximum Flows and Minimum Cuts
22
Network flow
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
23
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Ford-Fulkerson(G, s, t)
1. foreach (e Î E) do
2. f(e) = 0
3. construct Gf
4. while ($ an s-t path P in Gf) do // augmenting path
5. b = bottleneck(P, f)
6. foreach (e Î P) do
7. if (e Î E) then f(e) = f(e) + b // forward edge
8. else f(eR) = f(eR) – b // backward edge
9. update Gf
10. return f
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
IRIS H.-R. JIANG
Is It a Flow?
¨ Let f’ be the new flow after line 8 in Ford-Fulkerson algorithm. f’
is a flow in G.
¨ Pf: Verify the capacity and conservation conditions.
¤ f’ differs from f only on edges of P in G (a s-t simple path in Gf).
¤ Capacity condition: (check edges of P in G)
n If e = (u, v)ÎP is a forward edge, its residual capacity = ce - f(e).
0 £ f(e) £ f’(e) = f(e) + bottleneck(P, f) £ f(e) + (ce - f(e)) = ce
n If (u, v)ÎP is a backward edge, its residual capacity is f(e), e =
(v, u)
ce ³ f(e) ³ f’(e) = f(e) - bottleneck(P, f) ³ f(e) - f(e) = 0
¤ Conservation condition: (check nodes of P in G)
n For each internal node v on P, the amount of flow belonging to
f satisfies the conservation condition.
n Excluding f, f’ enters and exits v with bottleneck(P, f)
n f’ must satisfy conservation condition, too.
Network flow
24
v f
bottleneck(P, f)
22. IRIS H.-R. JIANG
Bipartite Matching via Network Flow (2/2)
¨ Residual graph Gf simplifies to:
¤ If (x, y) Ï M, then (x, y) is in Gf.
¤ If (x, y) Î M, the (y, x) is in Gf.
¨ Augmenting path simplifies to:
¤ Edge from s to an unmatched x Î X.
¤ Alternating unmatched/matched edges.
¤ Edge from unmatched y Î Y to t.
Network flow
21
X Y
s t
1/1
0/1
G Gf
X Y
s t
1
1
1
X Y
s t
1
1
1
Maximum Flows and Minimum Cuts
22
Network flow
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
23
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Ford-Fulkerson(G, s, t)
1. foreach (e Î E) do
2. f(e) = 0
3. construct Gf
4. while ($ an s-t path P in Gf) do // augmenting path
5. b = bottleneck(P, f)
6. foreach (e Î P) do
7. if (e Î E) then f(e) = f(e) + b // forward edge
8. else f(eR) = f(eR) – b // backward edge
9. update Gf
10. return f
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
IRIS H.-R. JIANG
Is It a Flow?
¨ Let f’ be the new flow after line 8 in Ford-Fulkerson algorithm. f’
is a flow in G.
¨ Pf: Verify the capacity and conservation conditions.
¤ f’ differs from f only on edges of P in G (a s-t simple path in Gf).
¤ Capacity condition: (check edges of P in G)
n If e = (u, v)ÎP is a forward edge, its residual capacity = ce - f(e).
0 £ f(e) £ f’(e) = f(e) + bottleneck(P, f) £ f(e) + (ce - f(e)) = ce
n If (u, v)ÎP is a backward edge, its residual capacity is f(e), e =
(v, u)
ce ³ f(e) ³ f’(e) = f(e) - bottleneck(P, f) ³ f(e) - f(e) = 0
¤ Conservation condition: (check nodes of P in G)
n For each internal node v on P, the amount of flow belonging to
f satisfies the conservation condition.
n Excluding f, f’ enters and exits v with bottleneck(P, f)
n f’ must satisfy conservation condition, too.
Network flow
24
v f
bottleneck(P, f)
23. IRIS H.-R. JIANG
Bipartite Matching via Network Flow (2/2)
¨ Residual graph Gf simplifies to:
¤ If (x, y) Ï M, then (x, y) is in Gf.
¤ If (x, y) Î M, the (y, x) is in Gf.
¨ Augmenting path simplifies to:
¤ Edge from s to an unmatched x Î X.
¤ Alternating unmatched/matched edges.
¤ Edge from unmatched y Î Y to t.
Network flow
21
X Y
s t
1/1
0/1
G Gf
X Y
s t
1
1
1
X Y
s t
1
1
1
Maximum Flows and Minimum Cuts
22
Network flow
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
23
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Ford-Fulkerson(G, s, t)
1. foreach (e Î E) do
2. f(e) = 0
3. construct Gf
4. while ($ an s-t path P in Gf) do // augmenting path
5. b = bottleneck(P, f)
6. foreach (e Î P) do
7. if (e Î E) then f(e) = f(e) + b // forward edge
8. else f(eR) = f(eR) – b // backward edge
9. update Gf
10. return f
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
IRIS H.-R. JIANG
Is It a Flow?
¨ Let f’ be the new flow after line 8 in Ford-Fulkerson algorithm. f’
is a flow in G.
¨ Pf: Verify the capacity and conservation conditions.
¤ f’ differs from f only on edges of P in G (a s-t simple path in Gf).
¤ Capacity condition: (check edges of P in G)
n If e = (u, v)ÎP is a forward edge, its residual capacity = ce - f(e).
0 £ f(e) £ f’(e) = f(e) + bottleneck(P, f) £ f(e) + (ce - f(e)) = ce
n If (u, v)ÎP is a backward edge, its residual capacity is f(e), e =
(v, u)
ce ³ f(e) ³ f’(e) = f(e) - bottleneck(P, f) ³ f(e) - f(e) = 0
¤ Conservation condition: (check nodes of P in G)
n For each internal node v on P, the amount of flow belonging to
f satisfies the conservation condition.
n Excluding f, f’ enters and exits v with bottleneck(P, f)
n f’ must satisfy conservation condition, too.
Network flow
24
v f
bottleneck(P, f)
24. IRIS H.-R. JIANG
Bipartite Matching via Network Flow (2/2)
¨ Residual graph Gf simplifies to:
¤ If (x, y) Ï M, then (x, y) is in Gf.
¤ If (x, y) Î M, the (y, x) is in Gf.
¨ Augmenting path simplifies to:
¤ Edge from s to an unmatched x Î X.
¤ Alternating unmatched/matched edges.
¤ Edge from unmatched y Î Y to t.
Network flow
21
X Y
s t
1/1
0/1
G Gf
X Y
s t
1
1
1
X Y
s t
1
1
1
Maximum Flows and Minimum Cuts
22
Network flow
IRIS H.-R. JIANG
Ford-Fulkerson Algorithm
Network flow
23
a
b d t
c
4
8
2
9 10
s 10
10 6 10
G
L. R. Ford & D. R. Fulkerson. Maximal flow through a network.
Canadian Journal of Mathematics (8) pp.399–404, 1956.
Ford-Fulkerson(G, s, t)
1. foreach (e Î E) do
2. f(e) = 0
3. construct Gf
4. while ($ an s-t path P in Gf) do // augmenting path
5. b = bottleneck(P, f)
6. foreach (e Î P) do
7. if (e Î E) then f(e) = f(e) + b // forward edge
8. else f(eR) = f(eR) – b // backward edge
9. update Gf
10. return f
Iteratively push flow forward and backward
via flow network and residual graph
max flow = min cut
IRIS H.-R. JIANG
Is It a Flow?
¨ Let f’ be the new flow after line 8 in Ford-Fulkerson algorithm. f’
is a flow in G.
¨ Pf: Verify the capacity and conservation conditions.
¤ f’ differs from f only on edges of P in G (a s-t simple path in Gf).
¤ Capacity condition: (check edges of P in G)
n If e = (u, v)ÎP is a forward edge, its residual capacity = ce - f(e).
0 £ f(e) £ f’(e) = f(e) + bottleneck(P, f) £ f(e) + (ce - f(e)) = ce
n If (u, v)ÎP is a backward edge, its residual capacity is f(e), e =
(v, u)
ce ³ f(e) ³ f’(e) = f(e) - bottleneck(P, f) ³ f(e) - f(e) = 0
¤ Conservation condition: (check nodes of P in G)
n For each internal node v on P, the amount of flow belonging to
f satisfies the conservation condition.
n Excluding f, f’ enters and exits v with bottleneck(P, f)
n f’ must satisfy conservation condition, too.
Network flow
24
v f
bottleneck(P, f)
25. IRIS H.-R. JIANG
Termination and Running Time (1/2)
¨ Assumption: all capacities are integers.
¨ Invariant property: Throughout Ford-Fulkerson, the flow values
{f(e): eÎE} and the residual capacities in Gf are integers.
¨ n(f’) = n(f) + bottleneck(P, f). Since bottleneck(P, f)>0, n(f’) > n(f).
¨ Pf:
¤ The first edge e of P must be an edge out of s in Gf.
¤ Since P is simple, it does not visit s again. Since G has no edges
entering s, e must be a forward edge.
¤ We increase f(e) by bottleneck(P, f) > 0, and we do not change
the flow on any other edge out of s.
¤ Therefore, n(f’) = n(f) + bottleneck(P, f). n(f’) > n(f).
Network flow
25
The flow value strictly increases
when we apply an augmentation
IRIS H.-R. JIANG
Termination and Running Time (2/2)
¨ C = åe out of s ce ³ åe out of s f(e) = n(f). Ford-Fulkerson terminates
in at most C iterations of the while loop.
¨ Pf: Each augmentation increases flow value by at least 1.
¨ Running time: O(mC)
¤ while loop: C iterations
¤ Augmentation: O(m)
¨ Q: Is Ford-Fulkerson polynomial in input size?
¨ A: No.
Network flow
26
a
b
1
s
100
100
t
100
100
G a
b
1
s
100
100
t
100
100
Gf
a
b
1
s
100
t
100
a
b
1/1
s
0/100
1/100
t
1/100
0/100
G a
b
1
s
100
99
t
99
100
Gf
1
1
a
b
s
100
t
100
1
a
b
0/1
s
1/100
1/100
t
1/100
1/100
G a
b
1
s
99
99
t
99
99
Gf
1
1
1
1
IRIS H.-R. JIANG
Choosing Good Augmenting Paths
¨ Use care when selecting augmenting paths.
¨ Choose augmenting paths with:
¤ Max bottleneck capacity.
¤ Fewest number of edges.
¤ Sufficiently large bottleneck capacity.
n r-scaling: look for paths with bottleneck capacity of at least r
Network flow
27
a
b
0/1
s
0/100
0/100
t
0/100
0/100
G a
b
1
s
100
100
t
100
100
Gf
a
s
100
t
100
a
b
0/1
s
0/100
100/100
t
0/100
100/100
G
a
b
0/1
s
100/100
100/100
t
100/100
100/100
G a
b
1
s
100
100
t
100
100
Gf
b
s
100
t
100
a
b
1
s
100
100
t
100
100
Gf
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (1/3)
¨ Max-flow min-cut theorem: The value of the max flow is equal
to the value of the min cut.
¨ Pf: We prove both simultaneously by showing:
1. There exists a cut (A, B) such that n(f) = cap(A, B).
2. Flow f is a max flow.
3. There is no augmenting path relative to f.
¨ 2. Þ 3. By contradiction.
¤ Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
Network flow
28
26. IRIS H.-R. JIANG
Termination and Running Time (1/2)
¨ Assumption: all capacities are integers.
¨ Invariant property: Throughout Ford-Fulkerson, the flow values
{f(e): eÎE} and the residual capacities in Gf are integers.
¨ n(f’) = n(f) + bottleneck(P, f). Since bottleneck(P, f)>0, n(f’) > n(f).
¨ Pf:
¤ The first edge e of P must be an edge out of s in Gf.
¤ Since P is simple, it does not visit s again. Since G has no edges
entering s, e must be a forward edge.
¤ We increase f(e) by bottleneck(P, f) > 0, and we do not change
the flow on any other edge out of s.
¤ Therefore, n(f’) = n(f) + bottleneck(P, f). n(f’) > n(f).
Network flow
25
The flow value strictly increases
when we apply an augmentation
IRIS H.-R. JIANG
Termination and Running Time (2/2)
¨ C = åe out of s ce ³ åe out of s f(e) = n(f). Ford-Fulkerson terminates
in at most C iterations of the while loop.
¨ Pf: Each augmentation increases flow value by at least 1.
¨ Running time: O(mC)
¤ while loop: C iterations
¤ Augmentation: O(m)
¨ Q: Is Ford-Fulkerson polynomial in input size?
¨ A: No.
Network flow
26
a
b
1
s
100
100
t
100
100
G a
b
1
s
100
100
t
100
100
Gf
a
b
1
s
100
t
100
a
b
1/1
s
0/100
1/100
t
1/100
0/100
G a
b
1
s
100
99
t
99
100
Gf
1
1
a
b
s
100
t
100
1
a
b
0/1
s
1/100
1/100
t
1/100
1/100
G a
b
1
s
99
99
t
99
99
Gf
1
1
1
1
IRIS H.-R. JIANG
Choosing Good Augmenting Paths
¨ Use care when selecting augmenting paths.
¨ Choose augmenting paths with:
¤ Max bottleneck capacity.
¤ Fewest number of edges.
¤ Sufficiently large bottleneck capacity.
n r-scaling: look for paths with bottleneck capacity of at least r
Network flow
27
a
b
0/1
s
0/100
0/100
t
0/100
0/100
G a
b
1
s
100
100
t
100
100
Gf
a
s
100
t
100
a
b
0/1
s
0/100
100/100
t
0/100
100/100
G
a
b
0/1
s
100/100
100/100
t
100/100
100/100
G a
b
1
s
100
100
t
100
100
Gf
b
s
100
t
100
a
b
1
s
100
100
t
100
100
Gf
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (1/3)
¨ Max-flow min-cut theorem: The value of the max flow is equal
to the value of the min cut.
¨ Pf: We prove both simultaneously by showing:
1. There exists a cut (A, B) such that n(f) = cap(A, B).
2. Flow f is a max flow.
3. There is no augmenting path relative to f.
¨ 2. Þ 3. By contradiction.
¤ Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
Network flow
28
27. IRIS H.-R. JIANG
Termination and Running Time (1/2)
¨ Assumption: all capacities are integers.
¨ Invariant property: Throughout Ford-Fulkerson, the flow values
{f(e): eÎE} and the residual capacities in Gf are integers.
¨ n(f’) = n(f) + bottleneck(P, f). Since bottleneck(P, f)>0, n(f’) > n(f).
¨ Pf:
¤ The first edge e of P must be an edge out of s in Gf.
¤ Since P is simple, it does not visit s again. Since G has no edges
entering s, e must be a forward edge.
¤ We increase f(e) by bottleneck(P, f) > 0, and we do not change
the flow on any other edge out of s.
¤ Therefore, n(f’) = n(f) + bottleneck(P, f). n(f’) > n(f).
Network flow
25
The flow value strictly increases
when we apply an augmentation
IRIS H.-R. JIANG
Termination and Running Time (2/2)
¨ C = åe out of s ce ³ åe out of s f(e) = n(f). Ford-Fulkerson terminates
in at most C iterations of the while loop.
¨ Pf: Each augmentation increases flow value by at least 1.
¨ Running time: O(mC)
¤ while loop: C iterations
¤ Augmentation: O(m)
¨ Q: Is Ford-Fulkerson polynomial in input size?
¨ A: No.
Network flow
26
a
b
1
s
100
100
t
100
100
G a
b
1
s
100
100
t
100
100
Gf
a
b
1
s
100
t
100
a
b
1/1
s
0/100
1/100
t
1/100
0/100
G a
b
1
s
100
99
t
99
100
Gf
1
1
a
b
s
100
t
100
1
a
b
0/1
s
1/100
1/100
t
1/100
1/100
G a
b
1
s
99
99
t
99
99
Gf
1
1
1
1
IRIS H.-R. JIANG
Choosing Good Augmenting Paths
¨ Use care when selecting augmenting paths.
¨ Choose augmenting paths with:
¤ Max bottleneck capacity.
¤ Fewest number of edges.
¤ Sufficiently large bottleneck capacity.
n r-scaling: look for paths with bottleneck capacity of at least r
Network flow
27
a
b
0/1
s
0/100
0/100
t
0/100
0/100
G a
b
1
s
100
100
t
100
100
Gf
a
s
100
t
100
a
b
0/1
s
0/100
100/100
t
0/100
100/100
G
a
b
0/1
s
100/100
100/100
t
100/100
100/100
G a
b
1
s
100
100
t
100
100
Gf
b
s
100
t
100
a
b
1
s
100
100
t
100
100
Gf
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (1/3)
¨ Max-flow min-cut theorem: The value of the max flow is equal
to the value of the min cut.
¨ Pf: We prove both simultaneously by showing:
1. There exists a cut (A, B) such that n(f) = cap(A, B).
2. Flow f is a max flow.
3. There is no augmenting path relative to f.
¨ 2. Þ 3. By contradiction.
¤ Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
Network flow
28
28. IRIS H.-R. JIANG
Termination and Running Time (1/2)
¨ Assumption: all capacities are integers.
¨ Invariant property: Throughout Ford-Fulkerson, the flow values
{f(e): eÎE} and the residual capacities in Gf are integers.
¨ n(f’) = n(f) + bottleneck(P, f). Since bottleneck(P, f)>0, n(f’) > n(f).
¨ Pf:
¤ The first edge e of P must be an edge out of s in Gf.
¤ Since P is simple, it does not visit s again. Since G has no edges
entering s, e must be a forward edge.
¤ We increase f(e) by bottleneck(P, f) > 0, and we do not change
the flow on any other edge out of s.
¤ Therefore, n(f’) = n(f) + bottleneck(P, f). n(f’) > n(f).
Network flow
25
The flow value strictly increases
when we apply an augmentation
IRIS H.-R. JIANG
Termination and Running Time (2/2)
¨ C = åe out of s ce ³ åe out of s f(e) = n(f). Ford-Fulkerson terminates
in at most C iterations of the while loop.
¨ Pf: Each augmentation increases flow value by at least 1.
¨ Running time: O(mC)
¤ while loop: C iterations
¤ Augmentation: O(m)
¨ Q: Is Ford-Fulkerson polynomial in input size?
¨ A: No.
Network flow
26
a
b
1
s
100
100
t
100
100
G a
b
1
s
100
100
t
100
100
Gf
a
b
1
s
100
t
100
a
b
1/1
s
0/100
1/100
t
1/100
0/100
G a
b
1
s
100
99
t
99
100
Gf
1
1
a
b
s
100
t
100
1
a
b
0/1
s
1/100
1/100
t
1/100
1/100
G a
b
1
s
99
99
t
99
99
Gf
1
1
1
1
IRIS H.-R. JIANG
Choosing Good Augmenting Paths
¨ Use care when selecting augmenting paths.
¨ Choose augmenting paths with:
¤ Max bottleneck capacity.
¤ Fewest number of edges.
¤ Sufficiently large bottleneck capacity.
n r-scaling: look for paths with bottleneck capacity of at least r
Network flow
27
a
b
0/1
s
0/100
0/100
t
0/100
0/100
G a
b
1
s
100
100
t
100
100
Gf
a
s
100
t
100
a
b
0/1
s
0/100
100/100
t
0/100
100/100
G
a
b
0/1
s
100/100
100/100
t
100/100
100/100
G a
b
1
s
100
100
t
100
100
Gf
b
s
100
t
100
a
b
1
s
100
100
t
100
100
Gf
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (1/3)
¨ Max-flow min-cut theorem: The value of the max flow is equal
to the value of the min cut.
¨ Pf: We prove both simultaneously by showing:
1. There exists a cut (A, B) such that n(f) = cap(A, B).
2. Flow f is a max flow.
3. There is no augmenting path relative to f.
¨ 2. Þ 3. By contradiction.
¤ Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
Network flow
28
29. IRIS H.-R. JIANG
0
Max-Flow Min-Cut Theorem (2/3)
¨ Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we
have n(f) £ cap(A, B).
¨ Pf:
¤ n(f) = åe out of s f(e)
= åe out of s f(e) - åe into s f(e)
= åe out of s f(e) - åe into s f(e) + åvÎA (åe out of v f(e) - åe into v f(e))
(internal edges in A: f(e) appears once “+” & once “-”)
= åe out of A f(e) - åe into A f(e)
£ åe out of A f(e)
£ åe out of A ce
= cap(A, B).
¨ 1. Þ 2. This was the corollary to weak duality lemma.
¤ All edges into A are completely unused.
Network flow
29
G
A B
27
2
a
b d t
c
4
8
2
9 10
s 10
10 6 10
19 21
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (3/3)
¨ 3. Þ 1.
¤ Let f be a flow without augmenting paths.
¤ Let A be set of nodes reachable from s in residual graph.
¤ By definition of A, s Î A.
¤ By definition of f, t Ï A.
¤ n(f) = åe out of s f(e)
= åe out of A f(e) - åe into A f(e)
= åe out of A f(e) // f(e) for e into A = 0, otherwise, s can reach out
= åe out of A ce
= cap(A, B).
Network flow
30
a
b d t
c
1
2
s 1
6 1
Gf
10 7
10
9
9
9
3
1
A B
G
a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10
30. IRIS H.-R. JIANG
0
Max-Flow Min-Cut Theorem (2/3)
¨ Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we
have n(f) £ cap(A, B).
¨ Pf:
¤ n(f) = åe out of s f(e)
= åe out of s f(e) - åe into s f(e)
= åe out of s f(e) - åe into s f(e) + åvÎA (åe out of v f(e) - åe into v f(e))
(internal edges in A: f(e) appears once “+” & once “-”)
= åe out of A f(e) - åe into A f(e)
£ åe out of A f(e)
£ åe out of A ce
= cap(A, B).
¨ 1. Þ 2. This was the corollary to weak duality lemma.
¤ All edges into A are completely unused.
Network flow
29
G
A B
27
2
a
b d t
c
4
8
2
9 10
s 10
10 6 10
19 21
IRIS H.-R. JIANG
Max-Flow Min-Cut Theorem (3/3)
¨ 3. Þ 1.
¤ Let f be a flow without augmenting paths.
¤ Let A be set of nodes reachable from s in residual graph.
¤ By definition of A, s Î A.
¤ By definition of f, t Ï A.
¤ n(f) = åe out of s f(e)
= åe out of A f(e) - åe into A f(e)
= åe out of A f(e) // f(e) for e into A = 0, otherwise, s can reach out
= åe out of A ce
= cap(A, B).
Network flow
30
a
b d t
c
1
2
s 1
6 1
Gf
10 7
10
9
9
9
3
1
A B
G
a
b d t
c
3/4
7/8
0/2
9/9 10/10
s 9/10
10/10 6/6 9/10