|
for ( each edge e in network ) do
{
f(e) = 0;
}
repeat
{
Clear the label of all nodes;
Use DFS to find a path S → T
{
During DFS traversal:
1. Use only "flow augmenting edges"
(1. forward edges that are unsaturated or
2. backward edges with flow > 0)
2. if ( node visited is unlabeled )
label the node x with the predecessor node
}
if ( T received a label )
{ // T was reached by a flow augmenting path !!
1. Use the labels to trace (back) the path;
2. increase flow by the slack of the (flow augmenting) path
}
} until T not reached during DFS
|
|
|
|
|
(The algorithm uses labels.
The flow augmenting path is highlighted for your convenient.)
Augment flow: by 3
|
|
Augment flow: by 1
|
|
Augment flow: by 1
|
|
Augment flow: by 1
|
|
Done
|
Solution: (max flow = 17)
|
Flow augmenting paths are "color coded" with the given amount of flow passing through various links.