- 197 Views
- Uploaded on
- Presentation posted in: General

Maximum flow problems

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

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

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

Representation

Example: oil pipeline

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

v3

v3

v1

v1

S

S

t

t

source

v2

v4

v2

v4

sink

Representation

Example: oil pipeline

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

v3

v3

v1

v1

S

S

t

t

source

v2

v4

v2

v4

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?

3

v3

v1

6

8

3

S

t

3

6

8

v2

v4

6

c(u,v)=12

6

c(u,v)=6

u

u

v

v

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

12

Big pipe

Small pipe

Representation

Example: oil pipeline

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

3

v3

v3

v1

v1

6

8

3

S

S

t

t

3

6

8

v2

v4

v2

v4

6

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

6

v2

v4

0

0

v4

v3

0

3

v3

v1

6

8

3

S

t

3

6

8

v2

v4

6

f(u,v)=6

f(u,v)=6

u

u

v

v

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

6/12

Flow below capacity

6/6

Maximum flow

3

v3

v1

6

8

3

S

t

3

6

8

v2

v4

6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3

v3

v1

6

8

3

S

t

3

6/6

6/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3

v3

v1

6

8

3

S

t

3

6/6

6/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3/3

v3

v1

3/6

3/8

3

S

t

3

6/6

6/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3/3

v3

v1

3/6

3/8

3

S

t

3

6/6

6/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3/3

v3

v1

3/6

5/8

2/3

S

t

3

6/6

8/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3/3

v3

v1

3/6

5/8

2/3

S

t

3

6/6

8/8

v2

v4

6/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

3/3

v3

v1

4/6

6/8

3/3

S

t

1/3

6/6

8/8

v2

v4

5/6

Representation

Example: oil pipeline

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

v3

v1

S

t

v2

v4

u

u

u

u

8/10

3/4

5/10

4

10

4

8/10

4

v

v

v

v

Flow network G = (V,E)

12/12

v3

v1

Note:

by skew symmetry

f (v3,v1) = - 12

11/16

15/20

10

1/4

7/7

S

t

4/9

4/4

8/13

v2

v4

11/14

u

u

f(u,v) = 5

f(v,u) = -5

8/10

3/4

5/10

4

v

v

3/3

v3

v1

4/6

6/8

3/3

S

t

1/3

6/6

8/8

v2

v4

5/6

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.

This method contains 3 important ideas:

1) residual networks

2) augmenting paths

3) cuts of flow networks

1 initialize flow f to 0

2 while there exits an augmenting path p

3do augment flow f along p

4 return f

5

11

5

8

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

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)

residual network Gf = (V,Ef)

12/12

v3

v3

v1

v1

11/16

15/20

10

1/4

7/7

S

t

S

t

4/9

4/4

8/13

v2

v4

v2

v4

11/14

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

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)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

5

11/16

15/20

4

11

10

1/4

11

7/7

7

15

3

S

t

S

t

4/9

5

5

4/4

4

3

8/13

8

v2

v4

v2

v4

11/14

11

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

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

Flow network G = (V,E)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

5

11/16

15/20

4

11

10

1/4

11

7/7

7

15

3

S

t

S

t

4/9

5

5

4/4

4

3

8/13

8

v2

v4

v2

v4

11/14

11

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

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

Flow network G = (V,E)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

5

11/16

15/20

4

11

10

1/4

11

7/7

7

15

3

S

t

S

t

4/9

5

5

4/4

4

3

8/13

8

v2

v4

v2

v4

11/14

11

Augmenting path

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

Flow network G = (V,E)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

5

11/16

15/20

4

11

10

1/4

11

7/7

7

15

3

S

t

S

t

4/9

5

5

4/4

4

3

8/13

8

v2

v4

v2

v4

11/14

11

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:

Flow network G = (V,E)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

4/5

11/16

15/20

4/4

11

10

1/4

11

7/7

7

-4/15

3

S

t

S

t

4/9

-4/5

4/5

4/4

4

3

8/13

-4/8

v2

v4

v2

v4

11/14

11

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:

Flow network G = (V,E)

residual network Gf = (V,Ef)

12

12/12

v3

v3

v1

v1

5

4/5

11/16

19/20

4/4

11

10

1/4

11

7/7

7

15

3

S

t

S

t

0/9

5

4/5

4/4

4

3

12/13

8

v2

v4

v2

v4

11/14

11

New flow:

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

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

Lemma:

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

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

Capacity constraint:

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

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

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

Skew symmetry:

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

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)

Lemma:

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

Flow conservation:

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

v V

Proof:

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

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

v V

v V

v V

v V

Lemma:

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

Value of a Flow f:

Def:

|f| = f(s,v)

v V

Proof:

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

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

v V

v V

v V

v V

Lemma:

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

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

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.

Practical example

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

12/12

v3

v1

11/16

19/20

10

1/4

7/7

S

t

0/9

4/4

12/13

v2

v4

11/14

S

T

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

u S

v T

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

Lemma:

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

f (S ,T) = | f |

