Flow Networks zichun@comp.nus.edu.sg. Formalization Basic Results Ford-Fulkerson Edmunds-Karp...

Post on 23-Dec-2015

216 views 0 download

Tags:

transcript

Flow Networkszichun@comp.nus.edu.sg

Formalization

Basic Results

Ford-Fulkerson

Edmunds-Karp

Bipartite Matching

Min-cut

Flow Network

โ€ข Directed Graph G = (V, E)โ€ข Each edge has a capacity

Properties of Flow

Capacity Constraint

Skew Symmetry

Flow Conservation

Maximum Flow

โ€“ Returns Maximum Flow of G

Value of Flow

|๐’‡ |=โˆ‘๐‘ฃโˆˆ๐‘‰

๐‘“ (๐‘  ,๐‘ฃ )

Motivating Problem

s

v1

v2

v3

v4

tFact

ory

Warehouse

16

10 4

1220

9 7

4

14

13

Motivating Problem

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/20

4/9 7/7

4/4

11/14

8/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

15/20

4/9 7/7

4/4

11/14

8/13

12/12

Multiple Sources / Sinks

s1

v1

v2

v3

v4

t1

16

10 4

1220

9 74

14

13

t24s2

4

Multiple Sources / Sinks

s1

v1

v2

v3

v4

t1

16

10 4

1220

9 74

14

13

t24s2

4

S tโˆž

โˆž โˆž

โˆž

Implicit Summation Notation

Key EqualitiesLet G = (V, E) be a flow network, and let f be a flow in G. Then

Capacity Constraint

Skew Symmetry

Flow Conservation

Homomorphism

Flow Value

Prove

DefinitionHomomorphismFlow Conservation

Skew SymmetryHomomorphismFlow Conservation

Ford-Fulkerson

flow=0while(augmenting path p)) { augment flow f along p}return flow

Residual network

Induced network from G=(V, E) and flow f

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/20

4/9 7/7

4/4

11/14

8/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

Augmenting Path

A path of

non-zero weight

from s to t in Gf

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/20

4/9 7/7

4/4

11/14

8/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/20

4/9 7/7

4/4

11/14

8/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/20

4/9 7/7

4/4

11/14

8/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

20/20

0/9 7/7

4/4

11/14

13/13

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

20

411

1311

0 7

0

3

0

9

3

00

0

S-T Cut

โ€ข A cut C=(S, T) of a flow network G=(V, E) is a partition of V into S and T = V โ€“ S

โ€ข Net flow acrossโ€ข Capacity of cut:

s

v1

v2

v3

v4

tFact

ory

Warehouse

11/16

10 1/4

12/12

15/204/9 7/

7

4/4

11/14

8/13

f(S, T) = 12 โ€“ 4 + 11 = 19c(S, T) = 12 + 14 = 26

Let f be a flow in a flow network G with source s and sink t, and let (S, T) be a cut of G. Then the net flow across (S, T) is f(S, T) = |f|

HomomorphismFlow ConservationHomomorphism

Flow ConservationDefinition

|๐‘“ |= ๐‘“ (๐‘† ,๐‘‡ )The value of any flow f in a flow network G is bounded by the capacity of any cut of G

Min-Cut Max-Flow

1. f is a maximum flow in G2. The residual network Gf contains no

augmenting path3. |f|= c(S, T) for some cut (S, T) of G

(1 )โ‡’(2)1. Premise: f is a max-flow in G2. Assume Gf has augmenting path p

3. We can augment Gf with p to get a flow fโ€™ > fโ€“ Contradicts [1]

โ€ข Hence Gf has no augmenting paths

(2 )โ‡’(3)1. Premise: Gf has no augmenting paths

2. Let

1. T = V-S

3. (S, T) is a cut

1. Otherwise

(3 )โ‡’(1)

1. , |f| is maximum

The value of any flow f in a flow network G is bounded by the capacity of any cut of G

Ford-Fulkerson

flow=0while(augmenting path p)) { augment flow f along p}return flow

Termination: Gf has no augmenting path iff flow is maximum

Run-time

flow=0while(augmenting path p)) { augment flow f along p}return flow

O(E|f*|) where |f*| is the maximum flow

s

v1

v2

t1

1,000,000 1,000,000

1,000,0001,000,000

s

v1

v2

t1

1,000,000 1,000,000

1,000,0001,000,000

s

v1

v2

t1

999,999 1,000,000

1,000,0001,000,000

1

1

s

v1

v2

t1

999,999 1,000,000

1,000,0001,000,000

1

1

s

v1

v2

t1

999,999 999,999

1,000,000999,999

1

11

1

s

v1

v2

t1

999,999 999,999

1,000,000999,999

1

11

1

Edmunds Karp

flow=0while(augmenting path p)) { find augmenting path by BFS augment flow f along p}return flow

Run-time: O(VE2)

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

Critical Edge

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

Critical Edge

Lemma: Edges can be critical at most times

s

v1

v2

v3

v4

tFact

ory

Warehouse

11

5

12

15

411

811

4 7

5

3

0

5

3

00

5

๐›ฟ ๐‘“ (๐‘ข ,๐‘ฃ )โ‰” h๐‘  ๐‘œ๐‘Ÿ๐‘ก๐‘’๐‘ ๐‘กโˆ’ h๐‘๐‘Ž๐‘ก h๐‘™๐‘’๐‘›๐‘”๐‘ก ๐‘“๐‘Ÿ๐‘œ๐‘š๐‘ขโ†’๐‘ฃ

๐›ฟ ๐‘“ (๐‘ข ,๐‘ฃ )โ‰” h๐‘  ๐‘œ๐‘Ÿ๐‘ก๐‘’๐‘ ๐‘กโˆ’ h๐‘๐‘Ž๐‘ก h๐‘™๐‘’๐‘›๐‘”๐‘ก ๐‘“๐‘Ÿ๐‘œ๐‘š๐‘ขโ†’๐‘ฃ1. Assume (u, v) is a critical edge2. Augmenting-paths are shortest path [by EK]3. [from 1]4. After flow-augmentation, cf(u,v) = 0โ€ข (u, v) cannot be critical path until another

augmenting path containing (v, u).โ€ข Let the flow at this point be fโ€™5.

6. i.e, each time (u, v) is augmenting-path, path length increases by 2

7. (u, v) can be critical edge at most times

Lemma: Edges can be critical at most times

Since there are O(E) edges, the number of augmenting path is bounded by O(VE) [by Lemma].

Run-time: O(VE2)

Bipartite Matching

Bipartite Matching

Bipartite Matching MaxFlow

s t

Bipartite Matching MaxFlow

s t