week 11.3, friday, nov 1 - purdue university · 1 week 11.3, friday, nov 1 midterm 2: grading in...

Post on 27-Jul-2020

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Week 11.3, Friday, Nov 1

Midterm 2: Grading in progressHomework 6: Planned Released on Monday, November 4th

2

Chapter 7

Network Flow

Slides by Kevin Wayne.Copyright © 2005 Pearson-Addison Wesley.All rights reserved.

Max Flow Recap

3

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10154

4capacity

source

sink

4

Towards a Max Flow Algorithm

Greedy algorithm. Start with f(e) = 0 for all edge e ∈ E. Find an s-t path P where each edge has f(e) < c(e). Augment flow along path P. Repeat until you get stuck.

greedy = 20

s

1

2

t

20 10

10 20

30

20 0

0

20

20

opt = 30

s

1

2

t

20 10

10 20

30

20 10

10

10

20

locally optimality ⇒ global optimality

5

Clicker Question: Greedy Max Flow Algorithm

Greedy algorithm. Start with f(e) = 0 for all edge e ∈ E. Find an s-t path P where each edge has f(e) < c(e). Augment flow along path P. Repeat until you get stuck.

For which of the following graphs is the greedy algorithm guaranteed to find the maximum flow?

A. Graph G1 only B. Graph G2 only C. Graph G3 only

D. Graphs G3 and G2 E. None of them

s

1

2

t

10

10

20

20

40 s

1

2

t

10

10

20

20

30 s

1

2

t

100

10

20

20

30

(G1)(G2) (G3)

6

7

Clicker Question: Greedy Max Flow Algorithm

Greedy algorithm. Start with f(e) = 0 for all edge e ∈ E. Find an s-t path P where each edge has f(e) < c(e). Augment flow along path P. Repeat until you get stuck.

For which of the following graphs is the greedy algorithm guaranteed to find the maximum flow?

A. Graph G1 only B. Graph G2 only C. Graph G3 only

D. Graphs G3 and G2 E. None of them

s

1

2

t

10

10

20

20

40 s

1

2

t

10

10

20

20

30 s

1

2

t

100

10

20

20

30

(G1) (G2) (G3)

10

10

1020

20

2010

10

10

8

9

10

11

Example

u

s t

v

15

5

20

15 5

5

Augmenting path s → v → u→ twith bottleneck capacity 5Results in a flow of 30

u

s t

v

20

20

30

10

10

u

s t

v

20

20

30

10

10

20

G, Gf

G,

f

20

515

5

20 5

5

5

f+f’20

10

1010

20

5

f’

10=f(u,v) – f’(v,u) = 15-5(flow negates on reverse edge

13

15

Ford-Fulkerson Algorithm

s

2

3

4

5 t10

10

9

8

4

10

1062

G:capacity

play

Initialize: f(e)=0 //empty flow While there remains an augmenting path P // s-t path in residual graph Gf

Augment(f,c,P) // Increases v(f)Update Gf

16

Augmenting Path Algorithm

Augment(f, c, P) {b ← bottleneck(P) foreach e ∈ P {

if (e ∈ E) f(e) ← f(e) + belse f(eR)← f(eR) - b

}return f

}

Ford-Fulkerson(G, s, t, c) {foreach e ∈ E f(e) ← 0Gf ← residual graph

while (there exists augmenting path P) {f ← Augment(f, c, P)update Gf

}return f

}

forward edgereverse edge

17

Max-Flow Min-Cut Theorem

Augmenting path theorem. Flow f is a max flow iff there are no augmenting paths.

Max-flow min-cut theorem. [Elias-Feinstein-Shannon 1956, Ford-Fulkerson 1956]

The value of the max flow is equal to the value of the min cut.

Pf. We prove both simultaneously by showing TFAE:(i) There exists a cut (A, B) such that v(f) = cap(A, B).

(ii) Flow f is a max flow.(iii) There is no augmenting path relative to f.

(i) ⇒ (ii) This was the corollary to weak duality lemma.

(ii) ⇒ (iii) We show contrapositive. Let f be a flow. If there exists an augmenting path, then we

can improve f by sending flow along path.

18

Proof of Max-Flow Min-Cut Theorem

(iii) ⇒ (i) (No augmenting paths relative to f cap(A,B)=v(g) for some cut A,B) Let f be a flow with no augmenting paths. Let A be set of vertices reachable from s in residual graph. By definition of A, s ∈ A. By definition of f, t ∉ A.

original network

s

t

A B

Must be 0 since there is noEdge from A to B in residual graph

Must be c(e) since there is no edgefrom A to B in residual graph

19

Proof of Max-Flow Min-Cut Theorem

(iii) ⇒ (i) Let f be a flow with no augmenting paths. Let A be set of vertices reachable from s in residual graph. By definition of A, s ∈ A. By definition of f, t ∉ A.

original network

s

t

A B

Must be 0 since there is noEdge from A to B in residual graph

20

Pseudo-polynomial

21

Ford-Fulkerson: Exponential Number of Augmentations

Q. Is generic Ford-Fulkerson algorithm polynomial in input size?

A. No. If max capacity is C, then algorithm can take C iterations.

s

v

w

t

C

C

0 0

0 0

0

C

C

1 s

v

w

t

C

C

1

0 0

0 0

0X 1

C

C

X

X

X

1

1

1

X

X

1

1X

X

X

1

0

1

m, n, and log C

22

7.3 Choosing Good Augmenting Paths

24

Choosing Good Augmenting Paths

Use care when selecting augmenting paths. Some choices lead to exponential algorithms. Clever choices lead to polynomial algorithms. If capacities are irrational, algorithm not guaranteed to terminate!

Goal: choose augmenting paths so that: Can find augmenting paths efficiently. Few iterations.

Choose augmenting paths with: [Edmonds-Karp 1972, Dinitz 1970] Max bottleneck capacity. Sufficiently large bottleneck capacity. Fewest number of edges e.g., BFS in residual graph.

Interested in knowing more about MaxFlow?2014 CACM Review paper by Goldberg and Tarjan posted on Piazza

http://cacm.acm.org/magazines/2014/8/177011-efficient-maximum-flow-algorithms/abstract

top related