Está en la página 1de 76

IT307

Network flow problems


By

K V Arya

Network 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

Introduction network
Practical examples of a network
- liquids flowing through pipes - parts through assembly lines - current through electrical network

- information through communication network


- goods transported on the road

Introduction - network
Representation
Flow network: directed graph G=(V,E)
v1 v3 v1 v3

Example: oil pipeline

v2

v4

source

v2

v4

sink

Introduction max-flow problem


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

Example: oil pipeline

v2

v4

source

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?

Introduction - capacity
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6

t 8

v2

6 12

v4

v2

v4

c(u,v)=12
6

Big pipe
v

c(u,v)=6

Small pipe

Introduction - capacity
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6

t 8

v2

v4

v2

v4

If (u,v)
v2

E
6

c(u,v) = 0
v4

0
0 v4 0 v3

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6

t 8

v2

6 6/12

v4

v2

v4

f(u,v)=6
6/6

Flow below capacity


v

f(u,v)=6

Maximum flow

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6

t 8

v2

v4

v2

v4

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6/6

t 6/8

v2

6/6

v4

v2

v4

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3 v1 v3 v1 6 S v3

Example: oil pipeline

8
S 3 6/6

t 6/8

v2

6/6

v4

v2

v4

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3/3 v1 v3 v1 3/6 S v3

Example: oil pipeline

3/8
S 3 6/6

t 6/8

v2

6/6

v4

v2

v4

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3/3 v1 v3 v1 3/6 S v3

Example: oil pipeline

3/8
S 3 6/6

t 6/8

v2

6/6

v4

v2

v4

Introduction flow
Representation
Flow network: directed graph G=(V,E)
3/3 v1 v3 v1 3/6 S v3

Example: oil pipeline

5/8
S 3 6/6

2/3

t 8/8

v2

6/6

v4

v2

v4

Introduction cancellation
Representation
Flow network: directed graph G=(V,E)
3/3 v1 v3 v1 3/6 S v3

Example: oil pipeline

5/8
S 3 6/6

2/3

t 8/8

v2

6/6

v4

v2

v4

Introduction cancellation
Representation
Flow network: directed graph G=(V,E)
3/3 v1 v3 v1 4/6 S v3

Example: oil pipeline

6/8
S

3/3

t 1/3 8/8

6/6

v2

5/6

v4

v2

v4

u 10 4 8/10

u 4 8/10

u 3/4 5/10

u 4

Flow properties
Flow in G = (V,E): f: V x V R with 3 properties: V : f(u,v) < c(u,v) V : f(u,v) = - f(v,u) V \ {s,t} :
v V

1) Capacity constraint: For all u,v 2) Skew symmetry: For all u,v

3) Flow conservation: For all u

f(u,v) = 0

Flow properties
Flow in G = (V,E): f: V x V R with 3 properties: V : f(u,v) < c(u,v) V : f(u,v) = - f(v,u) V \ {s,t} :
v V

1) Capacity constraint: For all u,v 2) Skew symmetry: For all u,v

3) Flow conservation: For all u


Flow network G = (V,E)

f(u,v) = 0

v1

12/12

v3

Note: by skew symmetry


t

f (v3,v1) = - 12

v2

11/14

v4

Net flow and value of a flow


u u
3/4 5/10 4

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

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

8/10

3/3 v1 v3

Value of a Flow f: Def: |f| = v V f(s,v)

6/8
S

3/3

4/6

1/3
6/6

v2

5/6

v4

8/8

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.

The Ford-Fulkerson method


a way how to find the max-flow

This method contains 3 important ideas: 1) residual networks

2) augmenting paths
3) cuts of flow networks

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

Ford Fulkerson residual networks


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)
v1

residual network Gf = (V,Ef)


v1 v3

12/12

v3

v2

11/14

v4

v2

v4

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

Ford Fulkerson residual networks


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)
v1

residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

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

Ford Fulkerson augmenting paths


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)
v1

residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

Ford Fulkerson augmenting paths


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)
v1

residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

Augmenting path

Ford Fulkerson augmenting paths


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 Flow network G = (V,E)
v1

otherwise residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