12/12

v3

v1

11/16

19/20

10

1/4

7/7

S

t

0/9

4/4

12/13

v2

v4

11/14

proof

Assumption:

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)

12/12

| f | = f (S, T)

= f (u, v)

< c (u, v)

= c (S, T)

v3

v1

11/16

19/20

10

1/4

7/7

S

t

0/9

u S

v T

4/4

u S

v T

12/13

v2

v4

11/14

- If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:
- f is a maximum flow in G.
- The residual network Gf contains no augmenting paths.
- | f | = c (S, T) for some cut (S, T) of G.

- proof:
- (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.

residual network Gf

3/3

3

v3

v3

v1

v1

4/6

2

6/8

3/3

2

3

4

6

1

S

S

t

t

1/3

2

6/6

6

5

8/8

8

v2

v4

v2

v4

5/6

1

- If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:
- f is a maximum flow in G.
- The residual network Gf contains no augmenting paths.
- | f | = c (S, T) for some cut (S, T) of G.

proof:

(2) (3):

original flow network G

- If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:
- f is a maximum flow in G.
- The residual network Gf contains no augmenting paths.
- | 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))

residual network Gf

3

v3

v1

2

2

3

4

6

1

S

t

2

6

5

8

v2

v4

1

3/3

v3

v1

4/6

6/8

3/3

S

t

1/3

6/6

8/8

v2

v4

5/6

- f is a maximum flow in G.
- The residual network Gf contains no augmenting paths.
- | 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)

original network G

1

- If f is a fow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent:
- f is a maximum flow in G.
- The residual network Gf contains no augmenting paths.
- | 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

(residual) network Gf

12

v3

v1

16

20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

0/12

v3

v1

0/16

0/20

0/10

0/4

7

S

t

0/9

0/4

0/13

v2

v4

0/14

(residual) network Gf

12

v3

v1

16

20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

16

20

10

4

7

S

t

9

4

13

v2

v4

14

temporary variable:

cf (p) = 12

(residual) network Gf

12

v3

v1

16

20

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

temporary variable:

cf (p) = 12

12/20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

temporary variable:

cf (p) = 4

4

13

v2

v4

14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

13

v2

v4

14

new flow network G

12/12

v3

v1

12/16

temporary variable:

cf (p) = 4

12/20

10

4

7

S

t

9

4/4

4/13

v2

v4

4/14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

4

4

9

v2

v4

10

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4/4

4/13

v2

v4

4/14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

4

4

9

v2

v4

10

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4/4

4/13

v2

v4

4/14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

4

4

9

v2

v4

10

new flow network G

12/12

v3

v1

12/16

12/20

10

4

7

S

t

9

4/4

4/13

v2

v4

4/14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

4

4

9

v2

v4

10

new flow network G

12/12

v3

v1

12/16

temporary variable:

cf (p) = 7

12/20

10

4

7

S

t

9

4/4

4/13

v2

v4

4/14

(residual) network Gf

12

v3

v1

4

8

12

12

10

4

7

S

t

9

4

4

4

9

v2

v4

10

new flow network G

12/12

v3

v1

12/16

temporary variable:

cf (p) = 7

19/20

10

4

7/7

S

t

9

4/4

11/13

v2

v4

11/14

(residual) network Gf

12

v3

v1

4

1

12

19

10

4

7

S

t

9

11

4

11

2

v2

v4

3

new flow network G

12/12

v3

v1

12/16

19/20

10

4

7/7

S

t

9

4/4

11/13

v2

v4

11/14

(residual) network Gf

12

v3

v1

4

1

12

19

10

4

7

S

t

9

11

4

11

2

v2

v4

3

new flow network G

12/12

v3

v1

12/16

19/20

Finally we have:

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

10

4

7/7

S

t

9

4/4

11/13

v2

v4

11/14

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

O(|E|)

O(|E|)

O(|E| |fmax|)

O(|E|)

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

with fmax as maximum flow

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

Consequencies of an arbitrarily choice:

Example if |f*| is large:

v1

1,000,000

1,000,000

s

1

t

1,000,000

1,000,000

v2

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

with fmax as maximum flow

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

Consequencies of an arbitrarily choice:

Example if |f*| is large:

residual network Gf

v1

v1

1 / 1,000,000

1,000,000

999,999

1,000,000

1

1 / 1

s

t

s

1

t

1

1,000,000

1,000,000

1 / 1,000,000

999,999

v2

v2

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

with fmax as maximum flow

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

Consequencies of an arbitrarily choice:

Example if |f*| is large:

residual network Gf

v1

v1

1/ 1,000,000

1 / 1,000,000

999,999

999,999

1

1

1

s

t

s

1

t

1

1

999,999

1 / 1,000,000

1/ 1,000,000

999,999

v2

v2

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

with fmax as maximum flow

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

- Informal idea of the proof:
- 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)

4

v3

u1

6

6

2

2

S

t

4

4

u2

v4

4

f(s,u2) = 1

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

(2) Edmonds-Karp algorithm

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