Top Banner
Maximum Flow CSC 172 SPRING 2002 LECTURE 27
25

Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Maximum Flow

CSC 172

SPRING 2002

LECTURE 27

Page 2: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Flow Networks

Digraph

Weights, called capacities, on edges

Two distinct veticiesSource, “s” (no incoming edges)

Sink, “t” (no outgoing edges)

Page 3: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Example

Source

s

t

Sink

2

2

2

2

2

3

1

21

1

4

2

Page 4: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Capacity and Flow

Edge Capacities

Non-negative weights on network edges

Flow

function on network edges

0 <= flow <= capacity

flow into vertex == flow out of vertex

Value

combined flow into the sink

Page 5: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Example

Source

s

t

Sink

2

2

2

2

2

3

1

21

1

4

1 21

0 21

0

11

1

1

22

Page 6: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

FormallyFlow(u,v) edge(u,v)

Capacity rule edge(u,v)

0 <= flow <= capacity

Conservation rule

uin(v) flow(u,v) = uout(v) flow(v,w)

Value rule

|f| = wout(s) flow(s,w) = uin(t) flow(u,t)

Page 7: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Maximum Flow Problem

Given a network N, find a flow of maximum value

ApplicationsTraffic movement

Hydraulic systems

Electrical circuits

Layout

Page 8: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Example

Source

s

t

Sink

2

2

2

2

2

3

1

21

1

4

2 21

1 11

1

21

0

1

22

Page 9: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Augmenting Path

t

s

2

2

1

12

2

2

12

1

Network with flow 3

Page 10: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Augmenting Path

t

s

2

2

1

12

2

2

12

1

Network with flow 3

t

s

2

2

2

10

2

Augmenting Path

Page 11: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Augmenting Path

t

s

2

2

1

12

2

2

12

1

Network with flow 3

t

s

2

2

2

10

2

Augmenting Path

t

s

2

2

2

12

2

2

02

2Result

Page 12: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Augmenting Path

Forward Edges

flow(u,v) < capacity

we can increase flow

Backward edges

flor(u,v) > 0

flow can be decreased

Page 13: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Max Flow Theorem

A flow has maximum value if and only if it has no augmenting path

Page 14: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Ford & Fulkerson Flow Algorithm

Initialize network with null flow

Method FindFlow

if augmenting path exists then

find augmenting path

increase flow

recursively call FindFlow

Page 15: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

0

12

2

0

00

0

Initialize Network

Page 16: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

0

12

2

1

11

0

Send one unit of flow through

Page 17: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

0

12

2

2

11

1

Send another unit of flow through

Page 18: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

1

12

2

2

12

1

Send another unit of flow through

Page 19: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

2

12

2

2

02

2

Send another unit of flow through

Note that there is still an augmentingPath that can proceed backwards

Page 20: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Flow

t

s

2

2

2

12

2

2

02

2

Send another unit of flow through

Note that there are no moreAugmenting paths

Page 21: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Residual Network Nf

v

u c(u,v)

f(u,v)

Page 22: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Residual Network Nf

v

u c(u,v)

f(u,v)

v

ucf(u,v)=f(u,v)

cf(u,v)=c(u,v)-f(u,v)

Page 23: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Residual Network

In Nf all edges (w,z) with capacity cf(w,z)=0 are removed

Augmenting Path in N is a direct path in Nf

Augmenting paths can be found by performing a depth-first search on the residual network Nf

Page 24: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Augmenting Path

t

s

2

2

1

12

2

2

12

1

Page 25: Maximum Flow CSC 172 SPRING 2002 LECTURE 27. Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming.

Finding Augmenting Path

t

s

2

2

1

12

2

2

12

1

t

s

1

1

12

2

1

1