Ford Fulkerson augmenting paths


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 Flow network G = (V,E)
v1

otherwise residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

Our virtual flow fp along the augmenting path p in Gf

Ford Fulkerson augmenting the flow


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 Flow network G = (V,E)
v1

otherwise residual network Gf = (V,Ef)


v1

12/12

v3

12

v3

v2

11/14

v4

v2

3 11

v4

New flow:

f: V x V

R : f=f + fp

Our virtual flow fp along the augmenting path p in Gf

Ford Fulkerson new valid flow


proof of capacity constraint Lemma: f :VxV R : f = f + fp in G
cf(p) fp(u,v) = if (u,v) is on p - cf(p) if (v,u) is on p 0 otherwise

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

Capacity constraint:
For all u,v Proof:

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

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

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)

Ford Fulkerson new valid flow


proof of Skew symmetry Lemma: f :VxV R : f = f + fp in G

Skew symmetry:
For all u,v 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) V, we require f(u,v) = - f(v,u)

Ford Fulkerson new valid flow


proof of flow conservation Lemma: f :VxV R : f = f + fp in G

Flow conservation:
For all u Proof: u V {s ,t}
v V

V \ {s,t} :
v V

f(u,v) = 0

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

=v Vf (u ,v) + v Vfp (u ,v) = 0 + 0 = 0

Ford Fulkerson new valid flow


Lemma: | (f + fp) | = | f | + | fp |

Value of a Flow f:
Def: Proof: | (f + fp) | = v V(f + fp) (s ,v) = v V (s ,v) + fp (s ,v)) (f |f| =
v V

f(s,v)

=
v V

f (s ,v) +
v

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

Ford Fulkerson new valid flow


Lemma: f :VxV 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 contains no augmenting path. the residual Gf

Ford Fulkerson cuts of flow networks


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.
Practical example
v1

12/12

v3

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

v2

11/14

v4

Capacity c(S,T) = c(v1,v3) + c(v2,v4) = 12 + 14 = 26 f (u, v)


S v T

Implicit summation notation: f (S, T) =


u

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 |
12/12

v1

v3

v2

11/14

v4

proof

Ford Fulkerson cuts of flow networks


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)
v1

| f | = f (S, T) = < f (u, v)


S
u S v T

12/12

v3

c (u, v)
v2

u S v T

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

11/14

v4

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.

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: original flow network G residual network Gf
3
4/6 2 6 S 1/3 6/6 v2 5/6 v4 6 8/8 v2 1 t S 2 5 v4 8 v1 3 1 4 t v3 2

(2)

(3):
6/8

3/3
v1 3/3 v3

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: residual network Gf

(2)

(3): Define
path p from s to v in Gf } S according to (2))
2 6 S

3
v1 3 1 2 6 v2 1 5

v3 2 4 t 8

