maximum flow problems

66
1 Maximum flow problems

Upload: dana-mccall

Post on 30-Dec-2015

93 views

Category:

Documents


3 download

DESCRIPTION

Maximum flow problems. Maximum flow problems. Introduction of: network, max-flow problem capacity, flow Ford-Fulkerson method pseudo code, residual networks, augmenting paths cuts of networks max-flow min-cut theorem example of an execution analysis, running time, - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Maximum flow problems

1

Maximum flow problems

Page 2: Maximum flow problems

2

Maximum flow problems- Introduction of:

network, max-flow problem

capacity, flow

- Ford-Fulkerson method

pseudo code, residual networks, augmenting paths

cuts of networks

max-flow min-cut theorem

example of an execution

analysis, running time,

variations of the max-flow problem

Page 3: Maximum flow problems

3

Introduction – flow network

Practical examples of a flow network

- liquids flowing through pipes

- parts through assembly lines

- current through electrical network

- information through communication network

- goods transported on the road…

Page 4: Maximum flow problems

4

Introduction – flow networkExample: oil pipelineRepresentation

Flow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

S t

v1

v2

v3

v4source sink

Page 5: Maximum flow problems

5

Introduction – max-flow problemRepresentation

Flow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

S t

v1

v2

v3

v4source sink

Informal definition of the max-flow problem:

What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints?

Example: oil pipeline

Page 6: Maximum flow problems

6

Introduction - capacity

S t

v1

v2

v3

v4

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

u v12

u v6

c(u,v)=12

c(u,v)=6

Big pipe

Small pipe

8

3

6

8

6

6

3

3

Example: oil pipeline

Page 7: Maximum flow problems

7

Introduction - capacity

S t

v1

v2

v3

v4

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

8

3

6

8

6

6

3

3

Example: oil pipeline

v4

v2

v3

v4

If (u,v) E c(u,v) = 0

0

0

0

6

Page 8: Maximum flow problems

8

Introduction – flow

S t

v1

v2

v3

v4

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

u v6/12

u v6/6

f(u,v)=6

f(u,v)=6

Flow below capacity

Maximum flow

8

3

6

8

6

6

3

3

Example: oil pipeline

Page 9: Maximum flow problems

9

Introduction – flow

S t

v1

v2

v3

v4

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

8

3

6

8

6

6

3

3

Example: oil pipeline

Page 10: Maximum flow problems

10

Introduction – flow

S t

v1

v2

v3

v4

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

8

3

6

6/8

6/6

6/6

3

3

Example: oil pipeline

Page 11: Maximum flow problems

11

Introduction – flow

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

8

3

6

6/8

6/6

6/6

3

3

Example: oil pipeline

Page 12: Maximum flow problems

12

Introduction – flow

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

3/8

3/3

3/6

6/8

6/6

6/6

3

3

Example: oil pipeline

Page 13: Maximum flow problems

13

Introduction – flow

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

3/8

3/3

3/6

6/8

6/6

6/6

3

3

Example: oil pipeline

Page 14: Maximum flow problems

14

Introduction – flow

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

5/8

3/3

3/6

8/8

6/6

6/6

2/3

3

Example: oil pipeline

Page 15: Maximum flow problems

15

Introduction – cancellation

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

5/8

3/3

3/6

8/8

6/6

6/6

2/3

3

Example: oil pipeline

Page 16: Maximum flow problems

16

Introduction – cancellation

S t

v1

v2 v4

v3

RepresentationFlow network: directed graph G=(V,E)

S t

v1

v2

v3

v4

6/8

3/3

4/6

8/8

5/6

6/6

3/3

1/3

u

v

10 4

u

v

8/10 4

u

v

8/10 3/4

u

v

5/10 4

Example: oil pipeline

Page 17: Maximum flow problems

17

Flow properties

Flow in G = (V,E): f: V x V R with 3 properties:

1) Capacity constraint: For all u,v V : f(u,v) < c(u,v)

2) Skew symmetry: For all u,v V : f(u,v) = - f(v,u)

3) Flow conservation: For all u V \ {s,t} : f(u,v) = 0 v V

Page 18: Maximum flow problems

18

Flow properties

Flow in G = (V,E): f: V x V R with 3 properties:

1) Capacity constraint: For all u,v V : f(u,v) < c(u,v)

2) Skew symmetry: For all u,v V : f(u,v) = - f(v,u)

3) Flow conservation: For all u V \ {s,t} : f(u,v) = 0 v V

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/207/

7

4/9

Flow network G = (V,E)Note:

