Max Flow and Flow Network
• Ur a owner of oil company, & your work is you have a source and destination and you
have to send the oil from source to the destination city.
• Network of pipeline has some capacity. (Edges are pipelines with capacity in gallons per
day)
• Ask manager, please tell in which of the pipeline I have to put how many gallons of oil
so that I can pump maximum max amount of oil to the destination.
• Flow F
f ( u,v)  Flow going out from u to v
C(u,v)  Max capacity it can carry.
Oil flowing/ Oil capacity.
Update the maximum flow, and capacities on the edges
Ford-Fulkerson Max Flow 4
1
1
2
2
1
2
3
3
1
s
2
4
5
3
t
This is the original network, and
the original residual network.
4
1
1
2
2
1
2
3
3
1
Ford-Fulkerson Max Flow
Find any s-t path in G(x)
s
2
4
5
3
t
4
1
1
2
1
3
Ford-Fulkerson Max Flow
Determine the capacity D of the path.
Send D units of flow in the path.
Update residual capacities.
1
1
1
2
1
2
3
2
1
s
2
4
5
3
t
4
1
1
2
1
3
Ford-Fulkerson Max Flow
Find any s-t path
1
1
1
2
1
2
3
2
1
s
2
4
5
3
t
4
2
1
1
1
1
2
2
1
1
1
1
3
Ford-Fulkerson Max Flow
1
1
1
1
3
2
1
s
2
4
5
3
t
Determine the capacity D of the path.
Send D units of flow in the path.
Update residual capacities.
4
2
1
1
1
1
2
2
1
1
1
1
3
Ford-Fulkerson Max Flow
1
1
1
1
3
2
1
s
2
4
5
3
t
Find any s-t path
1
1 1
1
1
4
1
2
1
1
2
1
1
3
Ford-Fulkerson Max Flow
1
1
3
2
1
s
2
4
5
3
t
Determine the capacity D of the path.
Send D units of flow in the path.
Update residual capacities.
1
1 1
1
1
4
1
2
1
1
2
2
1
1
3
Ford-Fulkerson Max Flow
1
1
3
2
1
s
2
4
5
3
t
Find any s-t path
1
1
1
2
1 1
1
1
4
2
2
1
1
2
2
1
Ford-Fulkerson Max Flow
1
1
3
1
1
s
2
4
5
3
t
Determine the capacity D of the path.
Send D units of flow in the path.
Update residual capacities.
2
1
1
2
1 1
1
1
4
2
2
1
1
2
2
1
Ford-Fulkerson Max Flow
1
1
3
1
1
s
2
4
5
3
t
Find any s-t path
2
1
1
1
1
1
4
1
3
1
1
2
1 1
3
2
2
1
2
1
Ford-Fulkerson Max Flow
2
1
s
2
4
5
3
t
2
Determine the capacity D of the path.
Send D units of flow in the path.
Update residual capacities.
1
1
1
1
1
4
1
3
1
1
2
1 1
3
2
2
1
2
1
Ford-Fulkerson Max Flow
2
1
s
2
4
5
3
t
2
There is no s-t path in the residual network.
This flow is optimal
1
1
1
1
1
4
1
3
1
1
2
1 1
3
2
2
1
2
1
Ford-Fulkerson Max Flow
2
1
s
2
4
5
3
t
2
These are the nodes that are reachable from
node s.
s
2
4
5
3
Ford-Fulkerson Max Flow 1
1
2
2
2
1
2
s
2
4
5
3
t
Here is the optimal flow

FORD-FULKERSON Algorithm.ppt