SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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)
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)
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)
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)
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
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
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
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
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
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

Más contenido relacionado

Similar a algorithm_7network_flow.pdf

Open channel flow
Open channel flowOpen channel flow
Open channel flowAdnan Aslam
 
Open Channel Flow of irrigation and Drainage Department .ppt
Open Channel Flow of irrigation and Drainage Department .pptOpen Channel Flow of irrigation and Drainage Department .ppt
Open Channel Flow of irrigation and Drainage Department .pptiphone4s4
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Traian Rebedea
 
Network Information Processing
Network Information ProcessingNetwork Information Processing
Network Information ProcessingReza Rahimi
 
Gradvariedflow
GradvariedflowGradvariedflow
Gradvariedflowgoliad1978
 
Chapter 6 energy and momentum principles
Chapter 6 energy and momentum principlesChapter 6 energy and momentum principles
Chapter 6 energy and momentum principlesBinu Karki
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network TalkImane Haf
 
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...AIRCC Publishing Corporation
 
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docxeugeniadean34240
 
Energy and momentum principles in open channel flow
Energy and momentum principles in open channel flowEnergy and momentum principles in open channel flow
Energy and momentum principles in open channel flowBinu Khadka
 
04_ex_flow_net_seepage_GDS.pdf (1).pdf
04_ex_flow_net_seepage_GDS.pdf (1).pdf04_ex_flow_net_seepage_GDS.pdf (1).pdf
04_ex_flow_net_seepage_GDS.pdf (1).pdfshiva89702
 
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2zukun
 
Fet full explanations
Fet full explanationsFet full explanations
Fet full explanationsSridhar Done
 

Similar a algorithm_7network_flow.pdf (20)

Open channel flow
Open channel flowOpen channel flow
Open channel flow
 
maxflow.ppt
maxflow.pptmaxflow.ppt
maxflow.ppt
 
Open Channel Flow of irrigation and Drainage Department .ppt
Open Channel Flow of irrigation and Drainage Department .pptOpen Channel Flow of irrigation and Drainage Department .ppt
Open Channel Flow of irrigation and Drainage Department .ppt
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12
 
OPEN CHANNEL FOLW BY AKASH V. MODI
OPEN CHANNEL FOLW BY AKASH V. MODIOPEN CHANNEL FOLW BY AKASH V. MODI
OPEN CHANNEL FOLW BY AKASH V. MODI
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
 
Hidro
HidroHidro
Hidro
 
Fountains&pumps&turbines
 Fountains&pumps&turbines Fountains&pumps&turbines
Fountains&pumps&turbines
 
Network Information Processing
Network Information ProcessingNetwork Information Processing
Network Information Processing
 
Gradvariedflow
GradvariedflowGradvariedflow
Gradvariedflow
 
Chapter 6 energy and momentum principles
Chapter 6 energy and momentum principlesChapter 6 energy and momentum principles
Chapter 6 energy and momentum principles
 
Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
 
Chap2 s11b
Chap2 s11bChap2 s11b
Chap2 s11b
 
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
On the Implementation of Goldberg's Maximum Flow Algorithm in Extended Mixed ...
 
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
23Network FlowsAuthor Arthur M. Hobbs, Department of .docx
 
10me36b-unit6.ppt
10me36b-unit6.ppt10me36b-unit6.ppt
10me36b-unit6.ppt
 
Energy and momentum principles in open channel flow
Energy and momentum principles in open channel flowEnergy and momentum principles in open channel flow
Energy and momentum principles in open channel flow
 
04_ex_flow_net_seepage_GDS.pdf (1).pdf
04_ex_flow_net_seepage_GDS.pdf (1).pdf04_ex_flow_net_seepage_GDS.pdf (1).pdf
04_ex_flow_net_seepage_GDS.pdf (1).pdf
 
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2
ECCV2008: MAP Estimation Algorithms in Computer Vision - Part 2
 
Fet full explanations
Fet full explanationsFet full explanations
Fet full explanations
 

Más de HsuChi Chen

algorithm_6dynamic_programming.pdf
algorithm_6dynamic_programming.pdfalgorithm_6dynamic_programming.pdf
algorithm_6dynamic_programming.pdfHsuChi Chen
 
algorithm_1introdunction.pdf
algorithm_1introdunction.pdfalgorithm_1introdunction.pdf
algorithm_1introdunction.pdfHsuChi Chen
 
algorithm_9linear_programming.pdf
algorithm_9linear_programming.pdfalgorithm_9linear_programming.pdf
algorithm_9linear_programming.pdfHsuChi Chen
 