by skew symmetry

f (v3,v1) = - 12

Page 19: Maximum flow problems

19

Net flow and value of a flow

Net Flow: positive or negative value of f(u,v) Value of a Flow f: Def:

|f| = f(s,v) v V

S t

v1

v2

v3

v4

6/8

3/3

4/6

8/8

5/6

6/6

3/3

1/3

u

v

8/10 3/4

u

v

5/10 4

f(u,v) = 5

f(v,u) = -5

Page 20: Maximum flow problems

20

The max-flow problem

Informal definition of the max-flow problem:

What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints?

Formal definition of the max-flow problem:

The max-flow problem is to find a valid flow for a given weighted directed graph G, that has the maximum value over all valid flows.

Page 21: Maximum flow problems

21

The Ford-Fulkerson methoda way how to find the max-flow

This method contains 3 important ideas: 

      1) residual networks

    2) augmenting paths

    3) cuts of flow networks

 

Page 22: Maximum flow problems

22

Ford-Fulkerson – pseudo code

1 initialize flow f to 0

2 while there exits an augmenting path p

3 do augment flow f along p

4 return f

Page 23: Maximum flow problems

23

Ford Fulkerson – residual networks

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

The residual network Gf of a given flow network G with a valid flow f consists of the same vertices v V as in G which are linked with residual edges (u,v) Ef that can admit more strictly positive net flow.

The residual capacity cf represents the weight of each edge Ef and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v)

Flow network G = (V,E)

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

S t

v1

v2

v3

v4

residual network Gf = (V,Ef)

5

11

8

5

Page 24: Maximum flow problems

24

Ford Fulkerson – residual networks

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

Flow network G = (V,E)

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

S t

v1

v2

v3

v4

residual network Gf = (V,Ef)

1111

8

12

5

3

43

5

7

5

11

5

154

The residual network Gf of a given flow network G with a valid flow f consists of the same vertices v V as in G which are linked with residual edges (u,v) Ef that can admit more strictly positive net flow.

The residual capacity cf represents the weight of each edge Ef and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v)

Page 25: Maximum flow problems

25

Ford Fulkerson – augmenting paths

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

cf(p) = min{cf (u,v): (u,v) is on p}

Flow network G = (V,E) residual network Gf = (V,Ef)

Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network Gf

Residual capacity of p

S t

v1

v2

v3

v4

11

8

12

5

3

43

5

7

5

11

5

11

154

Page 26: Maximum flow problems

26

Ford Fulkerson – augmenting paths

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

cf(p) = min{cf (u,v): (u,v) is on p}

Flow network G = (V,E)

S t

v1

v2

v3

v4

11

8

12

5

3

43

5

7

5

residual network Gf = (V,Ef)

11

5

11

154

Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network Gf

Residual capacity of p

Augmenting path

Page 27: Maximum flow problems

27

Ford Fulkerson – augmenting paths

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

Flow network G = (V,E)

S t

v1

v2

v3

v4

11

8

12

5

3

43

5

7

5

residual network Gf = (V,Ef)

11

5

11

154

We define a flow: fp: V x V R such as:

cf(p) if (u,v) is on p

fp(u,v) = - cf(p) if (v,u) is on p

0 otherwise

Page 28: Maximum flow problems

28

Ford Fulkerson – augmenting paths

S t

v1

v2

v3

v4

10

8/13

12/12

11/16

1/4

4/4

11/14

15/20

7/7

4/9

Flow network G = (V,E)

S t

v1

v2

v3

v4

11

-4/8

12

5

3

43

4/5

7

-4/5

residual network Gf = (V,Ef)

11

4/5

11

-4/154/4

Our virtual flow fp along the augmenting path p in Gf

cf(p) if (u,v) is on p

fp(u,v) = - cf(p) if (v,u) is on p

0 otherwise

We define a flow: fp: V x V R such as:

Page 29: Maximum flow problems

29

Ford Fulkerson – augmenting the flow

S t

v1

v2

v3

v4

10

12/13

12/12

11/16

1/4

4/4

11/14

19/20

7/7

0/9

Flow network G = (V,E)

S t

v1

v2

v3

v4

11

8

12

5

3

43

4/5

7

5

residual network Gf = (V,Ef)

11

4/5

11

154/4

Our virtual flow fp along the augmenting path p in Gf

New flow: f´: V x V R : f´=f + fp

cf(p) if (u,v) is on p

fp(u,v) = - cf(p) if (v,u) is on p

0 otherwise

We define a flow: fp: V x V R such as:

