Docsity

Maximum Flow and Maximum Matching - Iterative Improvement | COMP 157, Exams of Algorithms and Programming

Partial preview of the text

Download Maximum Flow and Maximum Matching - Iterative Improvement | COMP 157 and more Exams Algorithms and Programming in PDF only on Docsity!

Iterative

Improvement:

Maximum

Flow

Maximum

Matching

COMP

Nov

Iterative

Improvement

Strategy

To

solve

an

optimization

problem:

start

with

some

feasible

solution

improve

solution

by

repeated

application

of

some

simple

step

Potential

issues:

cheaply

finding

a

initial

solution

determining

what

changes

should

be

allowed

local

maxima/minima

Maximum

Flow

Problem

Is

this

the

maximum

flow?

S
T
A B

What can we observe about this cut

through the network?

Definition:

Cut

A

cut

is

a

partitioning

of

the

vertices

into

X

and

X

V

X

such

that

s

X

and

t

X

The

capacity

of

a

cut

is

the

sum

of

the

capacities

of

all

edges

that

cross

the

cut.

A

min

cut

is

a

cut

whose

capacity

capacity

of

all

other

cuts

Maximum

Flow

Problem

Lucky

Puck

needs

to

determine

the

rate

at

which

crates

of

hockey

pucks

can

be

sent

from

the

factory

in

Vancouver

to

the

warehouse

in

Winnipeg

(this

limits

the

rate

at

which

they

can

produce

pucks)

Edges

represent

the

daily

city

to

city

capacity

of

their

shipping

company.

Vancouver(factory)

Winnipeg(warehouse)

Regina

Calgary

Saskatoon

Edmonton

problem from

Introduction to Algorithms, 2

nd

ed

by Cormen, Leiserson, Rivest and Stein

Properties

of

a

Flow

Network

pucks

are

created

in

Vancouver

(the

source

pucks

are

stored

in

Winnipeg

(the

sink

all

other

cities

have

no

storage:

the

flow

in

and

out

of

these

cities

must

sum

to

zero

flow

conservation

the

flow

between

any

two

cities

cannot

exceed

the

shipping

capacity

between

the

cities

capacity

constraint

Vancouver

Winnipeg

Regina

Calgary

Saskatoon

Edmonton

Formalization

A

flow

in

G

is

a

function

f

V

x

V

Æ

R

that

satisfies:

capacity

constraint:

for

all

u

v

V

f

u

v

c

u

v

skew

symmetry:

for

all

u

v

V

f

u

v

f

v

u

flow

conservation:

for

all

u

V

s

t

The

value

of

a

flow

is

the

sum

of

the

flows

out

of

the

source

this

must

be

equal

to

∑

∈

=

V

v

v

u

f

0

)

,

(

∑

∈

V

v

v
s
f
f

∑

∈

V

v

t
v
f

Iterative

Improvement

Strategy

Ford

Fulkerson

method:

initialize

flow

to

zero

while

there

exists

an

augmenting

path

p:

augment

flow

along

p

return

flow

In

other

words,

find

a

path

which

has

unused

capacity,

and

add

it

to

the

flow

s

t

a

c

0/

0/

0/

0/

0/

b d

0/

0/

0/

0/

0/

we can add a flow of4 along s

Æ

c

Æ

d

Æ

t

Example

s

t

a

c

16/

0/

8/

4/

12/

b d

4/

0/

4/

16/

4/

add 3 alongs

Æ

c

Æ

d

Æ

b

Æ

t

s

t

a

c

16/

0/

11/

7/

12/

b d

4/

0/

4/

19/

7/

max flow: 23

Example

Where is the min-cut?

s

t

a b

0/

0/

0/

0/

c d

0/

0/

0/

max-flow is 3

Example

there’s too much flow

from a

Æ

d,

which prevents adding flow

from b

Æ

d

s

t

a b

2/

0/

0/

0/

c d

0/

2/

2/

To deal with this situation, we can allow augmentingpaths to go backward through edges. Backwardedges naturally subtract flow from the edge.

Example

s

t

a b

2/

0/

0/

0/

c d

0/

2/

2/

add 1 alongs

Æ

b

Æ

d

Æ

a

Æ

c

Æ

t

since d

Æ

a is a

backward edge,we subtract 1from a

Æ

d

s

t

a b

2/

1/

1/

1/

c d

1/

1/

2/

now we have amax flow of 3

Residual

Graph

s

t

a b

2/

0/

0/

0/

c d

0/

2/

2/

s

t

a b

2

4

3

1

c d

3

3

2

2

Example

with

Residual

Graph

residual with aug. path

network

figures from

Introduction to Algorithms, 2

nd

ed

by Cormen, Leiserson, Rivest and Stein