Wikipedia / Ford–Fulkerson algorithm
Wikipedia / Ford–Fulkerson algorithm
The Ford–Fulkerson method or Ford–Fulkerson algorithm (FFA) is a greedy algorithm that computes the maximum flow in a flow network. It is sometimes called a "method" instead of an "algorithm" as the approach to finding augmenting paths in a residual graph is not fully specified or it is specified in several implementations with different running times. It was published in 1956 by L. R. Ford Jr. and D. R. Fulkerson. The name "FordFulkerson" is often also used for the Edmonds–Karp algorithm, which is a fully defined implementation of the FordFulkerson method.
The idea behind the algorithm is as follows: as long as there is a path from the source (start node) to the sink (end node), with available capacity on all edges in the path, we send flow along one of the paths. Then we find another path, and so on. A path with available capacity is called an augmenting path.
Algorithm
be a graph, and for each edge from to be the flow. We want to find the maximum flow from the source to the sink . After every step in the algorithm the following is maintained:This means that the flow through the network is a legal flow after each round in the algorithm. We define the residual network and no flow. Notice that it can happen that a flow from to .
Inputs with flow capacity , a source node , and a sink node
Output Compute a flow from to of maximum value
While there is a path from to :
(Send flow along the path)
(The flow might be "returned" later)
The path in step 2 can be found with, for example, breadth-first search (BFS) or depth-first search. The former is known as the Edmonds–Karp algorithm.
When no more paths in step 2 can be found, will not be able to reach in the residual network. If is the set of nodes reachable by in the residual network, then the total capacity in the original network of edges from to the remainder of is on the one hand equal to the total flow we found from to , and on the other hand serves as an upper bound for all such flows. This proves that the flow we found is maximal. See also Max-flow Min-cut theorem.
. Then apply the FordFulkerson algorithm.
Also, if a node . We can then apply the FordFulkerson algorithm.
Complexity
By adding the flow augmenting path to the flow already established in the graph, the maximum flow will be reached when no more flow augmenting paths can be found in the graph. However, there is no certainty that this situation will ever be reached, so the best that can be guaranteed is that the answer will be correct if the algorithm terminates. In the case that the algorithm does not terminate, the flow might not converge towards the maximum flow. However, this situation only occurs with irrational flow values. (see big O notation.
A variation of the FordFulkerson algorithm with guaranteed termination and a runtime independent of the maximum flow value is the Edmonds–Karp algorithm time.
Integer flow example
is sent across the network. If breadth-first-search were used instead, only two steps would be needed.
Non-terminating example
.. Therefore, the algorithm never terminates and the flow does not converge to the maximum flow.
Another non-terminating example based on the Euclidean algorithm is given by in ordinal numbers.
Python implementation of the Edmonds–Karp algorithm
See also
Notes
References
External links