40
4/5/05 Tucker, Sec. 4.3 1 Applied Combinatorics, 4rth Ed. Alan Tucker Section 4.3 Graph Models Prepared by Jo Ellis-Monaghan

Applied Combinatorics, 4rth Ed. Alan Tucker

  • Upload
    yasuo

  • View
    86

  • Download
    3

Embed Size (px)

DESCRIPTION

Applied Combinatorics, 4rth Ed. Alan Tucker. Section 4.3 Graph Models Prepared by Jo Ellis-Monaghan. Real World Applications Of Network Flows Maximizing the flow of oil between two cities using a large pipeline network. Maximizing the number of telephone calls possible between two places. - PowerPoint PPT Presentation

Citation preview

Page 1: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 1

Applied Combinatorics, 4rth Ed.Alan Tucker

Section 4.3

Graph Models

Prepared by Jo Ellis-Monaghan

Page 2: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 2

Real World Applications Of Network Flows

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

Page 3: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 3

•k(e) represents the capacity of an edge e in the network.

•f(e) is how much is actually going along the edge (the flow).

•s(e) = k(e) – f(e) is the slack on the edge. If s(e) = 0, say e is saturated.

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

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

Note: The edge labels are (k(e), f(e)), the capacity and flow on each edge.

Page 4: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 4

• a-z Flow: an integer-valued function f defined on each edge e that satisfies the following

conditions:

a)

b)

c)

0 ( ) ( )f e k e

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

For or , ( ) ( )e In x e Out x

x a z f e f e

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

Page 5: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 5

Cut:

Let denote the set of all edges with vertex

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

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

Bold edges are in the cut.

The grey edge is not in the cut since it goes from to P.

The dashed line represents the cut.

Say is an a-z cut if

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

and . P Px y

P

( , )P P and .a P z P

_________________________________________________

P( , )P P

Page 6: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 6

_________________________________________________The Capacity of a Cut:

Just add up the capacities on the edges going from P to .

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

( , )

( , )PPe

k k ePP

P

Here,

( , ) 5 5 3 13.k PP

Page 7: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 7

An observation:

Let P not contain a or z.

Since then

Note that if x and y are both in P, and there is an edge e from x to y, then f(e) appears on both sides of the equation, so we can cancel it.

( ) ( )

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

f e f e

( ) ( )

for or , ( ) ( ),e In x e Out x

x a z f e f e

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

P = {b,d,e}

Page 8: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 8

This leaves only flows on edges from a vertex in to a vertex in P on the left side of the equation, and only flows out of a vertex in P to a vertex in on the right side. Thus,

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

The flow into P equals the flow out of P.

P

P

b

( , ) ( , )

( ) ( )e P P e P P

f e f e

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

(sum of green-to-blue flows = sum of blue-to-green flows)

Page 9: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 9

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

Proof:

Let P be all vertices in N except a and z, so .

The only flow into P from {a,z} must be from a, since condition (c) forbids flow from z. Similarly by condition (c), all flow out of P must go to z.

Thus:

{ , }.P a z

( )

( , ) ( , )

flow out of ( ) ( ) flow into by b

e P P e P P

a f e f e z

_________________________________________________

_________________________________________________

Page 10: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 10

_________________________________________________The Value of an a-z Flow:

Just add up the flows on the edges going out of a,

or equivalently, going into z.

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

e Out a e In z

f f e f e

Here,

4 8 6 6.f

( ) ( )

( ) ( )e Out a e Out a

f f e k e

Note,

Page 11: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 11

Theorem 2:

Intuitively, should equal the total flow from which is bounded by .

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

( , )P P

( , ).f k P P

f to P P( , )K P P

_________________________________________________

_________________________________________________

Page 12: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 12

Expand the network N by adding a new vertex with an edge of immense capacity, and flow .

Note that and z will be in for the resulting cut.

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

a P

Proof:

za’e’

a

P Poriginal

Edges between P and P

, f

f

Page 13: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 13

Proof: Continued…

Now apply condition ( ) from slide 8 to P in the new network.

It says that the flow into P, which is at least equals the flow out of P. Thus:

b

( )

( , ) ( , ) ( , )

( ) ( ) ( ) ( , )by b

e P P e P P e P P

f f e f e k e k P P

f

za’e’

a

, f

Page 14: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 14

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

if and only if:

(i) For each edge

(ii) For each edge

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

( , )P P( , )f k P P

( , )f k P P( , )P P

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

( , ), ( ) ( ).e P P f e k e

_________________________________________________

Page 15: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 15

Proof: Corollary 2aRecall:

The first inequality is an equality—the flow from into P (in the expanded network) equals –if condition (i) holds;

so that e’ is the only edge feeding into P,

otherwise the flow into P is greater than .

Pf

_________________________________________________

( )

( , ) ( , ) ( , )

( ) ( ) ( ) ( , )by b

e P P e P P e P P

f f e f e k e k P P

f

( , ), ( ) 0e P P f e

Page 16: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 16

The second inequality is an equality—the flow out of P equals –if condition (ii) holds;

otherwise it is less.

Thus if and only if conditions (i) and (ii) are both true.

The last sentence in the corollary follows directly from Theorem 2

( , )k P P

( )

( , ) ( , ) ( , )

( ) ( ) ( ) ( , )by b

e P P e P P e P P

f f e f e k e k P P

Proof: Corollary 2a, continued…_________________________________________________

( , ), ( ) ( )e P P f e k e

( , )f k P P

Page 17: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 17

By Theorem 2,

Thus if

Then is as big as possible

(say f is a maximum flow),

and is as small as possible

(say is an a-z cut of minimal capacity).

Proof: Corollary 2a, continued…_________________________________________________

( , ).f k P P

( , )f k P P

( , )k P P

f

( , )P P

Page 18: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 18

Goal-- Find maximum flows in networks.

Method I: Flow paths

(Fast and easy, but not necessarily the best)

b

a

d

c

z

e8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

A flow path is just a path from a to z.

Page 19: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 19

Basic idea• Find a flow path and push as much as possible along it.• Find another flow path, using only unsaturated edges, and

push as much as possible along it.• And so on, until you can’t find any more flow paths along

unsaturated edges.

Page 20: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 20

a

b d

c e

z

5,3 6,3

3,3

1,06,0

6,0

5,0

3,0

Start with 0 flow on all edges.

Find a flow path, L1. Can push 3 units along it.

Find another flow path, L3. Can push 3 units along it.

a

b d

c e

z

5,0 6,0

3,0

1,06,0

6,0

5,0

3,0

a

b d

c e

z

5,3+2 6,3

3,3

1,06,2

6,2

5,0

3,0

Find another flow path, L2. Can push 2 units along it.

Find another flow path, L4. Can push 1 unit along it.

Can’t do any more, so the flow is f = 3 L1 + 2 L2 + 3 L3 + 1 L4

a

b d

c e

z

5,3+2 6,3

3,3

1,06,2+3

6,2

5,3

3,3

a

b d

c e

z

5,3+2 6,3+1

3,3

1,16,2+3

6,2

5,3+1

3,3

Page 21: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 21

Note--all of the edges have been saturated in the cut ,where , and , so

And hence by corollary 2a on slide 14, this flow is maximal.

How do we know….• That we are done?• That this is the best possible flow?

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

a

b d

c e

z

5,3+2 6,3+1

3,3

1,16,2+3

6,2

5,3+1

3,3

= the sum of the flow out of a.

9f

Page 22: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 22

Yes, but how would we find the cut in a large messy network?

And what if we hadn’t noticed the last flow path and stopped too soon?

Also note that we were essentially trying all possible paths from a to z, which isn’t

feasible in a large network.

Page 23: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 23

1. Label vertex a: [__, ].2. Pick a labeled vertex p with label [v*, n], and consider the

unlabeled vertices adjacent to it.a. Label a vertex on a incoming edge e by [p-, m], where m = min{n, f(e)}

provided that f(e) > 0 b. Label a vertex on an outgoing edge e by [p+, m], where m = min{n, s(e)},

provided that s(e) > 0

If you can’t label any more vertices following the procedure in step 2, (if the edge flows and slacks are all zero), and z is unlabeled, then….

Let P be the set of labeled vertices, and is a saturated a-z cut, so

is a minimal cut and f is a maximal flow with by Cor. 2a

Augmenting Flow Algorithm

( , )P P

( , )P P ( , )f k P P

Page 24: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 24

3. If z has been labeled, go to step 4. Otherwise, go to step 2.

4. Find an a-z chain* backtracking the labels. Increase the flow in the forward edges from a to z (decrease the flow in the backward edges) m units, where m is the second label on z.

5. Remove all the vertex labels (but not the new edge labels!) and return to step 1. Continue doing this until you get stuck on step 2, which is when you are finished, having found a min cut/max flow.

* A chain is just a path along the edges of the graph that doesn’t have to follow the directions of the arrows.

Augmenting Flow Algorithm, cont…

Page 25: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 25

Tip…This algorithm assumes that the original flow is 0 on all the

edges, and for a computer program this works just fine.

