Maximum Flow CSC 172 SPRING 2002 LECTURE 27
Flow Networks Digraph Weights, called capacities, on edges Two distinct veticies Source, “s” (no incoming edges) Sink, “t” (no outgoing edges)
Example Source s t Sink
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
Example Source s t Sink
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)
Maximum Flow Problem Given a network N, find a flow of maximum value Applications Traffic movement Hydraulic systems Electrical circuits Layout
Example Source s t Sink
Augmenting Path t s Network with flow 3
Augmenting Path t s Network with flow 3 t s Augmenting Path
t s Network with flow 3 t s Augmenting Path t s Result
Augmenting Path Forward Edges flow(u,v) < capacity we can increase flow Backward edges flor(u,v) > 0 flow can be decreased
Max Flow Theorem A flow has maximum value if and only if it has no augmenting path
Ford & Fulkerson Flow Algorithm Initialize network with null flow Method FindFlow if augmenting path exists then find augmenting path increase flow recursively call FindFlow
Finding Flow t s Initialize Network
Finding Flow t s Send one unit of flow through
Finding Flow t s Send another unit of flow through
Finding Flow t s Send another unit of flow through
Finding Flow t s Send another unit of flow through Note that there is still an augmenting Path that can proceed backwards
Finding Flow t s Send another unit of flow through Note that there are no more Augmenting paths
Residual Network N f v u c(u,v) f(u,v)
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)
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
Finding Augmenting Path t s
t s t s