Ford-Fulkerson Algorithm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Page |1

Flow Network
In graph theory, a flow network is defined as a directed graph having a source(𝑆) and a sink(𝑇)
and several other nodes connected with edges. Each edge has an individual capacity which is
the maximum limit of flow that edge could allow. The source produces material at a steady
rate, and the sink consumes it at the same rate. The amount of flow on an edge cannot exceed
its capacity. A flow network represents the flow of materials.
Flow in the network should follow the following conditions:
• For any non-source and non-sink node, the input flow is equal to output flow.
• For any edge(𝐸𝑖) in the network, 0≤𝑓𝑙𝑜𝑤(𝐸𝑖)≤𝐶𝑎𝑝𝑎𝑐𝑖𝑡𝑦(𝐸𝑖).
• Total flow out of the source node is equal total to flow in to the sink node.
• Net flow in the edges follows skew symmetry i.e. 𝐹 (𝑢, 𝑣) =−𝐹 (𝑣, 𝑢) where 𝐹 (𝑢, 𝑣) is
flow from node u to node v. The quantity f (u, v), which can be positive or negative, is
called the net flow from vertex u to vertex v. the value of flow f is defined as

|𝑓| = ∑ 𝑓(𝑠, 𝑣)
𝑣∈𝑉

Where V is the set of all vertices. There is no net flow between vertices u and v, if there is no
edge between them.
Flow networks can be used to model problems that involve transporting items between
locations, such as:
• Traffic on a network of roads
• Fluid in a network of pipes
• Electricity in a network of circuit components
• Shipping packages between cities using trucks
The graph below is the graph above plus the corresponding capacities.

Maximum Flow Problem:


It is defined as the maximum amount of flow that the network allows to flow from source to
sink. There are multiple algorithms to solve the maximum flow problem. Two major
algorithms are Ford-Fulkerson algorithm and Dinic's Algorithm.
Page |2
The following graph represents a flow network, where the first value of each edge is the
amount of the flow through it (which is initially set to 0) and the second value is the capacity
of the edge.

Maximum flow can be defined as Maximum amount of flow that the network would allow to
flow from source to sink vertex.

The Ford-Fulkerson algorithm is used to detect maximum flow from start vertex to sink vertex
in a given graph. This algorithm was developed by L.R. Ford and Dr. R. Fulkerson in 1956.
Let us discuss some terms related to this algorithm:
Residual Capacity
Residual capacity of the directed edge is (capacity of the edge - current flow through the edge).
If there is flow along a directed edge u → v then reversed edge has a capacity 0 and we can
say 𝑓 (𝑣, 𝑢) =−𝑓 (𝑢, 𝑣). So, residual capacity of the edge (u, v) =c (u, v)-f (u, v).

Residual Graph
Residual graph is the same graph with the only difference is we use residual capacities as
capacities. A residual graph indicates how much more flow is allowed in each edge in the
network graph.
Page |3

Residual Graph

Augmenting Path
An augmenting path is a simple path from source to sink which do not include any cycles and
that pass only through positive weighted edges. Augmenting paths help determine how to
change the flow on certain edges to increase the overall flow from the source to the sink.
A residual network graph indicates how much more flow is allowed in each edge in the network
graph. If there are no augmenting paths possible from 𝑆 to 𝑇, then the flow is maximum. The
result i.e. the maximum flow will be the total flow out of source node which is also equal to
total flow in to the sink node.

We can see that the initial flow of all the paths is 0. Now we will search for an augmenting
path in the network.
One such path is 𝑠→𝐴→𝐵→𝑡 with residual capacities as 7, 5, and 8. Minimum of them is 5.
So as per the Ford-Fulkerson method we will increase the flow of 5 along the path.
Page |4
Now, we will check for other possible augmenting paths. One such path can be s→D→C→t
with residual capacities 4, 2, and 5. Among them 2 is the minimum. So, we increase a flow of
2 along the path.

We can observe from the figure that we can’t increase the flow along paths A→B and D→C
as their flow has reached their maximum capacity. So, to find other augmenting paths, we must
take care that these edges must not be part of the path.
One such path can be s→D→A→C→t with residual capacities of 2, 3, 3 and 3. Among them
minimum capacity is 2. Hence, we increase a flow of 2 along this path.

An augmenting path that is possible in the current residual network is s→A→C→t with
residual capacities of 2, 1 and 1, of which 1 is the minimum. So, we will increase the flow of
1 along the path after which our network will look like -

Now there are no more augmenting paths possible in the network. So, the maximum flow is
the total flow going out of source or total flow coming in sink i.e. 6+4=5+5=10
Page |5
The pseudocode is as below:
FordFulkerson(Graph G, Node s, Node t):
Initialize flow of all edges e to 0.
while (there is augmenting path (P) from s to t in the residual graph):
Find augmenting path between s and t.
Update the residual graph.
Increase the flow.
return

You might also like