![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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/1.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/2.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/3.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/4.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/5.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/6.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/7.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/8.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/9.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/10.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/11.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/12.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/13.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/14.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/15.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/16.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/17.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/18.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/19.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/20.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/21.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/22.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/23.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/24.jpg)
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](https://reader030.vdocuments.us/reader030/viewer/2022032522/56649d635503460f94a45b47/html5/thumbnails/25.jpg)
Finding Augmenting Path
t
s
2
2
1
12
2
2
12
1
t
s
1
1
12
2
1
1