Title: Flows
1(No Transcript)
2Flows
t
s
source
sink
3Flows
edge-weights capacities
2
3
5
7
4
4
2
2
source
sink
4Flows
edge-weights capacities
2
2
2
3
2
5
7
2
4
4
2
2
2
2
4 units of flow
source
sink
5Flows
edge-weights capacities
2
2
2
3
4
5
7
2
2
4
4
4
2
2
2
6 units of flow
source
sink
6Flows
edge-weights capacities
2
2
3
3
5
5
7
3
2
1
4
4
4
2
1
2
7 units of flow
source
sink
7Optimal?
? a larger flow?
8Cuts
capacity of a cut cap(C)? c(u,v)
C
s
u?C v?V-C
C ? V s ? C t ? V-C
for any cut and any flow
flow ? cut
?
max-flow ? min-cut
9Flows
edge-weights capacities
2
2
5
5
3
4
FLOW CONSERVATION
10Skew symmetry
edge-weights capacities
2
2
5
5
3
4
x
-x
FLOW CONSERVATION
11Flows
edge-weights capacities
2
2
-5
5
3
? f(u,v) 0
v?V
4
x
-x
FLOW CONSERVATION
12Flow formal definition
FLOW CONSERVATION CAPACITY CONSTRAINTS
? f(u,v) 0
v?V
f(u,v) ? c(u,v)
SKEW SYMMETRY
f(u,v) - f(v,u)
13Max-flow problem
INPUT directed graph G(V,E), source s?V, sink
t?V a capacity c(e) for each edge
e?E OUTPUT maximum flow from s to t
14Max-flow problem
F ? zero-flow while can improve F improve F
15Max-flow problem
improving can decrease flow on some edges
16Augmenting path
1
1
1
1
-1
17Augmenting path
1
1
1
1
1
18Augmenting path
? can improve the flow
Ford-Fulkerson algorithm
F ? zero-flow while ? augmenting path p
improve F along p
19Residual capacity
f(u,v)
c(u,v)
r(u,v) c(u,v) f(u,v)
makes sense for negative f(u,v)
20Residual network
2
2
5
2
3
7
2
4
2
4
4
4
2
2
2
21Residual network
2
2
2
3
9
7
2
1
2
4
4
4
2
2
2
22Residual network
2
2
2
3
9
7
2
1
2
4
4
4
2
2
2
23Residual network
4
2
3
9
7
2
1
2
4
4
4
2
2
2
24Residual network
4
2
3
9
7
2
1
2
4
4
4
2
2
2
25Residual network
4
5
9
7
2
1
1
2
4
4
4
2
2
2
26Residual network
4
5
6
9
7
1
1
7
2
8
4
4
Is there an augmenting path? Is there a path from
s to t in the residual network?
27Correct ?
F ? zero-flow while ? augmenting path p
improve F along p
28Correct ?
F ? zero-flow while ? augmenting path p
improve F along p
YES
Theorem no augmenting path ? max-flow
29Theorem no augmenting path ? max-flow
Proof
no augmenting path ? no path
from s to t in the residual network
s
t
30Theorem no augmenting path ? max-flow
Proof
no augmenting path ? no path
from s to t in the residual network
s
t
vertices to which we can get from s
31Theorem no augmenting path ? max-flow
Proof
no augmenting path ? no path
from s to t in the residual network
all edges from C to V-C saturated
C
s
t
vertices to which we can get from s
32Theorem no augmenting path ? max-flow
Theorem 2 max-flow min-cut
33Is there an augmenting path? Is there a path from
s to t in the residual network?
time O(E)
F ? zero-flow while ? augmenting path p
improve F along p
time ?
34F ? zero-flow while ? augmenting path p
improve F along p
100
100
0
0
1
0
0
0
100
100
35F ? zero-flow while ? augmenting path p
improve F along p
100
100
0
0
1
0
0
0
100
100
36F ? zero-flow while ? augmenting path p
improve F along p
100
100
1
0
1
1
0
1
100
100
37F ? zero-flow while ? augmenting path p
improve F along p
100
100
1
0
1
1
0
1
100
100
38F ? zero-flow while ? augmenting path p
improve F along p
100
100
1
0
1
1
0
1
100
100
39F ? zero-flow while ? augmenting path p
improve F along p
100
100
1
2
1
-1
2
1
100
100
40F ? zero-flow while ? augmenting path p
improve F along p
100
100
1
2
1
-1
2
1
100
100
41F ? zero-flow while ? augmenting path p
improve F along p
100
100
3
2
1
1
2
3
100
100
42F ? zero-flow while ? augmenting path p
improve F along p
Assume that the capacities are integers. Then the
number of augementations is bounded by
F (max-flow)
running time O(E F)
43F ? zero-flow while ? augmenting path p
improve F along p
can a good choice of p improve the algorithm?
running time O(E F)
44F ? zero-flow while ? augmenting path p
improve F along p
1. choose path p which increases the flow the
most (i.e., p has the maximum bottleneck capacity)
2. choose path p which has the fewest number of
edges
451. choose path p which increases the flow the
most (i.e., p has the maximum bottleneck capacity)
THEOREM number of augmenting steps
O(E log F)
46Graph G flow f in G
Residual network Gf
fflow in Gf
Claim hff is a flow in G
SKEW SYMMETRY h(u,v)f(u,v)f(u,v)-f(v,u)-f(v,
u) -
(f(v,u) f(v,u)) - h(v,u)
FLOW CONSERVATION ?u h(u,v) ?u
(f(u,v)f(u,v))
?u f(u,v) ?u f(u,v) 0
47Graph G flow f in G
Residual network Gf
fflow in Gf
Claim hff is a flow in G
CAPACITY CONSTRAINTS
f(u,v)? c(u,v)-f(u,v) ? h(u,v)f(u,v)f(u,v) ?
c(u,v)
48Graph G flow f in G
Residual network Gf
fflow in Gf
flow h in G
Claim fh-g is a flow in Gf
CAPACITY CONSTRAINTS
f(u,v) h(u,v)-f(u,v)?c(u,v)-f(u,v)
49Claim any flow f in G is a sum of at most E
path flows
Induction on the number of non-zero edges in f
50Claim any flow f in G is a sum of at most e?
Ef(e)?0 path flows
Induction on the number of non-zero edges in f
f flow
G with capacities c(u,v)max0,f(u,v) p
augmenting path from zero flow in G p has
bottleneck edge ? f-p has less non-zero edges
than f
f p (f-p)
51- choose path p which increases the flow the most
(i.e., - p has the maximum bottleneck capacity)
THEOREM number of augmenting steps O(E log F)
Claim any flow f in G is a sum of at most E
path flows
Graph G flow f in G
Residual network Gf
ff-f
? path with bottleneck capacity ? f/E
max-flow f in G
52- choose path p which increases the flow the most
(i.e., - p has the maximum bottleneck capacity)
THEOREM number of augmenting steps O(E log F)
max-flow in the residual graph decreases by a
factor of at least (1-1/E)
Graph G flow f in G
Residual network Gf
ff-f
? path with bottleneck capacity ? f/E
max-flow f in G
532. choose path p which has the fewest number of
edges
THEOREM number of augmenting steps
O(E V)
542. choose path p which has the fewest number of
edges
level graph BFS in the residual network
552. choose path p which has the fewest number of
edges
level graph BFS in the residual network
562. choose path p which has the fewest number of
edges
count edges in the residual graph which are on a
path of length d from s to t
- one such edge saturated
- no new introduced
57Plain Ford-Fulkerson O(E F) Maximum bottleneck
capacity O( (EV log V) E log F ) Fewest
edges O(E2 V)
58Max-matching in bipartite graphs
59Max-matching in bipartite graphs
60Max-matching in bipartite graphs
solution using max-flow
all edge weights 1
s
t
61Max-matching in bipartite graphs
solution using max-flow
Plain Ford-Fulkerson O(E F) Maximum bottleneck
capacity O( (EV log V) E log F ) Fewest
edges O(E2 V)
which one to use?