slides15 - max flowsheldon/teaching/mhc... · slides15 - max flow author: dan created date:...

14
Network Flow

Upload: others

Post on 16-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Network Flow

Page 2: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Algorithm Design

GreedyDivide and

Conquer

DynamicProgramming

Network Flow?

Formulate problem -- -- -- --

Design algorithm easy hard hard ?

Prove correctness hard easy easy ?

Analyze running time

easy hard easy ?

Page 3: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Network Flow

Previous topics → design techniquesNetwork flow → a specific class of problems

Many applications“Traffic” in networks: cars/highways, packets/internet, water/pipesLess obvious: bipartite matching, airline scheduling, baseball elimination, and many, many more...

Page 4: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Network Flow

Goal: design and analyze algorithms for max-flow problem, then apply to solve other problems

Page 5: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Flows and Cuts:Soviet Rail Network, 1955

Reference: On the history of the transportation and maximum flow problems.Alexander Schrijver in Math Programming, 91: 3, 2002.

Page 6: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Example and definitions on board

Page 7: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Flow Network

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10 15 4

4capacity

source sink

Page 8: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10 15 4

4

source sink

flow = 4 4

44

0

0

0

0

0

0

0

0

0 0

0

Flow Network

Page 9: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Flows

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10 15 4

4

source sink

flow = 4 4

44

0

0

0

0

0

0

0

0

0 0

0

value = 4

Page 10: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Flows

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10 15 4

4

source sink

flow = 10 0

09

4

10

9

1

0

6

1

10

0 9

6

value = 24

Page 11: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Find s-t flow of maximum value.

Maximum Flow Problem

s

2

3

4

5

6

7

t

15

5

30

15

10

8

15

9

6 10

10

10 15 4

4

source sink

flow = 10 1

010

5

13

9

0

0

8

3

13

0 9

9

value = 28

Page 12: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Augmenting Path

Augment(f, P) { b = bottleneck(P, f) foreach e = (u,v) ∈ P { if e is a forward edge f(e) = f(e) + b else let e’ = (v, u) f(e’) = f(e’) - b } return f}

// least residual capacity of any edge in P

Use path P in Gf to to update flow in G

// forward edge: increase flow

// backward edge: decrease flow

Example on board

Page 13: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Ford-Fulkerson Algorithm

Ford-Fulkerson(G, s, t) { foreach e ∈ E f(e) = 0 // initially, no flow Gf = copy of G // residual graph = original graph

while (there exists an s-t path P in Gf) { f = Augment(f, P) // change the flow update Gf // build a new residual graph } return f}

Repat: find an augmenting path, and augment!

Page 14: Slides15 - Max Flowsheldon/teaching/mhc... · Slides15 - Max Flow Author: Dan Created Date: 4/9/2014 1:38:56 AM

Next Time

Termination and running time (easy)

Correctness: Max-Flow Min-Cut Theorem