Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Maximum Flow CSC 172 SPRING 2002 LECTURE 27

2 Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming edges) Sink, “t” (no outgoing edges)

3 Example Source s t Sink 2 2 2 2 2 3 1 2 1 1 4 2

4 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

5 Example Source s t Sink 2 2 2 2 2 3 1 2 1 1 4 12 1 0 2 1 0 1 1 1 1 22

6 Formally Flow(u,v)  edge(u,v) Capacity rule  edge(u,v) 0 <= flow <= capacity Conservation rule  u  in(v) flow(u,v) =  u  out(v) flow(v,w) Value rule |f| =  w  out(s) flow(s,w) =  u  in(t) flow(u,t)

7 Maximum Flow Problem Given a network N, find a flow of maximum value Applications Traffic movement Hydraulic systems Electrical circuits Layout

8 Example Source s t Sink 2 2 2 2 2 3 1 2 1 1 4 22 1 1 1 1 1 2 1 0 1 22

9 Augmenting Path t s 2 2 1 1 2 2 2 1 2 1 Network with flow 3

10 Augmenting Path t s 2 2 1 1 2 2 2 1 2 1 Network with flow 3 t s 2 2 2 1 0 2 Augmenting Path

11 t s 2 2 1 1 2 2 2 1 2 1 Network with flow 3 t s 2 2 2 1 0 2 Augmenting Path t s 2 2 2 1 2 2 2 0 2 2 Result

12 Augmenting Path Forward Edges flow(u,v) < capacity we can increase flow Backward edges flor(u,v) > 0 flow can be decreased

13 Max Flow Theorem A flow has maximum value if and only if it has no augmenting path

14 Ford & Fulkerson Flow Algorithm Initialize network with null flow Method FindFlow if augmenting path exists then find augmenting path increase flow recursively call FindFlow

15 Finding Flow t s 2 2 0 1 2 2 0 0 0 0 Initialize Network

16 Finding Flow t s 2 2 0 1 2 2 1 1 1 0 Send one unit of flow through

17 Finding Flow t s 2 2 0 1 2 2 2 1 1 1 Send another unit of flow through

18 Finding Flow t s 2 2 1 1 2 2 2 1 2 1 Send another unit of flow through

19 Finding Flow t s 2 2 2 1 2 2 2 0 2 2 Send another unit of flow through Note that there is still an augmenting Path that can proceed backwards

20 Finding Flow t s 2 2 2 1 2 2 2 0 2 2 Send another unit of flow through Note that there are no more Augmenting paths

21 Residual Network N f v u c(u,v) f(u,v)

22 Residual Network N f v u c(u,v) f(u,v) v u c f (u,v)=f(u,v) c f (u,v)=c(u,v)-f(u,v)

23 Residual Network In N f all edges (w,z) with capacity c f (w,z)=0 are removed Augmenting Path in N is a direct path in N f Augmenting paths can be found by performing a depth-first search on the residual network N f

24 Finding Augmenting Path t s 2 2 1 1 2 2 2 1 2 1

25 t s 2 2 1 1 2 2 2 1 2 1 t s 1 1 1 2 2 1 1


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

Similar presentations


Ads by Google