algorithm_4greedy_algorithms.pdf
algorithm_4greedy_algorithms.pdfalgorithm_4greedy_algorithms.pdf
algorithm_4greedy_algorithms.pdfHsuChi Chen
 
algorithm_3graphs.pdf
algorithm_3graphs.pdfalgorithm_3graphs.pdf
algorithm_3graphs.pdfHsuChi Chen
 
algorithm_2algorithm_analysis.pdf
algorithm_2algorithm_analysis.pdfalgorithm_2algorithm_analysis.pdf
algorithm_2algorithm_analysis.pdfHsuChi Chen
 
algorithm_8beyond_polynomial_running_times.pdf
algorithm_8beyond_polynomial_running_times.pdfalgorithm_8beyond_polynomial_running_times.pdf
algorithm_8beyond_polynomial_running_times.pdfHsuChi Chen
 
algorithm_5divide_and_conquer.pdf
algorithm_5divide_and_conquer.pdfalgorithm_5divide_and_conquer.pdf
algorithm_5divide_and_conquer.pdfHsuChi Chen
 
algorithm_0introdunction.pdf
algorithm_0introdunction.pdfalgorithm_0introdunction.pdf
algorithm_0introdunction.pdfHsuChi Chen
 
期末專題報告書
期末專題報告書期末專題報告書
期末專題報告書HsuChi Chen
 
單晶片期末專題-報告二
單晶片期末專題-報告二單晶片期末專題-報告二
單晶片期末專題-報告二HsuChi Chen
 
單晶片期末專題-報告一
單晶片期末專題-報告一單晶片期末專題-報告一
單晶片期末專題-報告一HsuChi Chen
 
模組化課程生醫微製程期末報告
模組化課程生醫微製程期末報告模組化課程生醫微製程期末報告
模組化課程生醫微製程期末報告HsuChi Chen
 
單晶片期末專題-初步想法
單晶片期末專題-初步想法單晶片期末專題-初步想法
單晶片期末專題-初步想法HsuChi Chen
 

Más de HsuChi Chen (14)

algorithm_6dynamic_programming.pdf
algorithm_6dynamic_programming.pdfalgorithm_6dynamic_programming.pdf
algorithm_6dynamic_programming.pdf
 
algorithm_1introdunction.pdf
algorithm_1introdunction.pdfalgorithm_1introdunction.pdf
algorithm_1introdunction.pdf
 
algorithm_9linear_programming.pdf
algorithm_9linear_programming.pdfalgorithm_9linear_programming.pdf
algorithm_9linear_programming.pdf
 
algorithm_4greedy_algorithms.pdf
algorithm_4greedy_algorithms.pdfalgorithm_4greedy_algorithms.pdf
algorithm_4greedy_algorithms.pdf
 
algorithm_3graphs.pdf
algorithm_3graphs.pdfalgorithm_3graphs.pdf
algorithm_3graphs.pdf
 
algorithm_2algorithm_analysis.pdf
algorithm_2algorithm_analysis.pdfalgorithm_2algorithm_analysis.pdf
algorithm_2algorithm_analysis.pdf
 
algorithm_8beyond_polynomial_running_times.pdf
algorithm_8beyond_polynomial_running_times.pdfalgorithm_8beyond_polynomial_running_times.pdf
algorithm_8beyond_polynomial_running_times.pdf
 
algorithm_5divide_and_conquer.pdf
algorithm_5divide_and_conquer.pdfalgorithm_5divide_and_conquer.pdf
algorithm_5divide_and_conquer.pdf
 
algorithm_0introdunction.pdf
algorithm_0introdunction.pdfalgorithm_0introdunction.pdf
algorithm_0introdunction.pdf
 
期末專題報告書
期末專題報告書期末專題報告書
期末專題報告書
 
單晶片期末專題-報告二
單晶片期末專題-報告二單晶片期末專題-報告二
單晶片期末專題-報告二
 
單晶片期末專題-報告一
單晶片期末專題-報告一單晶片期末專題-報告一
單晶片期末專題-報告一
 
模組化課程生醫微製程期末報告
模組化課程生醫微製程期末報告模組化課程生醫微製程期末報告
模組化課程生醫微製程期末報告
 
單晶片期末專題-初步想法
單晶片期末專題-初步想法單晶片期末專題-初步想法
單晶片期末專題-初步想法
 

Último

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Último (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

algorithm_7network_flow.pdf

  • 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