Transcript

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

1

Network Flows

Michael Duquette & Whitney Sherman

Tucker, Applied Combinatorics, Section 4.2a, Group G

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

2

In this section we will be focusing on analyzing network flows in order to maximize a flow from a starting vertex to an ending vertex.

Real World Applications:

•Maximizing the flow of oil between two cities using a large pipeline network.

•Maximizing the number of telephone calls possible between two places.

•Calculating the maximum bandwidth of a computer network.

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

3

Assume initially that all networks are directed.

Definitions:

•K(e) represents the capacity or upper bound for a particular edge e in a network.

•In(x) = Set of edges directed into x.

•Out(x) = Set of edges directed out from x.

•Source, a = Initial starting vertex.

•Sink, z = Ending vertex.

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

4

Definitions: Continued

• a-z Flow, = Integer-valued function defined on each edge e that satisfies the following

conditions:

a)

b)

c)

0 ( ) ( )e K e

( ) 0 if ( ) or ( )e e In a e Out z

( ) ( )

For x or ,

( ) ( )e In x e Out x

a z

e e

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

5

Sample Flow: Figure 4.2, pg 138

b

a

d

c

z

e

8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

Note: The numbers corresponding to each edge represent (K(e), (e)), the capacity and flow of each edge.

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

6

Cut:

Let denote the set of all edges with vertex

This set is known as a cut. Note: denotes the complement of P.

Example:b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

The cut ({a,b,c}, {d,e,z}) consists of the edges:

Note: is not in the cut since it goes from to P.

The dashed line represents the cut.

Note: is considered an a-z cut if

( , )P P ( , )x y��������������

and .x P y P

( , )P P P

( , ), ( , ) and ( , ).b d b e c e������������������������������������������

( , )d c��������������

P

( , )P P and .a P z P

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

7

Let be an a-z flow in the network N and let P be a subset of vertices in N not containing a or z. If we sum together the conservation-of-flow equations from condition (c) on slide 4 for each we obtain:

x P

( ) ( )

( ) ( )x P e In x x P e Out x

e e

After some elimination of duplicate vertices (flows) we reach the following condition:

( ) For each vertex subset P not containing a or z,

Meaning that the flow into P equals the flow out of P

( , ) ( , )

( ) ( )e P P e P P

e e

c

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

8

Theorem 1:For any a-z flow in a network N, the flow out of a equals the flow into z.

Proof:

Assume temporarily that N contains no edge . Let P be all vertices in N except a and z. So Then consists of edges going into z (from P) and consists of edges going out of a (to P). Thus:

Remember that the only flow into P from {a,z} must be from a, since condition (b) forbids flow from z. Similarly by condition (b), all flow out of P must go to z. The flow equality still holds if there is flow in an edge .

( , )a z��������������

{ , }.P a z ( , )P P

( , )P P

( )

( , ) ( , )

flow out of ( ) ( ) flow into by c

e P P e P P

a e e z

( , )a z��������������

_________________________________________________

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

9

Let denote the value of the a-z flow . This value equals the sum of the flow out of a, or equivalently the flow into z.

( ) ( )

( ) ( )e Out a e Out a

e K e

Define the capacity of cut :

Example:

This tells us that no a-z flow in the network can have a value greater than 13.

( , )K P P ( , )P P( , )

( , ) ( )e P P

K P P K e

The capacity of the a-z cut where P = {a,b,c} = 5+3+5 = 13.

( , )P P

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

10

Theorem 2:

Informally, should equal the total flow from (which is bounded by ), but we cannot prove an equality of this type using condition ( ) without first modifying N. We cannot use ( ) in N because condition ( ) requires that P not contain the source a.

Expand the network N by adding a new vertex with an edge of immense capacity. Note that will be part of .

For any a-z flow and any a-z cut in a network N,

Proof:

( , )P P( , ).K P P

to P P( , )K P P

a( , )e a a ��������������

aP

_________________________________________________

_________________________________________________

ccc

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

11

Proof: Theorem 2 Continued

Assign a flow value of to , yielding a valid flow in the expanded network. In effect, the old source a now gets its flow from the “super source” . In the new network, we can apply condition ( ) to P. It says that the flow into P, which is at least (other flow could come into P along edges from ), equals the flow out of P. Thus:

( )

( , ) ( , ) ( , )

( ) ( ) ( ) ( , )by c

e P P e P P e P P

e e K e K P P

e a z

a

P

_________________________________________________

c

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

12

Corollary 2a:For any a-z flow and any a-z cut in a network N,

if and only if:

(i) For each edge

(ii) For each edge

Further, when , is a maximal flow and is an a-z cut of minimal capacity.

( , )P P( , )K P P

( , )K P P ( , )P P

( , ), ( ) 0.e P P e

( , ), ( ) ( ).e P P e K e

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

13

Proof: Corollary 2aConsider the following inequalities of the proceeding proof:

