Ford–Fulkerson algorithm

1

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 "Ford–Fulkerson" is often also used for the Edmonds–Karp algorithm, which is a fully defined implementation of the Ford–Fulkerson 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

Let G(V,E) be a graph, and for each edge from u to v, let c(u,v) be the capacity and f(u,v) be the flow. We want to find the maximum flow from the source s to the sink t. After every step in the algorithm the following is maintained: ! Rh | Capacity constraints ! Rh | Skew symmetry ! Rh | Flow conservation ! Rh | Value(f) This means that the flow through the network is a legal flow after each round in the algorithm. We define the residual network G_f(V,E_f) to be the network with capacity and no flow. Notice that it can happen that a flow from v to u is allowed in the residual network, though disallowed in the original network: if f(u,v)>0 and c(v,u)=0 then. The path in step 2 can be found with, for example, breadth-first search (BFS) or depth-first search in G_f(V,E_f). The former is known as the Edmonds–Karp algorithm. When no more paths in step 2 can be found, s will not be able to reach t in the residual network. If S is the set of nodes reachable by s in the residual network, then the total capacity in the original network of edges from S to the remainder of V is on the one hand equal to the total flow we found from s to t, 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. If the graph G(V,E) has multiple sources and sinks, we act as follows: Suppose that and. Add a new source s^* with an edge (s^,s) from s^ to every node s\in S, with capacity. And add a new sink t^* with an edge (t, t^) from every node t\in T to t^, with capacity. Then apply the Ford–Fulkerson algorithm. Also, if a node u has capacity constraint d_u, we replace this node with two nodes, and an edge , with capacity. Then apply the Ford–Fulkerson 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 runs forever, the flow might not even converge towards the maximum flow. However, this situation only occurs with irrational flow values. When the capacities are integers, the runtime of Ford–Fulkerson is bounded by O(E f) (see big O notation), where E is the number of edges in the graph and f is the maximum flow in the graph. This is because each augmenting path can be found in O(E) time and increases the flow by an integer amount of at least 1, with the upper bound f. A variation of the Ford–Fulkerson algorithm with guaranteed termination and a runtime independent of the maximum flow value is the Edmonds–Karp algorithm, which runs in O(VE^2) time.

Integer flow example

The following example shows the first steps of Ford–Fulkerson in a flow network with 4 nodes, source A and sink D. This example shows the worst-case behaviour of the algorithm. In each step, only a flow of 1 is sent across the network. If breadth-first-search were used instead, only two steps would be needed.

Non-terminating example

Consider the flow network shown on the right, with source s, sink t, capacities of edges e_1 = 1, and e_3 = 1, and the capacity of all other edges some integer M \ge 2. The constant r was chosen so, that r^2 = 1 - r. We use augmenting paths according to the following table, where, and. Note that after step 1 as well as after step 5, the residual capacities of edges e_1, e_2 and e_3 are in the form r^n, r^{n+1} and 0, respectively, for some. This means that we can use augmenting paths p_1, p_2, p_1 and p_3 infinitely many times and residual capacities of these edges will always be in the same form. Total flow in the network after step 5 is. If we continue to use augmenting paths as above, the total flow converges to. However, note that there is a flow of value 2M + 1, by sending M units of flow along sv_1t, 1 unit of flow along sv_2v_3t, and M units of flow along sv_4t. Therefore, the algorithm never terminates and the flow does not even converge to the maximum flow. Another non-terminating example based on the Euclidean algorithm is given by, where they also show that the worst case running-time of the Ford-Fulkerson algorithm on a network G(V,E) in ordinal numbers is.

Python implementation of the Edmonds–Karp algorithm

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original