# Ford-Fulkerson algorithm

 related topics {math, number, function} {line, north, south} {system, computer, user} {ship, engine, design} {law, state, case}

The Ford–Fulkerson algorithm (named for L. R. Ford, Jr. and D. R. Fulkerson) computes the maximum flow in a flow network. It was published in 1956. The name "Ford–Fulkerson" is often also used for the Edmonds–Karp algorithm, which is a specialization of Ford–Fulkerson.

The idea behind the algorithm is very simple: 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 these paths. Then we find another path, and so on. A path with available capacity is called an augmenting path.

## Contents

### 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:

This means that the flow through the network is a legal flow after each round in the algorithm. We define the residual network Gf(V,Ef) to be the network with capacity cf(u,v) = c(u,v) − f(u,v) 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 cf(v,u) = c(v,u) − f(v,u) = f(u,v) > 0.

Algorithm Ford–Fulkerson

The path in step 2 can be found with for example a breadth-first search or a depth-first search in Gf(V,Ef). If you use the former, the algorithm is called Edmonds–Karp.

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.