Ford-Fulkerson algorithm

Ford-Fulkerson algorithm

The Ford-Fulkerson algorithm searches for an increasing path in the graph residual. It saturates this path if it exists, otherwise it returns the maximum flow. More precisely, the algorithm establishes a minimal cut to verify the optimality criterion. Remember that the flow is less than or equal to the cut.

In order to initialize the algorithm, it is possible to attribute any flow in the graph by following simple paths (from the source to the sink). In the following diagram, we have taken the path s-2-3-t for initialization.

ford-fulkerson algorithm maximum flow max flow problem minimum cut gap graph increasing flow
After construction of the residual graph, a path from s to t is chosen if there is one. Otherwise we have the maximum flow. In the first case, the new flow is calculated according to the increasing path chosen in the deviation graph: we add the flow of the increasing path to the existing flow if the corresponding arc in the original graph is in the same direction as that of the deviation graph, otherwise we subtract the flow. The algorithm stops when there is no longer an increasing path.

It is possible to form a cut using the last gap graph. We apply a path from s, all the vertices that can be traversed are in the set S, the others in the set T. Indeed, the arcs saturated by the flow cut the graph into two subsets, and form the value of the cut.

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

If you want to increase the flow by changing the value, you will need to increase the maximum flow that can pass through these arcs.

Step by step Ford-Fulkerson algorithm

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

The initial flow is 0. Here the residual graph Gf is a copy of graph G. We are looking for a path from s to t, for example s-2-5-t:

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

The minimum value of the path is 8. We add this flow of 8 to the path in the graph G.

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

As a reminder, the residual graph must show the inverse arcs (representing the flows). The residual graph of the new iteration is as follows:

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Here we choose the path s-2-3-5-t, with 2 for the blocking flow. When we choose an inverse arc (thus representing a flow) the new flow in the graph G is reduced as shown by this new graph G.

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Value of the flow = 10. Etc…

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm
maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Flow value = 16

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Choice of reverse arc (3,2):

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Flow value = 18.

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm
maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

Flow value = 19.

maximum flow max flow problem minimum cut deviation graph increasing flow ford-fulkerson algorithm

There is no longer a path from s to t, we have found a maximum flow for this graph G.