The first inequality is an equality—the flow from into P (in the expanded network) equals –if condition (i) holds; otherwise the flow into P is greater than . The second inequality is an equality—the flow out of P equals –if condition (ii) holds; otherwise it is less. Thus the equality holds in the figure above if and only if conditions (i) and (ii) are both true. The last sentence in the corollary follows directly from Theorem 2.

( )

( , ) ( , ) ( , )

( ) ( ) ( ) ( , )by c

e P P e P P e P P

e e K e K P P

P

( , )K P P

_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

14

All normal flows can be decomposed into a sum of unit-flow paths from a to z, for short, a-z unit flows.

An a-z unit flow along a-z path L is defined as if e is in L and = 0 if e is not in L.

We will begin building up a flow in order to build a maximal flow by successively adding a-z unit flows together.

Example:

Note: Make sure that you do not exceed any edge’s capacity.

L ( ) 1L e

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

1L a b d z 1

So our flow is 5 .L

1 2Now our flow is 5 5 .L L

2L a c e z

...etc.

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

15

Unsaturated Edges: Edges where the present flow does not equal the capacity.

Slack: Calculate the slack of edge e in flow by the following equation:

( )s e

( ) ( ) ( ).s e K e e

Definitions:_________________________________________________

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

16

Example• We start with no flow

• Find a path from a to z:

• The minimum slack on is 3 (at the start, the slack of each edge is just the capacity)

• Add to the initial zero flow

• All edges except are unsaturated

a

b d

c e

z

5

6

6

6

3

5

3

1

Minimum slack = 3

1L a b d z

13 L

1L

( , )b d

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

17

a

b d

c e

z

5

6

6

6

3

5

3

1

Example Continued• The next a-z path is which also has a minimum

slack of 3

• The current flow is

• The path with minimum slack 2 gives us

• Note that not all edges are saturated yet (see figure 2)

Minimum slack = 3

a

2

ec

b d

z1 4

1

3

Figure 2: slack in unsaturated edges

For .

2L a c e z

1 23 3L L 3L a b e z 32 L

1 2 33 3 2L L L

Minimum slack = 2

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

18

Example Continued• There is only one path that can be formed from the previous figure 2

and that is having a minimum slack of 1• Now it is not possible to go anywhere except from a to c• All of the edges have been saturated in the cut where • The value of the final flow is 9 which equals the capacity of

this cut• By corollary 2 the flow must be maximal

a

b d

c e

z

5, 5

1, 1 6, 2

5, 4

3, 3

3, 3

6, 5

6, 4

4L a c d z

a z ( , )P P { , }P a c( , )k P P

1 2 3 43 3 2L L L L

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

19

Augmenting Flow Algorithm Example• We want to find the maximum flow from a to z• Let the initial flow be where

• Now apply the labeling: label (by definition, there cannot be incoming edges to the source with flow)

• Edge has slack and b is unlabeled so label (2 is the minimum of and s(a, b))

• Edge has no slack, edge has slack so label it

a

d

c

f

b e

z

K1K2 K3

(-, )c

f

e

z

1 2 34 4 5K K K 1 2 3, ,K a b e z K a c d f z K a d f z

( , )a

( , )a b ( , ) 2 0s a b ( , 2)b a

( )a( , )a c

( , )a d

( , ) 2s a d

( , 2)a

( , 2)a

( , 2)a

6,4

7,4

5,04,0

4,0

4,4

12,93,0

5,4

4,4

7,5

9,9

6,4

7,4

5,04,0

4,0

4,4

12,93,0

5,4

4,4

7,5

9,9

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

20

Example Continued• Next scan b, (scan vertices in the order that they are labeled)

• There are two incoming edges, edge has but it is already labeled, edge has no flow, outgoing edge has slack

and e is unlabeled, so label

• Scan d, edge comes from a labeled vertex, edge has

and c is not labeled so using step 2a label edge is saturated

• No labeling can be done from e

• At c label f with

• At f label z with

(-, )

( , )a b

( , ) 4 0a b

( , )c b

( , )b e

( , ) 3s b e

( , 2)e b

( , )a d

( , )c d

( , ) 4c d

( , 2),c d ( , )d f

( , 2)c

( , 2)f

( , 2)f

( , 2)c

( , 2)d

( , 2)b

( , 2)a

( , 2)a

6,4

7,4

5,04,0

4,0

4,4

12,93,0

5,4

4,4

7,5

9,9

3/17/2003 Tucker, Applied Combinatorics Section 4.2a

21

Class ExampleFind a maximal flow from a to z in this network.

a

b e

d

c g

fz

30

10

10

20

305

10

10

5

30

10

20

10

2020

110 Labez

55 Labdfz 65 Labdefz

410 Lacgfz 310 Lacgz

210 Lagz

1 2 3 4 5 610 10 10 10 5 5 50L L L L L L


Recommended