Page 30: Maximum flow problems

30

Ford Fulkerson – new valid flowproof of capacity constraint

Proof:

fp (u ,v) < cf (u ,v) = c (u ,v) – f (u ,v)

(f + fp) (u ,v) = f (u ,v) + fp (u ,v) < c (u ,v)

Lemma:

f´ : V x V R : f´ = f + fp in G

Capacity constraint:

For all u,v V, we require f(u,v) < c(u,v)

cf(p) if (u,v) is on p

fp(u,v) = - cf(p) if (v,u) is on p

0 otherwise

cf(p) = min{cf (u,v): (u,v) is on p}

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

Page 31: Maximum flow problems

31

Ford Fulkerson – new valid flowproof of Skew symmetry

Proof:

(f + fp)(u ,v) = f (u ,v) + fp (u ,v) = - f (v ,u) – fp (v ,u)

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

Skew symmetry:

For all u,v V, we require f(u,v) = - f(v,u)

Lemma:

f´ : V x V R : f´ = f + fp in G

Page 32: Maximum flow problems

32

Ford Fulkerson – new valid flowproof of flow conservation

Proof:

u V – {s ,t} (f + fp) (u ,v) = (f(u ,v) + fp (u ,v))

= f (u ,v) + fp (u ,v) = 0 + 0 = 0

Flow conservation:

For all u V \ {s,t} : f(u,v) = 0 v V

v V v V

v V v V

Lemma:

f´ : V x V R : f´ = f + fp in G

Page 33: Maximum flow problems

33

Ford Fulkerson – new valid flow

Proof:

| (f + fp) | = (f + fp) (s ,v) = (f (s ,v) + fp (s ,v))

= f (s ,v) + fp (s ,v) = | f | + | fp |

Lemma:

| (f + fp) | = | f | + | fp |

v V v V

v V v V

Value of a Flow f:

 Def: |f| = f(s,v)

v V

Page 34: Maximum flow problems

34

Ford Fulkerson – new valid flow

Lemma:

| (f + fp) | = | f | + | fp | > | f |

f´ : V x V R : f´ = f + fp in G

Lemma shows:

if an augmenting path can be found then the above flow augmentation will result in a flow improvement.

Question: If we cannot find any more an augmenting path is our flow then maximum?

Idea: The flow in G is maximum the residual Gf contains no augmenting path.

Page 35: Maximum flow problems

35

Ford Fulkerson – cuts of flow networksNew notion: cut (S,T) of a flow network

A cut (S,T) of a flow network G=(V,E) is a partiton of V into S and T = V \ S such that s S and t T.

Implicit summation notation: f (S, T) = f (u, v)

S t

v1

v2

v3

v4

10

12/13

12/12

11/16

1/4

4/4

19/20

7/7

0/9

11/14

TS

In the example:

S = {s,v1,v2) , T = {v3,v4,t}

Net flow f(S ,T) = f(v1,v3) + f(v2,v4) + f(v2,v3)

= 12 + 11 + (-0) = 23

Capacity c(S,T) = c(v1,v3) + c(v2,v4)

= 12 + 14 = 26

Practical example

u S

v T

Page 36: Maximum flow problems

36

Ford Fulkerson – cuts of flow networks

Lemma:

the value of a flow in a network is the net flow across any cut of the network

f (S ,T) = | f |

S t

v1

v2

v3

v4

10

12/13

12/12

11/161/

4

4/4

19/20

7/7

0/9

11/14

proof

Page 37: Maximum flow problems

37

Ford Fulkerson – cuts of flow networksAssumption:

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

Lemma: | f | < c (S, T)

| f | = f (S, T)

= f (u, v)

< c (u, v)

= c (S, T) v T

u S

v T

u S

S t

v1

v2

v3

v410

12/13

12/12

11/16

1/4

4/4

19/20

7/7

0/9

11/14

Page 38: Maximum flow problems

38

F. Fulkerson: Max-flow min-cut theorem

If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:

1. f is a maximum flow in G.

2. The residual network Gf contains no augmenting paths.

3. | f | = c (S, T) for some cut (S, T) of G.proof:

(1) (2):

We assume for the sake of contradiction that f is a maximum flow in G but that there still exists an augmenting path p in Gf.

Then as we know from above, we can augment the flow in G according to the formula: f´= f + fp. That would create a flow f´that is strictly greater than the former flow f which is in contradiction to our assumption that f is a maximum flow.

Page 39: Maximum flow problems

39

F. Fulkerson: Max-flow min-cut theorem

