CS302 Lecture Notes - Network Flow

Maximum Flows, Minimum Cuts, Residual Graphs, The Edmonds-Karp Algorithm


Reference Material Online

I have standard Wikipedia reference material, but it's a bit dry and mathematical. A much better description of finding maximum flow comes from Topcoder.

An example of using the Edmonds-Karp algorithm

The Edmonds-Karp algorithm is a specialization of the Ford-Fulkerson algorithm which always uses the augmenting path with the smallest number of edges. The running time is O(|V|2|E|).

I'll give an example here of using the algorithm to find the maximum flow in the following graph (the same example as Wikipedia). Node A is the source, and Node G is the sink.

Now, to clarify, we're going to separate the flow graph and the residual graph:

Our first step is to find a minimal hop augmenting path from A to G in the residual graph. We can find these using an unweighted shortest path algorithm. There are two of these paths: A,D,E,G and A,D,F,G. Suppose we use the first. This has a flow of 1, since its limiting edge (EG) has a capacity of one.

We add the flow to the flow graph, remove the flow from the residual graph, and add the appropriate back edges. Here are the resulting graphs:

Next, we find another minimal hop augmenting path. There is only one of these: A,D,F,G, with a flow of two:

Again, we update the flow and residual graphs:

And we search for another minimal hop augmenting path in the residual graph. This is A,B,C,D,F,G:

And we update:

There is one more augmenting path: A,B,C,E,D,F,G:

When we add it to the flow graph, you see that the flow in edge DE has been canceled out:

The residual graph has no more paths to the sink, so we're done. The maximum flow is 5. Note, had we instead used the technique that finds the maximum capacity augmenting path at each step, we would have found the flow with one fewer step. However, each step would have been more expensive.


Finding the Minimum Cut

As detailed in the Topcoder tutorial, you can use the final residual graph to find the minimum cut. First, you find all nodes reachable from the source in the residual graph. This is one set of nodes:

Now, in the original graph, we divide our nodes into two sets: the set determined above, and all of the remaining sets. They are drawn blue and yellow below.

The minimum cut is composed of all the edges that go from the source set to the sink set. These are edges AD, CD and EG. The sum of their capacities equals the maximum flow of five.