However, if you are finding a max flow by hand, you can reduce the amount of work by starting with a ‘pretty good’ flow constructed from flow paths before implementing the algorithm.

In fact, if your ‘pretty good’ flow is actually maximal, the algorithm will confirm this in the first run through (you will get stuck on step 2 before reaching z).

Page 26: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 26

6,0

7,0

5,04,0

4,0

4,0

12,03,0

5,0

4,0

7,0

9,0

Start with 0 flow….

Example

a

d

c

f

b e

z

K1

K2

K3

4K1 + 5K2 + 4K3

a c

f

e

z

6,4

7,4

5,04,0

4,0

4,4

12,93,0

5,4

4,4

7,5

9,9d

b

Use flow paths to get a ‘pretty good’ flow.

Page 27: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 27

Apply algorithm

6,4

7,4

5,0

4,0

4,0

4,4

12,9

3,0

5,4

4,4

7,5

9,9

ac

f

e

z

d

b

Page 28: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 28

Getting…

6,4

7,4

5,0

4,0

4,0

4,4

12,9

3,0

5,4

4,4

7,5

9,9

ac

f

e

z

d

b

(_, ∞)

(a+, 2) (c+ ,2)

(f+ ,2)

(b+, 2)

(d-, 2)

(a+, 2)

Now backtrack from z to get an a-z chain

Page 29: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 29

Now augment along the chain from a to z by the amount of the label on z

6,4

7,4

5,0

4,0

4,0

4,4

12,9+2

3,0+2

5,4-2

4,4

7,5+2

9,9

ac

f

e

z

d

b

Page 30: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 30

Now run the algorithm again on this new flow.

6,4

7,4

5,0

4,0

4,0

4,4

12,11

3,2

5,2

4,4

7,7

9,9

ac

f

e

z

d

b

Page 31: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 31

6,4

7,4

5,0

4,0

4,0

4,4

12,11

3,2

5,2

4,4

7,7

9,9

ac

f

e

z

d

b

Getting…

(_, ∞)

(c+, 2) (c+ ,1)

(f+ ,1)

(b+, 2)

(e+, 2)

(a+, 2)

Now backtrack from z to get an a-z chain

Page 32: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 32

6,4+1

7,4+1

5,0

4,0

4,0+1

4,4

12,11+1

3,2+1

5,2

4,4

7,7

9,9

ac

f

e

z

d

b

Now augment along the chain from a to z by the amount of the label on z

Page 33: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 33

6,5

7,5

5,0

4,0

4,1

4,4

12,12

3,3

5,2

4,4

7,7

9,9

ac

f

e

z

d

b

Now run the algorithm again on this new flow.

Page 34: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 34

6,5

7,5

5,0

4,0

4,1

4,4

12,12

3,3

5,2

4,4

7,7

9,9

ac

f

e

z

d

b

(_, ∞)

(c+, 1)

(b+, 1)

(e+, 1)

(a+, 1)

The capacity of the cut is the size of the flow, here 9 + 3 + 4 =16.

Can’t label any more, so let P be the labeled vertices.

Page 35: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 35

Theorem 3

• For any given a-z flow f, a finite number of applications of the augmenting flow algorithm yields a maximum flow.

• If P is the set of vertices labeled during the final application of the algorithm, then is a minimal a-z cut set.( , )P P

Page 36: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 36

• If f is the current flow and K is the augmenting a-z flow chain, we must show the new flow f + m K is a legal flow, where m is the label on z.

Check that f + m K satisfies the flow conditions:

So yes, it is a valid flow.

Proof of Theorem 3

Page 37: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 37

Each time we reach z in the algorithm, we augment the flow by a positive integer m, increasing the flow along some edges. But the capacities on the edges (and the number of edges) is finite, so eventually the algorithm must get stuck on step 2, failing to label z.

Proof of Theorem 3 (cont.)

Page 38: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 38

Proof of Theorem 3 (cont.)

• Let P be the set of labeled vertices when z is not labeled.

• Clearly is an a-z cut since a is labeled and z is not.

( , )P P

Page 39: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 39

• There is no edge with non-zero slack (i.e. where the flow on the edge doesn’t equal the capacity) from any labeled vertex p to any unlabeled vertex q or else q would have been labeled.

• Thus, by Cor. 2a, is minimal and the flow is maximal.

Proof of Theorem 3 (cont.)

( , ) k P P

Page 40: Applied Combinatorics, 4rth Ed. Alan Tucker

4/5/05 Tucker, Sec. 4.3 40

b

a

d

c

z

e

8,8

5,5

4,34,0

5,5

3,24,1

7,67,4

8,6

Class exercise—apply augmenting flow algorithm.