64MaxFlow Export
64MaxFlow Export
64MaxFlow Export
capacity
10
15
15
15
10
10
15
10
16
3
Mincut problem
Def. A st-cut (cut) is a partition of the vertices into two disjoint sets,
with s in one set A and t in the other set B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
10
15
capacity = 10 + 5 + 15 = 30
4
Mincut problem
Def. A st-cut (cut) is a partition of the vertices into two disjoint sets,
with s in one set A and t in the other set B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
10
t
don't count edges
from B to A
capacity = 10 + 8 + 16 = 34
16
5
Mincut problem
Def. A st-cut (cut) is a partition of the vertices into two disjoint sets,
with s in one set A and t in the other set B.
Def. Its capacity is the sum of the capacities of the edges from A to B.
Minimum st-cut (mincut) problem. Find a cut of minimum capacity.
10
10
capacity = 10 + 8 + 10 = 28
6
Maxflow problem
Input. An edge-weighted digraph, source vertex s, and target vertex t.
each edge has a
positive capacity
capacity
10
15
15
15
10
10
15
10
16
9
Maxflow problem
Def. An st-flow (flow) is an assignment of values to the edges such that:
capacity
flow
inflow at v = 5 + 5 + 0 = 10
5/9
10
10
5
0/4
5/5
10
15
0/4
outflow at v = 10 + 0
/1
0 / 15
5/8
/6
0 / 15
10
10 / 10
10
= 10
10
10 / 16
10
Maxflow problem
Def. An st-flow (flow) is an assignment of values to the edges such that:
5/9
10
10
5
0/4
15
0 / 15
5/8
5/5
10
/1
0/4
/6
10
10 / 10
0 / 15
10
value = 5 + 10 + 10 = 25
10
10 / 16
11
Maxflow problem
Def. An st-flow (flow) is an assignment of values to the edges such that:
10
10
2
0/4
15
0 / 15
8/8
5/5
13
/1
0/4
/6
10
10 / 10
0 / 15
10
value = 8 + 10 + 10 = 28
10
13 / 16
12
flow
capacity
13
facebook graph
14
Summary
Input. A weighted digraph, source vertex s, and target vertex t.
Mincut problem. Find a cut of minimum capacity.
Maxflow problem. Find a flow of maximum value.
8/9
2
10
10
0/4
15
0 / 15
8/8
5/5
13
/1
0/4
/6
10
10 / 10
0 / 15
10
10
10
10
13 / 16
value of flow = 28
capacity of cut = 28
Ford-Fulkerson algorithm
Initialization. Start with 0 flow.
flow
capacity
initialization
0/9
10
0/4
0/5
15
/1
0 / 15
0/4
/6
10
0 / 10
0/8
0 / 15
value of flow
10
0 / 16
17
10 /
0
10
0/4
0/5
15
10
0
/1
5
0 / 15
0/4
/6
10
10
0 / 10
0/8
0 / 15
0 + 10 = 10
10
0 / 16
18
10
10
0/4
0/5
10
/1
0 / 15
10
0/8
10 / 10
10
10 + 10 = 20
10
/
15
0/4
/6
0 / 15
10
10
0 / 16
19
backward edge
(not empty)
0/9
5
10
10
0/4
0/5
10
15
10
/1
5
0 / 15
0/8
0/4
/6
/
10
10 / 10
0 / 15
10
20 + 5 = 25
10
10 / 16
20
backward edge
(not empty)
5/9
2
10
10
0/4
/1
5
5/5
5/8
13
10
15
0/4
0
/6
0 / 15
/
10
10 / 10
0 / 15
10
25 + 3 = 28
10
13
10
/ 16
21
10
10
0/4
5/5
13
15
/1
0 / 15
/6
10
10 / 10
8/8
0/4
0 / 15
10
28
10
Ford-Fulkerson algorithm
Ford-Fulkerson algorithm
Start with 0 flow.
While there exists an augmenting path:
- find an augmenting path
- compute bottleneck capacity
- increase flow on that path by bottleneck capacity
Questions.
5/9
10
10
5
0/4
15
0 / 15
5/8
5/5
10
/1
0/4
/6
10
10 / 10
0 / 15
10
value of flow = 25
10
10 / 16
25
5/9
10
10
5
0/4
15
0 / 15
5/8
5/5
10
/1
0/4
/6
10
10 / 10
0 / 15
10
value of flow = 25
10
10 / 16
26
5/9
edges from B to A
10
10
5
0/4
15
0 / 15
5/8
5/5
10
/1
0/4
/6
10
10 / 10
0 / 15
10
value of flow = 25
10
10 / 16
27
Base case: B = { t }.
Induction step: remains true by local equilibrium when moving
any vertex from A to B.
28
flow-value lemma
8/9
2
10
10
0/4
15
0 / 15
0/4
/6
10
9 / 10
7/8
5/5
12
/1
0 / 15
10
10
10
15
12 / 16
value of flow = 27
capacity of cut = 30
29
Maxflow-mincut theorem
Augmenting path theorem. A flow f is a maxflow iff no augmenting paths.
Maxflow-mincut theorem. Value of the maxflow = capacity of mincut.
Pf. The following three conditions are equivalent for any flow f :
i. There exists a cut whose capacity equals the value of the flow f.
ii. f is a maxflow.
iii. There is no augmenting path with respect to f.
[i
ii ]
by assumption
30
Maxflow-mincut theorem
Augmenting path theorem. A flow f is a maxflow iff no augmenting paths.
Maxflow-mincut theorem. Value of the maxflow = capacity of mincut.
Pf. The following three conditions are equivalent for any flow f :
i. There exists a cut whose capacity equals the value of the flow f.
ii. f is a maxflow.
iii. There is no augmenting path with respect to f.
[ ii
~ii.
31
Maxflow-mincut theorem
Augmenting path theorem. A flow f is a maxflow iff no augmenting paths.
Maxflow-mincut theorem. Value of the maxflow = capacity of mincut.
Pf. The following three conditions are equivalent for any flow f :
i. There exists a cut whose capacity equals the value of the flow f.
ii. f is a maxflow.
iii. There is no augmenting path with respect to f.
[ iii
i]
By definition of cut, s is in A.
Since no augmenting path, t is in B.
Capacity of cut = net flow across cut
= value of flow f.
10
10
2
0/4
15
0 / 15
8/8
5/5
13
/1
5
3/4
6
/6
10
10 / 10
0 / 15
10
10
forward edge
(not full)
33
Ford-Fulkerson algorithm
Ford-Fulkerson algorithm
Start with 0 flow.
While there exists an augmenting path:
- find an augmenting path
- compute bottleneck capacity
- increase flow on that path by bottleneck capacity
Questions.
35
36
10
0
10
s
flow
capacity
0
1
0
0
10
0
10
t
37
1st iteration
10
0
10
0
0
10
0
10
t
38
2nd iteration
10
0
10
10
0
0
10
0
t
39
3rd iteration
10
0
10
1
0
10
0
10
t
40
4th iteration
10
0
10
10
0
1
10
0
t
41
...
42
199th iteration
10
99 0
10
99
10
10
99 0
99
10
10
0
0
t
43
200th iteration
10
10
0
10
99 0
10
10
0
10
99 0
10
10 0
0
t
44
10
10
0
10 0
10
0
1
10
10 0
0
10
10
0
t
45
augmenting path
number of paths
implementation
random path
EU
randomized queue
DFS path
EU
stack (DFS)
shortest path
EV
queue (BFS)
fattest path
E ln(E U)
priority queue
46