network flow & linear programming

18
Network Flow & Linear Programming Jeff Edmonds York University Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5- NetworkFlow.ppt

Upload: raja

Post on 07-Jan-2016

71 views

Category:

Documents


1 download

DESCRIPTION

Thinking about Algorithms Abstractly. Network Flow & Linear Programming. Jeff Edmonds York University. Network Flow. Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge has a maximum capacity c A source node s in which flow arrives - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Network Flow &  Linear Programming

Network Flow & Linear Programming

Jeff Edmonds York UniversityAdapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 2: Network Flow &  Linear Programming

•Instance: •A Network is a directed graph G •Edges represent pipes that carry flow•Each edge <u,v> has a maximum capacity c<u,v> •A source node s in which flow arrives•A sink node t out which flow leaves

Goal: Max Flow

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 3: Network Flow &  Linear Programming

•Instance: •A Network is a directed graph G •Edges represent pipes that carry flow•Each edge <u,v> has a maximum capacity c<u,v> •A source node s in which flow arrives•A sink node t out which flow leaves

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 4: Network Flow &  Linear Programming

•Solution: •The amount of flow F<u,v> through each edge.

•Flow can’t exceed capacity i.e. F<u,v> c<u,v>.•Unidirectional flow

F<u,v> 0 and F<v,u> = 0 orF<u,v> = 0 and F<v,u> 0

Some texts:F<u,v> = -F<v,u>

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 5: Network Flow &  Linear Programming

•Solution: •The amount of flow F<u,v> through each edge.

•Flow F<u,v> can’t exceed capacity c<u,v>.•Unidirectional flow•No leaks, no extra flow.

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 6: Network Flow &  Linear Programming

•Solution: •The amount of flow F<u,v> through each edge.

•Flow F<u,v> cant exceed capacity c<u,v>.•Unidirectional flow•No leaks, no extra flow.

For each node v: flow in = flow outu F<u,v> = w F<v,w>

Except for s and t.

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 7: Network Flow &  Linear Programming

•Value of Solution: •Flow from s into the network minus flow from the network back into s. rate(F) = u F<s,u>

= flow from network into t minus flow back in. = u F<u,t> - v F<t,v>

- v F<v,s>

What about flow back into s? Goal:

Max Flow

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 8: Network Flow &  Linear Programming

Network flow problem is a linear program

Flow in G = (V,E): f: V x V R with 3 properties:

1) Capacity constraint: For all u,v V : f(u,v) < c(u,v)

2) Skew symmetry: For all u,v V : f(u,v) = - f(v,u)

3) Flow conservation: For all u V \ {s,t} : f(u,v) = 0 v V

Taken from www.infosun.fim.uni-passau.de/br/lehrstuhl/Kurse/Proseminar_ss01/Network_flow_problems.ppt

Page 9: Network Flow &  Linear Programming

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-

NetworkFlow.ppt

Page 10: Network Flow &  Linear Programming

A network with its edge capacities

Network Flow

What is the maximum that can flow from s to t?

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 11: Network Flow &  Linear Programming

A network with its edge capacities

Network Flow

The max total rate of the flow is 1+2-0 = 3.

flow/capacity = 2/5

Can prove that total cannot be higher.

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 12: Network Flow &  Linear Programming

No more flow can be pushedalong the top path because the

edge <b,c> is at capacity.

Similarly, the edge <e,f>.

No flow is pushed along the bottom path because this would decrease the total from s to t.

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 13: Network Flow &  Linear Programming

<U,V> is a minimum cut

Its capacity is the sum of the capacities crossing the cut

= 1+2 = 3.

<i,j> is not included in because it is going in the wrong

direction.

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 14: Network Flow &  Linear Programming

The edges crossing forward across the cut are at capacity

those crossing backwards have zero flow.

This is always true.

Network Flow

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 15: Network Flow &  Linear Programming

The maximum flow is 1+2=3

The minimum cut is 1+2=3.

These are always equal.

Maxflow = Mincut

Adapted from www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt

Page 16: Network Flow &  Linear Programming

An Application: MatchingSam Mary

Bob Beth

John Sue

Fred Ann

Who loves whom.Who should be matched with whom

so as many as possible matchedand nobody matched twice?

3 matches Can we do better?4 matches

Adapted from www.cse.yorku.ca/~jeff/notes/3101/0

3.5-NetworkFlow.ppt

Page 17: Network Flow &  Linear Programming

An Application: Matching

s t

c<s,u> = 1•Total flow out of u flow into u 1•Boy u matched to at most one girl.

1

c<v,t> = 1•Total flow into v = flow out of v 1•Girl v matched to at most one boy.

1u v

Adapted from www.cse.yorku.ca/~jeff/notes/3101/0

3.5-NetworkFlow.ppt

Page 18: Network Flow &  Linear Programming

•Instance: •A Network is a directed graph G •Special nodes s and t.•Edges represent pipes that carry flow•Each edge <u,v> has a maximum capacity c<u,v>

•Partition into two regions so that the cut between the two is minimized

Min Cut

s

tAdapted from

www.cse.yorku.ca/~jeff/notes/3101/03.5-NetworkFlow.ppt