Network Flow Algorithm Design Divide and Dynamic Greedy Conquer - - PowerPoint PPT Presentation

network flow algorithm design
SMART_READER_LITE
LIVE PREVIEW

Network Flow Algorithm Design Divide and Dynamic Greedy Conquer - - PowerPoint PPT Presentation

Network Flow Algorithm Design Divide and Dynamic Greedy Conquer Programming Formulate problem ? ? ? Design algorithm less work more work more work Prove correctness more work less work less work Analyze running time less work


slide-1
SLIDE 1

Network Flow

slide-2
SLIDE 2

Algorithm Design

Greedy Divide and Conquer Dynamic Programming Formulate problem ? ? ? Design algorithm less work more work more work Prove correctness more work less work less work Analyze running time less work more work less work

slide-3
SLIDE 3

Network Flow

Greedy, Divide-and-Conquer, and Dynamic Programming were design techniques Network flow → a specific class of problems. Useful in many different applications! (matching, transportation, network design, etc.) Goal: design and analyze algorithms for max-flow problem, then apply to solve other problems

slide-4
SLIDE 4

Soviet Rail Network, 1955

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

slide-5
SLIDE 5

Flow network. Abstraction for material flowing through the edges. G = (V , E) = directed graph Two distinguished nodes: s = source, t = sink. c(e) = capacity of edge e.

Flow Networks

s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10 15 4 4 capacity source sink

slide-6
SLIDE 6

An s-t flow is a function f: E→ R+ that satisfies: Capacity condition: For each e ∈ E: 0 ≤ f(e) ≤ c(e) Conservation condition: For each v ∈ V – {s, t}: ∑ f(e) = ∑ f(e)

Flows

e into v e out of v

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 4 4

slide-7
SLIDE 7

The value of a flow f is: v(f) = ∑ f(e)

Flows

e out of s

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 4 4

value = 4

slide-8
SLIDE 8

The value of a flow f is: v(f) = ∑ f(e)

Flows

e out of s

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 9 4 10 9 1 6 1 10 9 6

value = 24

slide-9
SLIDE 9

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 10 5 13 9 8 3 13 9 9

value = 28

slide-10
SLIDE 10

Towards a Max Flow Algorithm

Greedy algorithm. Start with f(e) = 0 for all edges 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.

s 1 2 t 10 10 20 20 30

Flow value = 0

slide-11
SLIDE 11

Towards a Max-Flow Algorithm

Key idea: repeatedly choose paths and “augment” the amount of flow on those paths as much as possible until capacities are met

slide-12
SLIDE 12

Towards a Max Flow Algorithm

Greedy algorithm. Start with f(e) = 0 for all edges 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.

s 1 2 t 10 10 20 20 30

Flow value = 0

× × ×

20 20 20

×

20

slide-13
SLIDE 13

Optimal Solution

s 1 2 t 10 10

10 10

20 20 30

Flow value = 30

20 20 10

slide-14
SLIDE 14

Problem

To fix the greedy algorithm, we need a way to track: (1) how much more flow can we send on any edge? (2) how much flow can we “undo” on each edge?

s 1 2 t 10 10 20 20 30

20 20 20

slide-15
SLIDE 15

Residual Graph

Original edge: e = (u, v) ∈ E. Flow f(e), capacity c(e). Create two residual edges “Forward edge” e = (u, v) with capacity c(e) - f(e) “Backward edge” e’ = (v, u) with capacity f(e) Residual graph: Gf = (V , Ef ). Ef = edges with positive residual capacity Ef = {e : f(e) < c(e)} ∪ {e’ : f(e) > 0}

u v 17 6 u v 11

residual capacity

6

slide-16
SLIDE 16

Augmenting Path

Augment(f, P) { b = bottleneck(P) 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 } / / edge on P with least residual capacity

Use path P in Gf to to update flow in G

/ / forward edge: increase flow / / backward edge: decrease flow

Example on board

slide-17
SLIDE 17

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!

slide-18
SLIDE 18

Next Time

Termination and running time (easy) Correctness: Max-Flow Min-Cut Theorem