In a transport graph, we have a source vertex, where a producer of some commodity is located, a destination vertex, and all the other vertices act as intermediates. Each edge represents the possibility to transport a certain amount of that commodity; the amount is the capacity of that edge.
The goal is to plan how to transport a maximum amount of that commodity from the source to the destination.
More formally, we have:
A flow can be established through the graph. A flow is an assignment of a flow value to each edge, such that:
For the source vertex, there is a positive net outbound flow. That value is called the total value of the flow. It is vflow = ∑y∈Nout(s)flow(s,y) - ∑y∈Nin(s)flow(y,s).
It can be easily shown that the total flow value is equal to the net inbound flow into the destination vertex: vflow = ∑y∈Nin(t)flow(y,t) - ∑y∈Nout(t)flow(t,y).
The classical problem to be solved is to set a maximum flow in the transport graph, that is, to maximize the total flow value among all possible flows.
To analize the flow, we need the concept of a cut. A cut is, essentially, a partitioning of the vertices into two sets: one containing the source and the other containing the destination. Then, we analyse the capacities and the flow along the edges between vertices in one subset and the other subset.
The net flow across the cut is the total "left to right" flow (the total flow along the edges leading from the
set containing the source to the set containing the destination), minus the "right to left" flow. Formally, assuming
that the cut is (A, X\A), with s∈A and t∈ X\A:
flow(A,X\A) = ∑(x,y)∈E, x∈ A, y ∈ X\Aflow(x,y) -
∑(x,y)∈E, x∈ X\A, y ∈ Aflow(x,y)
The capacity of the cut is, however, only the "left to right" capacity: cap(A,X\A) = ∑(x,y)∈E, x∈ A, y ∈ X\Acap(x,y)
It is clear that, for any cut, the flow across the cut is less than or equal to the capacity of the cut. The maximum flow is obtained when all "right to left" edges are saturated and all "left to right" edges have zero flow.
On the other hand, the flow across any cut is the same, and is equal to the total value of the flow. (Actually, the total value of the flow is the flow across a cut that has only the source vertex on the "left", and all other vertices on the "right".)
A flow of zero everywhere is clearly a valid flow. Starting from it, we can increase the flow while keeping it valid by the following approach:
It is clear that, by following the steps above, the flow remains valid. However, we may end up with a flow that cannot be increased by this approach, yet a flow of larger total value still exists.
A correct algorithm can be devised starting from the (incorrect) naïve algorithm. This algorithm (Ford-Fulkerson) is the following:
To show that the algorithm produces the optimal flow, consider the cut having on the left-hand side all the vertices that are accessible from the source in the residual graph (since there is no path to destination, the destination is on the right-hand side of the cut). No edge can exist in the residual graph across the cut from left to right. Because of the way the residual graph was constructed, it follows that the left-to-right edges in the original graph are saturated and the right-to-left edges have zero flow. So, that cut is saturated. So, no larger flow can exist.
It follows that the value of the maximum flow is equal to the capacity of the minimum cut. This statement is called the Ford-Fulkerson theorem.
Input graph:
After augmenting path 1,2,3,6 (capacity = 1):
with residual graph
After augmenting path 1,4,5,6 (capacity = 3):
with residual graph
After augmenting path 1,2,5,6 (capacity = 1):
with residual graph
The naïve algorithm stops here. Ford-Fulkerson, however, finds the augmenting path 1,2,5,4,3,6 (capacity = 1):
with residual graph
No augmenting path can be found any more. The cut {1} to {2,3,4,5,6} is saturated (capacity=6, flow=6).
Radu-Lucian LUPŞA