If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:

1. f is a maximum flow in G.

2. The residual network Gf contains no augmenting paths.

3. | f | = c (S, T) for some cut (S, T) of G.proof:

(2) (3):

S t

v1

v2

v3

v4

6/8

3/3

4/6

8/8

5/6

6/6

3/3

1/3S t

v1

v2

v3

v4

2

3

2

8

1

6

3

2

5

6 14

residual network Gf original flow network G

Page 40: Maximum flow problems

40

F. Fulkerson: Max-flow min-cut theorem

If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:

1. f is a maximum flow in G.

2. The residual network Gf contains no augmenting paths.

3. | f | = c (S, T) for some cut (S, T) of G.proof:

(2) (3): Define

S = {v V | path p from s to v in Gf }

T = V \ S (note t S according to (2)) S t

v1

v2

v3

v4

2

3

2

8

1

6

3

2

5

6 14

residual network Gf

Page 41: Maximum flow problems

41

F. Fulkerson: Max-flow min-cut theorem

If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:

1. f is a maximum flow in G.

2. The residual network Gf contains no augmenting paths.

3. | f | = c (S, T) for some cut (S, T) of G.proof:

(2) (3): Define

S = {v V | path p from s to v in Gf }

T = V \ S (note t S according to (2))

for u S, v T: f (u, v) = c (u, v) (otherwise (u, v) Ef and v S)

| f | = f (S, T) = c (S, T)

1

S t

v1

v2

v3

v4

6/8

3/3

4/6

8/8

5/6

6/6

3/3

1/3

original network G

Page 42: Maximum flow problems

42

F. Fulkerson: Max-flow min-cut theorem

If f is a fow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:

1. f is a maximum flow in G.

2. The residual network Gf contains no augmenting paths.

3. | f | = c (S, T) for some cut (S, T) of G.proof:

(3) (1): as proofed before | f | = f (S, T) < c (S, T)

the statement of (3) : | f | = c (S, T) implies that f is a maximum flow

Page 43: Maximum flow problems

43

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t in the

