Graphs are often used to model transportation networks; networks whose edges carry some sort of traffic and whose nodes act as switches, passing traffic between edges. Network models of this type have capacities on the edges, indicating how much they can carry, source nodes in the graph, which generate traffic, sink nodes which can absorb traffic as it arrives, and the traffic itself, which is transmitted across the edges. A flow network is a directed graph G=(V,E) with the following features:
nodes other than s and t will be called internal nodes
We will assume that no edge enters the source s and no edge leaves the sink t, that there is at least one edge incident to each node, and that all capacities are integers.
We say that an s-t flow is a function f that maps each edge to a nonnegative real number. The value f(e) intuitively represents the amount of flow carried by e. A flow f must satisfy the following two properties:
Given a flow network, a natural goal is to arrange the traffic so as to make as efficient use as possible of the available capacity. So, the basic algorithm we consider will be: given a flow network, find a flow of maximum possible value.
Suppose we divide the nodes of the graph into two set, A and B, so that s is in A and t is in B. Then, any flow that goes from s to t must cross from A into B at some point and thereby use up some of the edge capacity from A to B. This suggests that each “cut” of the graph puts a bound on the maximum possible flow value. Our algorithm is intertwined with a proof that the maximum-flow value equals the minimum capacity of any such division, called the minimum cut.
Both dynamic programming and greedy algorithms fail to produce a result of maximum flow so we have to try something else. What we can do is push forward on edges with leftover capacity and push backward on edges that are already carrying flow, to divert it in a different direction. A residual graph provides a systematic way to search for forward-backward operations such as this. Given a flow network G, and a flow f on G, we define the residual graph G_f of G with respect to f as follows:
Let P be a simple s-t path in G_f. We define bottleneck(P,f) to be the minimum residual capacity of any edge on P, with respect to the flow f. augment(f,P):
return f
The result of augment(f,P) is a new flow f' in G, obtained by increasing and decreasing the flow values on edges of P.
max-flow:
return f
This algorithm runs in O(mC) time where C is the sum of all capacities in G and m is the number of edges in G.
I would rate this section a 5. This is a really difficult concept to wrap my head around. I wish there were more pictures or diagrams or examples. I think the lecture slides will prove to be more helpful.