S = {v V |

T = V \ S (note t

v4

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: original network G

(2)

(3): Define
v1

3/3
v3 3/3 4/6 6/8 S 1/3 6/6 v2 1 5/6 v4 8/8

S = {v V |

path p from s to v in Gf } S according to (2))

T = V \ S (note t

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)

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

The basic Ford Fulkerson algorithm


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


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

0/12

v3

1 2 3 4
t

v2

0/14

v4

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
temporary variable: cf (p) = 12

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
temporary variable:

12/12

v3

cf (p) = 12

v2

14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

temporary variable:
cf (p) = 4

v2

14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

v2

14

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
temporary variable:

12/12

v3

cf (p) = 4

v2

4/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

4
v2

10

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

4/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

4
v2

10

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

4/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

4
v2

10

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

v2

4/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

4
v2

10

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
temporary variable:

12/12

v3

cf (p) = 7

v2

4/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

4
v2

10

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
temporary variable:

12/12

v3

cf (p) = 7

v2

11/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

11
v2

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network G f do cf(p) = min{c f(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + c f(p) f [v, u] = - f [u, v]

12/12

v3

v2

11/14

v4

The basic Ford Fulkerson algorithm


example of an execution
(residual) network Gf
v1

12

v3

1 2 3 4
t

11
v2

v4

new flow network G


v1

5 6 7 8

for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

12/12

v3

Finally we have:
S t

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

11/14

v4

Analysis of the Ford Fulkerson algorithm


Running time
1 2 3 4 5 6 7 8 for each edge (u, v) E [G] do f [u, v] = 0 f [v, u] = 0 while there exists a path p from s to t in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]

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

Analysis of the Ford Fulkerson algorithm


Running time (arbitrary choice of p)
1 2 3 4 5 6 7 8 for each edge (u, v) E [G] do f [u, v] = 0 O(|E|) f [v, u] = 0 while there exists a path p from s to t O(|E|) in the residual network Gf do cf(p) = min{cf(u, v) | (u, v) p} for each edge (u, v) in p O(|E|) do f [u, v] = f [u, v] + cf(p) f [v, u] = - f [u, v]
running time: O ( |E| |fmax| )

O(|E| |fmax|)

with fmax as maximum flow


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

Analysis of the Ford Fulkerson algorithm


Running time (arbitrary choice of p)
Consequencies of an arbitrarily choice: Example if |f*| is large:
v1

v2

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

with fmax as maximum flow


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

Analysis of the Ford Fulkerson algorithm


Running time (arbitrary choice of p)
Consequencies of an arbitrarily choice: Example if |f*| is large:
v1 1/1

residual network Gf
v1

v2

v2

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

with fmax as maximum flow


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

Analysis of the Ford Fulkerson algorithm


Running time (arbitrary choice of p)
Consequencies of an arbitrarily choice: Example if |f*| is large:
v1

residual network Gf
v1

v2

v2

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

with fmax as maximum flow


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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Informal idea of the proof: (1) for all vertices v V\{s,t}:


S
u1

v3

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

u2

(s,v)

v4

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Informal idea of the proof: (1) for all vertices v V\{s,t}:


S
u1

v3

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

u2

(s,v)

v4

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Informal idea of the proof: (1) for all vertices v V\{s,t}:


S

Two flow augmentations later


u1

v3

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

u2

(s,v)

v4

f(s,u2)

=3

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

The total number of flow augmentations performed by the algorithm is at most O(|V| |E|)
S

u1

v3

u2

v4

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Def: critical edge (u,v) if cf(p) = cf(u,v)


u1

v3

At least one edge on p must be critical.


How many times can (u,v) be critical during an execution of Edmonds-Karp algorithm?

u2

v4

Critical edges on the path p

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Idea: (u,v) can become critical at most O(V) times (After beeing critical it dissappears in Gf and can only reappear after net flow is decreased)
S
u1

v3

u2

v4

our example: edge (u2,v4) 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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Idea: (u,v) can become critical at most O(V) times (After beeing critical it dissappears in Gf and can only reappear after net flow is decreased)
S

Two flow augmentations later


u1

v3

u2

v4

our example: edge (u2,v4) has disappeared

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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm

Idea: (u,v) can become critical at most O(V) times (After beeing critical it disappears in Gf and can only reappear after net flow is decreased)
S

After the third flow augmentation


u1

v3

2
u2 v4

our example: edge (u2,v4) reappeared but is now unreachable from s 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

Analysis of the Ford Fulkerson algorithm


Running time with Edmonds-Karp algorithm
Idea:

(u,v) can become critical at most O(|V|) times


O(|E|) pairs of vertices exist in Gf

All critical edges in O(|V| |E|)


O(|E|) for breath first search for p total running time O(|V| |E|) running time: O ( |V| |E| )

(2) Edmonds-Karp algorithm


In Ford Fulkerson algorithm

If augmenting path is found by breath-first search and has to be a shortest path from p to t then it become E-K algorithm

Different variants of the max-flow problem


- The algorithm of Dinic (different implementations reaps better running times than Edmonds-Karp): e.g. simultanous saturation of augmenting paths of the same length O(|V| |E|) - A second capacity function lim for a lower limit of the flow function f with lim(u,v) < f(u,v) < c(u,v)
- A cost function cost where each edge (u,v) has got a second weight cost(u,v) and the min-cost max-flow problem - Networks with multiple sources and sinks

Networks with multiple sources and sinks


s1

s2

t1 T

supersource

S s3 t2

supersink

s4

También podría gustarte