residual network Gf 5 do cf (p) = min {cf (u, v) | (u, v) is in p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf (p) 8 f [v, u] = - f [u, v]

The basic Ford Fulkerson algorithm

Page 44: Maximum flow problems

44

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

16

4

4

14

20

7

9

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

(residual) network Gf

Page 45: Maximum flow problems

45

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

0/10

0/13

0/12

0/16

0/4

0/4

0/14

0/20

7

0/9

(residual) network Gf 1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 46: Maximum flow problems

46

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

16

4

4

14

20

7

9

(residual) network Gf 1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 47: Maximum flow problems

47

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

16

4

4

14

20

7

9

(residual) network Gf

temporary variable:

cf (p) = 12

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 48: Maximum flow problems

48

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

16

4

4

14

20

7

9

(residual) network Gf

temporary variable:

cf (p) = 12S t

v1

v2

v3

v4

10

13

12/12

12/16

4

4

14

12/20

7

9

new flow network G

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 49: Maximum flow problems

49

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

4

4

4

14

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

13

12/12

12/16

4

4

14

12/20

7

9

new flow network G

1212

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 50: Maximum flow problems

50

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

4

4

4

14

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

13

12/12

12/16

4

4

14

12/20

7

9

new flow network G

1212

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 51: Maximum flow problems

51

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

4

4

4

14

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

13

12/12

12/16

4

4

14

12/20

7

9

new flow network G

1212

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 52: Maximum flow problems

52

The basic Ford Fulkerson algorithmexample of an execution

(residual) network Gf

S t

v1

v2

v3

v4

10

13

12/12

12/16

4

4

14

12/20

7

9

new flow network G

temporary variable:

cf (p) = 4

S t

v1

v2

v3

v4

10

13

12

4

4

4

14

8

7

9

1212

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 53: Maximum flow problems

53

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

13

12

4

4

4

14

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

4/13

12/12

12/16

4

4/4

4/14

12/20

7

9

new flow network G

1212

temporary variable:

cf (p) = 4

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 54: Maximum flow problems

54

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

9

12

4

4

4

10

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

4/13

12/12

12/16

4

4/4

4/14

12/20

7

9

new flow network G

1212

4

4

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 55: Maximum flow problems

55

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

9

12

4

4

4

10

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

4/13

12/12

12/16

4

4/4

4/14

12/20

7

9

new flow network G

1212

4

4

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 56: Maximum flow problems

56

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

9

12

4

4

4

10

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

4/13

12/12

12/16

4

4/4

4/14

12/20

7

9

new flow network G

1212

4

4

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 57: Maximum flow problems

57

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

9

12

4

4

4

10

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

4/13

12/12

12/16

4

4/4

4/14

12/20

7

9

new flow network G

1212

4

4

temporary variable:

cf (p) = 7

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 58: Maximum flow problems

58

The basic Ford Fulkerson algorithmexample of an execution

S t

v1

v2

v3

v4

10

9

12

4

4

4

10

8

7

9

(residual) network Gf

S t

v1

v2

v3

v4

10

11/13

12/12

12/16

4

4/4

11/14

19/20

7/7

9

new flow network G

1212

4

4

temporary variable:

cf (p) = 7

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 59: Maximum flow problems

59

The basic Ford Fulkerson algorithmexample of an execution

(residual) network Gf

S t

v1

v2

v3

v4

10

11/13

12/12

12/16

4

4/4

11/14

19/20

7/7

9

new flow network G

S t

v1

v2

v3

v4

10

2

12

4

4

4

3

1

7

9

1219

11

11

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 60: Maximum flow problems

60

The basic Ford Fulkerson algorithmexample of an execution

(residual) network Gf

S t

v1

v2

v3

v4

10

11/13

12/12

12/16

4

4/4

11/14

19/20

7/7

9

new flow network G

S t

v1

v2

v3

v4

10

2

12

4

4

4

3

1

7

9

1219

11

11

Finally we have:

| f | = f (s, V) = 23

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 61: Maximum flow problems

61

Analysis of the Ford Fulkerson algorithmRunning time

The running time depends on how the augmenting path p in line 4 is determined.

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

Page 62: Maximum flow problems

62

Analysis of the Ford Fulkerson algorithmRunning time (arbitrary choice of p)

O(|E|)

O(|E|)

O(|E| |fmax|)

running time: O ( |E| |fmax| )

with fmax as maximum flow

(1) The augmenting path is chosen arbitrarily and all capacities are integers

1 for each edge (u, v) E [G] 2 do f [u, v] = 0 3 f [v, u] = 0 4 while there exists a path p from s to t

in the residual network Gf 5 do cf(p) = min{cf(u, v) | (u, v) p} 6 for each edge (u, v) in p 7 do f [u, v] = f [u, v] + cf(p) 8 f [v, u] = - f [u, v]

O(|E|)

Page 63: Maximum flow problems

63

Analysis of the Ford Fulkerson algorithmRunning time (arbitrary choice of p)

(1) The augmenting path is chosen arbitrarily and all capacities are integers

Consequencies of an arbitrarily choice:

Example if |f*| is large:

t

v2

v1

s

1,000,000 1,000,000

1,000,0001,000,000

1

running time: O ( |E| |fmax| )

with fmax as maximum flow

Page 64: Maximum flow problems

64

Analysis of the Ford Fulkerson algorithmRunning time (arbitrary choice of p)

(1) The augmenting path is chosen arbitrarily and all capacities are integers

Consequencies of an arbitrarily choice:

Example if |f*| is large:

t

v2

v1

s

1 / 1,000,000 1,000,000

1,000,0001 / 1

,000,000

1 / 1

t

v2

v1

s

999,999 1,000,000

1,000,000999,999

1

residual network Gf

1

1

running time: O ( |E| |fmax| )

with fmax as maximum flow

Page 65: Maximum flow problems

65

Analysis of the Ford Fulkerson algorithmRunning time (arbitrary choice of p)

(1) The augmenting path is chosen arbitrarily and all capacities are integers

Consequencies of an arbitrarily choice:

Example if |f*| is large:

t

v2

v1

s

1 / 1,000,000 1 / 1,000,000

1 / 1,000,0001 / 1

,000,000

1

t

v2

v1

s

999,999 999,999

999,999999,999

1

residual network Gf

1

1

1

1

running time: O ( |E| |fmax| )

with fmax as maximum flow

Page 66: Maximum flow problems

66

Analysis of the Ford Fulkerson algorithmRunning time with Edmonds-Karp algorithm

running time: O ( |V| |E|² )

S t

u1

u2

v3

v44

4

6

4

4

6

2

2

Informal idea of the proof:

(1) for all vertices v V\{s,t}:

the shortest path distance f(s,v) in Gf increases monotonically with each flow augmentation

. f(s,v) < f´(s,v) f(s,u2) = 1

(2) Edmonds-Karp algorithm

augmenting path is found by breath-first search and has to be a shortest path from p to t