Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

61
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    218
  • download

    3

Transcript of Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Page 1: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.
Page 2: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

source sink

s t

Page 3: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

source sink

5

2

42

3

4

7

2

edge-weights = capacities

Page 4: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

source sink

5

2

42

3

4

7

2

2

2

2

2

22

edge-weights = capacities

4 units of flow

Page 5: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

source sink

5

2

42

3

4

7

2

2

4

2

2

24

edge-weights = capacities

6 units of flow

2

Page 6: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

source sink

5

2

42

3

4

7

2

2

5

2

3

14

edge-weights = capacities

7 units of flow

3

1

Page 7: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Optimal?

5

2

42

3

4

7

2

2

52

3

14

3

1

a larger flow?

Page 8: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Cuts

s

C

C Vs Ct V-C

capacity of a cut

cap(C)= c(u,v)uCvV-C

for any cut and any flow

flow cut

max-flow min-cut

Page 9: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

5

2

4

5

2

edge-weights = capacities

3

FLOW CONSERVATION

Page 10: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Skew symmetry

5

2

4

5

2

edge-weights = capacities

3

FLOW CONSERVATION

x

-x

Page 11: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flows

5

2

4

-5

2

edge-weights = capacities

3

FLOW CONSERVATION

x

-x

f(u,v) = 0vV

Page 12: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Flow – formal definition

FLOW CONSERVATION

CAPACITY CONSTRAINTS

f(u,v) = 0vV

f(u,v) c(u,v)

SKEW SYMMETRY

f(u,v) = - f(v,u)

Page 13: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-flow problem

INPUT:directed graph G=(V,E), source sV, sink tVa capacity c(e) for each edge eE

OUTPUT:maximum flow from s to t

Page 14: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-flow problem

F zero-flowwhile can improve F improve F

Page 15: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-flow problem

5

2

42

3

4

7

2

2

42

2

24

2

5

2

42

3

4

7

2

2

52

3

14

3

1improving can decrease flow on some edges

Page 16: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

+1+1

-1

+1+1

Augmenting path

Page 17: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

+1+1

+1

+1+1

Augmenting path

Page 18: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

+1+1

+1

+1+1

Augmenting path can improve the flow

F zero-flowwhile augmenting path p improve F along p

Ford-Fulkerson algorithm

Page 19: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual capacity

f(u,v)c(u,v)

r(u,v) = c(u,v) – f(u,v)

makes sense for negative f(u,v)

Page 20: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

5

2

42

3

4

7

2

2

22

24

24

Page 21: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

2

42

3

4

7

2

2

22

24

21

Page 22: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

2

42

3

4

7

2

2

22

24

21

Page 23: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

4

42

3

4

7

2

2

2

24

21

Page 24: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

4

42

3

4

7

2

2

2

24

21

Page 25: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

4

424

7

2

2

24

21 15

Page 26: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Residual network

9

4

84 2

71 15

4

7

6

Is there an augmenting path?Is there a path from s to t in the residual network?

Page 27: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Correct ?

F zero-flowwhile augmenting path p improve F along p

Page 28: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Correct ?

F zero-flowwhile augmenting path p improve F along p

Theorem:no augmenting path max-flow

YES

Page 29: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Theorem:no augmenting path max-flow

Proof:no augmenting path no path from s to t in the residual network

s t

Page 30: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Theorem: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

Page 31: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Theorem: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

all edges from C to V-C saturatedC

Page 32: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Theorem:no augmenting path max-flow

Theorem 2: max-flow = min-cut

Page 33: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Is there an augmenting path?Is there a path from s to t in the residual network?

time O(E)

F zero-flowwhile augmenting path p improve F along p

time = ?

Page 34: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

0

100

1

100

100

100

0 0

0

0

Page 35: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

0

100

1

100

100

100

0 0

0

0

Page 36: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1

100

1

100

100

100

0 1

0

1

Page 37: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1

100

1

100

100

100

0 1

0

1

Page 38: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1

100

1

100

100

100

0 1

0

1

Page 39: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1

100

1

100

100

100

2 -1

2

1

Page 40: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1

100

1

100

100

100

2 -1

2

1

Page 41: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

3

100

1

100

100

100

2 1

2

3

Page 42: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile 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*)

Page 43: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

running time O(E F*)

can a good choice of p improve the algorithm?

Page 44: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

F zero-flowwhile augmenting path p improve F along p

1. choose path p which increasesthe flow the most (i.e., p has themaximum bottleneck capacity)

2. choose path p which has the fewest number of edges

Page 45: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

1. choose path p which increasesthe flow the most (i.e., p has themaximum bottleneck capacity)

THEOREM:number of augmenting steps O(E log F*)

Page 46: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Graph G

flow f in G

Residual network Gf

f’=flow in Gf

Claim: h=f+f’ 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

Page 47: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Graph G

flow f in G

Residual network Gf

f’=flow in Gf

Claim: h=f+f’ 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)

Page 48: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Graph G

flow f in G

Residual network Gf

f’=flow in Gf

Claim: f’=h-g is a flow in Gf

CAPACITY CONSTRAINTS:

f’(u,v) h(u,v)-f(u,v)c(u,v)-f(u,v)

flow h in G

Page 49: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Claim: any flow f in G is a sum of at most |E| path flows

Induction on the number of non-zero edges in f

Page 50: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Claim: any flow f in G is a sum of at most |{e E;f(e)0}| path flows

Induction on the number of non-zero edges in f

G’ with capacities c’(u,v)=max{0,f(u,v)}p = augmenting path from zero flow in G’p has bottleneck edge f-p hasless non-zero edges than f

f = flow

f = p + (f-p)

Page 51: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

1. 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

f’=f*-f

max-flow f* in Gpath with bottleneckcapacity f’/|E|

Page 52: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

1. 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*)

Graph G

flow f in G

Residual network Gf

f’=f*-f

max-flow f* in Gpath with bottleneckcapacity f’/|E|

max-flow in the residual graph decreases by a factor of at least (1-1/|E|)

Page 53: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

2. choose path p which has the fewest number of edges

THEOREM:number of augmenting steps O(E V)

Page 54: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

2. choose path p which has the fewest number of edges

level graph = BFS in the residual network

Page 55: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

2. choose path p which has the fewest number of edges

level graph = BFS in the residual network

Page 56: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

2. choose path p which has the fewest number of edges

1) one such edge saturated2) no new introduced

count edges in the residual graph which are on a path of length d from s to t

Page 57: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Plain Ford-FulkersonO(E F*)

Maximum bottleneck capacity O( (E+V log V) E log F )

Fewest edgesO(E2 V)

Page 58: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-matching in bipartite graphs

Page 59: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-matching in bipartite graphs

Page 60: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-matching in bipartite graphs

s t

solution using max-flow

all edge weights =1

Page 61: Flows sourcesink s t Flows sourcesink 5 2 4 2 3 4 7 2 edge-weights = capacities.

Max-matching in bipartite graphssolution using max-flow

s t

all edge weights =1

Plain Ford-FulkersonO(E F*)

Maximum bottleneck capacity O( (E+V log V) E log F )

Fewest edgesO(E2 V)

which oneto use?