64MaxFlow Export

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Mincut 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
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

Mincut application (RAND 1950s)


"Free world" goal. Cut supplies (if cold war turns into real war).

rail network connecting Soviet Union with Eastern European countries


(map declassified
by Pentagon in 1999)
Figure 2
From Harris and Ross [1955]: Schematic diagram of the railway network of the Western So-

Potential mincut application (2010s)


Government-in-powers goal. Cut off communication to set of people.

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 constraint: 0 edge's flow edge's capacity.


Local equilibrium: inflow = outflow at every vertex (except s and t).

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:

Capacity constraint: 0 edge's flow edge's capacity.


Local equilibrium: inflow = outflow at every vertex (except s and t).
Def. The value of a flow is the inflow at t.
we assume no edges point to s or from t

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:

Capacity constraint: 0 edge's flow edge's capacity.


Local equilibrium: inflow = outflow at every vertex (except s and t).
Def. The value of a flow is the inflow at t.
Maximum st-flow (maxflow) problem. Find a flow of maximum value.
8/9

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

Maxflow application (Tolsto 1930s)


Soviet Union goal. Maximize flow of supplies to Eastern Europe.

flow
capacity

rail network connecting Soviet Union with Eastern European countries


(map declassified
by Pentagon
in 1999)
Figure
2
From Harris and Ross [1955]: Schematic diagram of the railway network of the Western So-

13

Potential maxflow application (2010s)


"Free world" goal. Maximize flow of information to specified set of people.

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

Remarkable fact. These two problems are dual!


15

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

Idea: increase flow along augmenting paths


Augmenting path. Find an undirected path from s to t such that:

Can increase flow on forward edges (not full).


Can decrease flow on backward edge (not empty).
1st augmenting path
bottleneck capacity = 10
0/9

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

Idea: increase flow along augmenting paths


Augmenting path. Find an undirected path from s to t such that:

Can increase flow on forward edges (not full).


Can decrease flow on backward edge (not empty).
2nd augmenting path
0/9

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

Idea: increase flow along augmenting paths


Augmenting path. Find an undirected path from s to t such that:

Can increase flow on forward edges (not full).


Can decrease flow on backward edge (not empty).
3rd augmenting path

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

Idea: increase flow along augmenting paths


Augmenting path. Find an undirected path from s to t such that:

Can increase flow on forward edges (not full).


Can decrease flow on backward edge (not empty).
4th augmenting path

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

Idea: increase flow along augmenting paths


Termination. All paths from s to t are blocked by either a

Full forward edge.


Empty backward edge.
no more augmenting paths
8/9

10

10

0/4

5/5

13

15

/1

0 / 15

/6

10

10 / 10

8/8

0/4

0 / 15

10

28

10

full forward edge


13 / 16

empty backward edge


22

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.

How to compute a mincut?


How to find an augmenting path?
If FF terminates, does it always compute a maxflow?
Does FF always terminate? If so, after how many augmentations?
23

Relationship between flows and cuts


Def. The net flow across a cut (A, B) is the sum of the flows on its edges
from A to B minus the sum of the flows on its edges from B to A.

net flow across cut = 5 + 10 + 10 = 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
25

Relationship between flows and cuts


Def. The net flow across a cut (A, B) is the sum of the flows on its edges
from A to B minus the sum of the flows on its edges from B to A.

net flow across cut = 10 + 5 + 10 = 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

Relationship between flows and cuts


Def. The net flow across a cut (A, B) is the sum of the flows on its edges
from A to B minus the sum of the flows on its edges from B to A.

net flow across cut = (10 + 10 + 5 + 10 + 0 + 0) (5 + 5 + 0 + 0) = 25

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

Relationship between flows and cuts


Flow-value lemma. Let f be any flow and let (A, B) be any cut. Then, the net
flow across (A, B) equals the value of f.
Intuition. Conservation of flow.
Pf. By induction on the size of B.

Base case: B = { t }.
Induction step: remains true by local equilibrium when moving
any vertex from A to B.

Corollary. Outflow from s = inflow to t = value of flow.

28

Relationship between flows and cuts


Weak duality. Let f be any flow and let (A, B) be any cut.
Then, the value of the flow the capacity of the cut.
Pf. Value of flow f = net flow across cut (A, B) capacity of cut (A, B).
flow bounded by capacity

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 ]

Suppose that (A, B) is a cut with capacity equal to the value of f.


Then, the value of any flow f ' capacity of (A, B) = value of f.
Thus, f is a maxflow.
weak duality

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

iii ] We prove contrapositive: ~iii

~ii.

Suppose that there is an augmenting path with respect to f.


Can improve flow f by sending flow along this path.
Thus, f is not a maxflow.

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]

Suppose that there is no augmenting path with respect to f.

Let (A, B) be a cut where A is the set of vertices connected to s by an


undirected path with no full forward or empty backward edges.

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.

forward edges full; backward edges empty


flow-value lemma
32

Computing a mincut from a maxflow


To compute mincut (A, B) from maxflow f :

By augmenting path theorem, no augmenting paths with respect to f.


Compute A = set of vertices connected to s by an undirected path
with no full forward or empty backward edges.
8/9

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

full forward edge


16 / 16

forward edge
(not full)

empty backward edge


backward edge
(not empty)

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.

How to compute a mincut? Easy.


How to find an augmenting path? BFS works well.
If FF terminates, does it always compute a maxflow? Yes.
Does FF always terminate? If so, after how many augmentations?
yes, provided edge capacities are integers
(or augmenting paths are chosen carefully)

requires clever analysis

35

Ford-Fulkerson algorithm with integer capacities


Important special case. Edge capacities are integers between 1 and U.
flow on each edge is an integer

Invariant. The flow is integer-valued throughout Ford-Fulkerson.


Pf. [by induction]

Bottleneck capacity is an integer.


Flow on an edge increases/decreases by bottleneck capacity.
Proposition. Number of augmentations the value of the maxflow.
Pf. Each augmentation increases the value by at least 1.

critical for some applications (stay tuned)

Integrality theorem. There exists an integer-valued maxflow.


Pf. Ford-Fulkerson terminates and maxflow that it finds is integer-valued.

36

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

initialize with 0 flow

10

0
10

s
flow
capacity

0
1

0
0

10
0

10

t
37

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

1st iteration

10

0
10

0
0

10
0

10

t
38

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

2nd iteration

10

0
10

10
0

0
10
0

t
39

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

3rd iteration

10

0
10

1
0

10
0

10

t
40

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

4th iteration

10

0
10

10
0

1
10
0

t
41

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

...
42

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

199th iteration

10

99 0
10

99

10

10

99 0

99
10
10
0
0

t
43

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.

200th iteration

10

10

0
10
99 0
10

10

0
10
99 0

10
10 0
0

t
44

Bad case for Ford-Fulkerson


Bad news. Even when edge capacities are integers, number of augmenting
paths could be equal to the value of the maxflow.
can be exponential in input size

Good news. This case is easily avoided. [use shortest/fattest path]

10

10

0
10 0
10

0
1

10
10 0
0

10
10
0

t
45

How to choose augmenting paths?


Use care when selecting augmenting paths.

Some choices lead to exponential algorithms.


Clever choices lead to polynomial algorithms.

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

digraph with V vertices, E edges, and integer capacities between 1 and U

46

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy