• Keine Ergebnisse gefunden

25. Flow in Networks

N/A
N/A
Protected

Academic year: 2021

Aktie "25. Flow in Networks"

Copied!
27
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

25. Flow in Networks

Flow Network, Maximal Flow, Cut, Rest Network, Max-flow Min-cut Theorem, Ford-Fulkerson Method, Edmonds-Karp Algorithm, Maximal Bipartite Matching [Ottman/Widmayer, Kap. 9.7, 9.8.1], [Cormen et al, Kap. 26.1-26.3]

719

(2)

Motivation

Modelling flow of fluents, components on conveyors, current in electrical networks or information flow in communication networks.

720

(3)

Flow Network

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

Antiparallel edges forbidden:

(u, v) ∈ E ⇒ (v, u) 6∈ E. Model a missing edge (u, v) by c(u, v) = 0.

Sources and sink t: special nodes.

Every nodev is on a path between s and t: s v t

s

v1

v2

v3

v4

t 16

13

12

14

20

4

4 9 7

721

(4)

Flow

A Flow f : V ×V → R fulfills the following conditions:

Bounded Capacity:

For all u, v ∈ V: 0 ≤f(u, v) ≤c(u, v). Conservation of flow:

For all u ∈ V \ {s, t}: X

v∈V

f(v, u)−X

v∈V

f(u, v) = 0.

s

v1

v2

v3

v4

t 16/8

13/10

12/12

14/10

20/14

4/4 9/4

4/4 7/6

Valueof the flow:

w(f) =P

v∈V f(s, v)−P

v∈V f(v, s).

Herew(f) = 18.

722

(5)

How large can a flow possibly be?

Limiting factors: cuts

cut separating s fromt: Partition of V into S and T with s ∈ S, t ∈ T.

Capacityof a cut: c(S, T) = P

v∈S,v0∈T c(v, v0) Minimal cut: cut with minimal capacity.

Flow over the cut: f(S, T) =P

v∈S,v0∈T f(v, v0)−P

v∈S,v0∈T f(v0, v)

723

(6)

How large can a flow possibly be?

For each flow and each cut it holds thatf(S, T) =w(f):

f(S, T) = X

v∈S,v0∈T

f(v, v0) X

v∈S,v0∈T

f(v0, v)

= X

v∈S,v0∈V

f(v, v0) X

v∈S,v0∈S

f(v, v0) X

v∈S,v0∈V

f(v0, v) + X

v∈S,v0∈S

f(v0, v)

= X

v0∈V

f(s, v0) X

v0∈V

f(v0, s) Second equality: amendment, last equality: conservation of flow.

s

v1

v2

v3

v4

t 16/8

13/10

12/12

14/10

20/14

4/4 9/4

4/4 7/6

724

(7)

Maximal Flow ?

In particular, for each cut (S, T)of V. f(S, T) ≤ X

v∈S,v0∈T

c(v, v0) = c(S, T)

Will discover that equality holds forminS,Tc(S, T).

s

v1

v2

v3

v4

t 16

13

12

14

20

4

4 9 7

c= 23

725

(8)

Maximal Flow ?

Naive Procedure

s

v1

v2

v3

v4

t 16/8

13/10

12/12

14/10

20/14

4/4

4/4 9/4 7/6 s

v1

v2

v3

v4

t 16/8

13/11

12/12

14/11

20/15

4/4

4/4 9/4 7/7

s

v1

v2

v3

v4

t 16/8

13/13

12/12

14/11

20/17

4/4

4/4 9/2 7/7 s

v1

v2

v3

v4

t 16/10

13/13

12/12

14/11

20/19

4/4

4/2 9/0 7/7

Conclusion: greedy increase of flow does not solve the problem.

726

(9)

The Method of Ford-Fulkerson

Start with f(u, v) = 0 for all u, v ∈ V

Determine rest network* Gf and expansion path in Gf Increase flow via expansion path*

Repeat until no expansion path available.

*Will now be explained

727

(10)

Increase of flow, negative!

Let some flowf in the network be given.

Finding:

Increase of the flow along some edge possible, when flow can be increased along the edge,i.e. if f(u, v) < c(u, v).

Rest capacitycf(u, v) =c(u, v)−f(u, v).

Increase of flow against the directionof the edge possible, if flow can be reduced along the edge, i.e. iff(u, v) > 0.

Rest capacitycf(v, u) =f(u, v).

728

(11)

Rest Network

Rest network Gf provided by the edges with positive rest capacity:

s

v1

v2

v3

v4

t 16/8

13/10

12/12

14/10

20/14

4/4

4/4 9/4 7/6

s

v1

v2

v3

v4

t 8

8

3 10

12

4 10

6 14

4 5

4

4 1 6

Rest networks provide the same kind of properties as flow networks with the exception of permitting antiparallel edges

729

(12)

Observation

Theorem

Let G= (V, E, c) be a flow network with source sand sink t andf a flow inG. Let Gf be the corresponding rest networks and let f0 be a flow inGf. Then f ⊕f0 defines a flow in Gwith value w(f) + w(f0).

(f ⊕f0)(u, v) = (

f(u, v) +f0(u, v)−f0(v, u) (u, v) ∈ E

0 (u, v) 6∈ E.

730

(13)

Proof

Limit of capacity:

(f ⊕f0)(u, v) =f(u, v) +f0(u, v)−f0(v, u)

≥ f(u, v) +f0(u, v)−f(u, v) =f0(u, v) ≥ 0 (f ⊕f0)(u, v) = f(u, v) +f0(u, v)−f0(v, u)

≤ f(u, v) +f0(u, v)

≤ f(u, v) +cf(u, v)

= f(u, v) +c(u, v)−f(u, v) = c(u, v).

731

(14)

Proof

Conservation of flow X

u∈V

(f ⊕f0)(u, v) = X

u∈V

f(u, v) +X

u∈V

f0(u, v)−X

u∈V

f0(v, u)

(Flow conservation off andf0)

= X

u∈V

f(v, u) +X

u∈V

f0(v, u)−X

u∈V

f0(u, v)

= X

u∈V

(f ⊕f0)(v, u)

732

(15)

Beweis

Value off ⊕f0 (in the sequel N+ := N+(s), N := N(s)):

w(f f0) = X

v∈N+

(f f0)(s, v) X

v∈N

(ff0)(v, s)

= X

v∈N+

f(s, v) +f0(s, v)f0(v, s) X

v∈N

f(v, s) +f0(v, s)f0(s, v)

= X

v∈N+

f(s, v) X

v∈N

f(v, s) + X

v∈N+∪N

f0(s, v) + X

v∈N+∪N

f0(v, s)

=X

v∈V

f(s, v)X

v∈V

f(v, s) +X

v∈V

f0(s, v) +X

v∈V

f0(v, s)

=w(f) +w(f0).

733

(16)

Flow in G

f

expansion path p: path from sto tin the rest network Gf. Rest capacitycf(p) = min{cf(u, v) : (u, v) edge in p}

Theorem

The mapping fp : V ×V → R, fp(u, v) =

(cf(p) if (u, v)edge in p 0 otherwise

provides a flow in Gf with value w(fp) = cf(p) > 0. [Proof: exercise]

734

(17)

Consequence

Strategy for an algorithm:

With an expansion pathp inGf the flow f ⊕fpdefines a new flow with value w(f ⊕fp) = w(f) + w(fp) > w(f)

735

(18)

Max-Flow Min-Cut Theorem

Theorem

Let f be a flow in a flow network G = (V, E, c)with source sand sink t. The following statementsa are equivalent:

1 f is a maximal flow in G

2 The rest network Gf does not provide any expansion paths

3 It holds thatw(f) =c(S, T) for a cut (S, T) of G.

736

(19)

Proof

(3) ⇒(1):

It holds thatw(f) ≤ c(S, T) for all cutsS, T. From w(f) = c(S, T) it follows that w(f) is maximal.

(1) ⇒(2):

f maximal Flow in G. Assumption: Gf has some expansion path w(f ⊕fp) = w(f) +w(fp) > w(f). Contradiction.

737

(20)

Proof (2) ⇒ (3)

Assumption:Gf has no expansion path. Define

S ={v V : there is a paths v inGf}.(S, T) := (S, V \S)is a cut:

sS, t6∈S. LetuSandv T.

If(u, v)E, thenf(u, v) =c(u, v), otherwise it would hold that(u, v)Ef. If(v, u)E, thenf(v, u) = 0, otherwise it would hold that

cf(u, v) =f(v, u)>0and(u, v)Ef

If(u, v)6∈E and(v, u)6∈E, thenf(u, v) = f(v, u) = 0.

Thus

w(f) =f(S, T) = X

u∈S

X

v∈T

f(u, v)X

v∈T

X

u∈s

f(v, u)

=X

u∈S

X

v∈T

c(u, v)X

v∈T

X

u∈s

0 = X

u∈S

X

v∈T

c(u, v) =c(S, T).

738

(21)

Algorithm Ford-Fulkerson( G, s, t )

Input : Flow network G= (V, E, c) Output : Maximal flowf.

for (u, v)E do f(u, v)0

whileExists path p:s t in rest network Gf do cf(p)min{cf(u, v) : (u, v)p}

foreach (u, v)p do if (u, v)E then

f(u, v)f(u, v) +cf(p) else

f(v, u)f(u, v)cf(p)

739

(22)

Analysis

The Ford-Fulkerson algorithm does not necessarily have to converge for irrational capacities. For integers or rational numbers it terminates.

For an integer flow, the algorithms requires maximallyw(fmax)iterations of the while loop.

Search a single increasing path (e.g. with DFS or BFS O(|E|)) Therefore O(fmax|E|).

s

u

v

t 1000

1000 1

1000

1000

With an unlucky choice the al- gorithm may require up to 2000 iterations here.

740

(23)

Edmonds-Karp Algorithm

Choose in the Ford-Fulkerson-Method for finding a path in Gf the expansion path of shortest possible length (e.g. with BFS)

741

(24)

Edmonds-Karp Algorithm

Theorem

When the Edmonds-Karp algorithm is applied to some integer valued flow networkG = (V, E) with source s and sink tthen the number of flow increases applied by the algorithm is in O(|V| · |E|) [Without proof]

742

(25)

Application: maximal bipartite matching

Given: bipartite undirected graphG = (V, E).

MatchingM: M ⊆ E such that|{m ∈ M : v ∈ m}| ≤ 1for all v ∈ V. Maximal MatchingM: MatchingM, such that |M| ≥ |M0|for each matchingM0.

743

(26)

Corresponding flow network

Construct a flow network that corresponds to the partitionL, R of a bipartite graph with source sand sink t, with directed edges froms to L, from L to Rand from R tot. Each edge has capacity1.

L R

s t

L R

744

(27)

Integer number theorem

Theorem

If the capacities of a flow network are integers, then the maximal flow generated by the Ford-Fulkerson method provides integer numbers for each f(u, v), u, v ∈ V.

[without proof]

Consequence: Ford-Fulkerson generates for a flow network that corresponds to a bipartite graph a maximal matching

M = {(u, v) : f(u, v) = 1}.

745

Referenzen

ÄHNLICHE DOKUMENTE

Generell lässt sich sagen, dass eine verständigungsorientierte Kultur durch geringe Machtdistanz, Unsicherheitsvermeidung, moderaten Medieneinsatz, Prozessorientierung und einen

A Media Flow is a normal Flow of media packets. There are no mandatory fields, as these Flows may also be exported by standard IPFIX devices not extended for SIP related monitoring

Since the capacities of these links are respectively equal to the maximum number of bits that can be sent by the source and maximum number of bits that can be received by

Keywords Combinatorial optimization · Network design · OLED · Algorithm engineering · Matrix decompositionM.

Utilizing this equivalence, we proceeded to define a topological notion of flow alignment between two edges in a network and proposed that such flow alignment will determine if an

The network formulation consists of breaking the network into a series of connected reaches; reducing the finite difference equations for each reach into two

Network flow analysis is employed to effect local optimizations and then dynamic programming ideas are introduced in order to piece the local solutions together into an optimal

ClaimFF2: The Ford-Fulkerson Algorithm terminates after finitely many steps, as long as all input parameters are natural or rational numbers.. Prf.: natural numbers: clear,