Maximum Flow and Minimum Cut
Maximum Flow and Minimum Cut
Introduction
In our previous articles, we have seen how costly it is to calculate the maximum flow as well
as the minimum cut of a graph. If we want to calculate both of them, then we need not follow
the conventional method to calculate them instead we will bother about calculating only one
of them.
In this article, we will discuss how we can find the maximum flow of a flow network by
calculating the minimum cut of the network or vice-versa. We have already seen what do
minimum cut and maximum flow means in previous articles, though we have given a slight
glimpse for revision of the concept.
There is a theorem that can be proved to pose a relation between maximum flow and
minimum cut of a network and that theorem is known as the "Max-flow Min-cut"
theorem which has been briefly explained and proved in the article.
Let's revisit the concepts of minimum cut and maximum flow and then we will see what does
the max-flow min-cut theorem states and how we can prove it.
example a simple undirected graph 𝐺G with five vertices and six edges as shown below -
To understand the minimum cut (or simply min-cut) concept, we will take the help of an
To obtain the minimum cut of this graph, we will be interested in disconnecting this graph
by removing two edges, 𝐴↔𝐵A↔B and 𝐷↔𝐶D↔C as shown below.
into two components by removing the minimum possible number of edges. This can be done
Formally minimum cut is defined as, the minimum sum of weight of the edges (minimum
edges in case of unweighted graphs) required to remove to disconnect the graph into two
components.
given graph 𝐺G has been discussed in the Minimum cut article. We would strongly
Karger's algorithm is a randomized algorithm that is used to find the minimum cut of any
Assuming steady conditions (number of trains on a railway line never exceeds its capacity), if
from City 𝐴A to city 𝐵B then the problem is known as the "Maximum Flow Problem".
we need to find what is the maximum number of trains (maximum flow) that we can send
In graph theory, we have been given a network with a source (which has no incoming edge)
node and a sink (which has no outgoing edge) node and capacities of all the edges which
correspond to the maximum flow that an edge can allow to flow through it.
We are interested in finding the maximum amount of flow we can send from the source node
to the sink node constrained with the capacities of all the intermediate edges. To understand it
more clearly we will have a look on an example have been given below -
The given graph 𝐺G has six vertices and nine edges where the first value of each edge
represents the flow through it (which is initially set to 0) and the second value represents its
capacity.
For example - 0/50/5 is written over edge 𝐴↔𝐵A↔B means capacity of this edges is
5 and currently there is no flow along this edge.
We can find the maximum flow through this network by following the steps which have been
explained briefly in Maximum Flow.
After proceeding through the steps, we find maximum flow through the network as
-
More formally, the max-flow min-cut theorem states that, the maximum flow passing from
the source node to the sink node is equal to the size of the minimum cut.
Intuition
In all types of networks (whether they carry data or some other object), the amount of flow
that can flow through the network is restricted by the weakest connection (an edge with
comparatively less capacity) between disjoint sets of the network. Even if other connections
can allow a huge amount of flow through them but can never be used.
In the above-shown network, edge 𝑠→𝐴, 𝑠→𝐵s→A, s→B has a capacity of 50 units
edges 𝐴→𝐵 𝑎𝑛𝑑 𝐵→𝐸A→B and B→E with capacities of 3 and 5 respectively.
but we can't send that much flow through them because in the later stage we have
Hence, the maximum flow we can have through this graph is only 8.
can be obtained by removing edges 𝐴→𝐸 𝑎𝑛𝑑 𝐵→𝐸A→E and B→E with the
Another important observation in this graph is the size of the minimum cut is also 8, which
while proving the max-flow min-cut theorem - 𝐺G - The given network. 𝑆S - Set that
Before beginning with the proof let's define some variables which we will use frequently
includes the source node 𝑠s. 𝑇T - Set that includes the sink node 𝑡t. 𝑓f - A function
represent flow through the network. 𝑓∗f∗ - Function 𝑓f at its max value (Maximum flow).
Lemma - A statement that is assumed to be true and used as a basis to draw a conclusion.
Corollary - A statement which is direct result of a fact (in our case result of a Lemma).
Lemma 1:
For any flow through 𝑓(𝐺)f(G) and cut (𝑆,𝑇)(S,T) in a network, we can say that -
𝑓(𝐺)≤𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦(𝑆,𝑇)f(G)≤capacity(S,T)
This lemma also makes sense as we have seen in the above intuition, it is not possible to send
more flow through an edge than its capacity.
Corollary 2:
𝑓(𝐺)∗≤𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦((𝑆,𝑇)∗)f(G)∗≤capacity((S,T)∗)
The above mathematical result places an upper bound for the maximum flow through the
graph.
According to the "Ford-Fulkerson method" let the initial flow 𝑓f be 00. Now we will
search for an augmenting path between 𝑠s and 𝑡t in the residual graph which has been
path 𝑝p from 𝑠s to 𝑡t, 𝑐𝑚𝑖𝑛cmin is the minimum capacity of any edge along the path.
formed at each step of the process. Let in an augmenting
𝑓∗=𝑓+𝑐𝑚𝑖𝑛f∗=f+cmin
This process is repeated until there are more augmenting paths in the residual network. Once
as 𝑉V and all vertices which are not reachable from the source as 𝑉′V′. It is obvious that
there is no augmenting path left, we denote all vertices which are reachable from the source
sink 𝑡t can't be in set 𝑉V as there are no more paths between 𝑠s and 𝑡t.
For any pair of vertices, 𝑢 𝑎𝑛𝑑 𝑣u and v where 𝑢u is in set 𝑉V and 𝑣v is in set 𝑉
′V′. The flow 𝑓(𝑢,𝑣)f(u,v) is maximized as no augmenting paths are left also flow
of (𝑣,𝑢)(v,u) is 0 due to same reason.
𝑓(𝑢,𝑣)=𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦(𝑢,𝑣), 𝑢 𝜖 𝑉, 𝑣 𝜖 𝑉′f(u,v)=capacity(u,v),
u ϵ V, v ϵ V′
And by corollary 2 we can conclude that -
𝑓∗=𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑦((𝑆,𝑇)∗)f∗=capacity((S,T)∗)
Applications
Generalized max-flow min-cut theorem
along a path also needs to satisfy the capacity constraint of vertices 𝑖.𝑒.i.e. a flow
If we define the capacity of vertices along with edges in a flow network. Then, flow
passing through a particular vertex can't exceed its capacity. In this case, the capacity
of a cut is the sum of the capacities of edges and vertices present in it.
capacity 𝑟(𝑝𝑖)r(pi) and a dummy sink node 𝑡t which is connected by all the
machines with capacities 𝑐(𝑚𝑗)c(mj) also an edge is is added
between (𝑝𝑖,𝑚𝑗)(pi,mj) if project 𝑝𝑖pi requires machine 𝑚𝑗mj.
Let's assume we have 3 projects and 3 machines with requirements and costs as
shown in the table below -
𝑚2m
1 50 100
𝑚2&𝑚3m
2 100 50
3 75 25
The network formed based on the data will look like
-
In the image segmentation problem, we have been given an image, we want to find
vertex 𝑖 𝑎𝑛𝑑 𝑗i and j if they are adjacent to each other as shown below -
In terms of graph data structure, we consider every pixel as a vertex and edge between
pixels 𝑖,𝑗i,j in case one is in the foreground and other in the background.
Now we introduce a new term penalty which we have for each adjacent pair of
We will define a dummy source node connected with all vertices with capacities 𝑓𝑖fi and a
sink node which is also connected to all the vertices with capacities 𝑏𝑖bi also, edges (𝑖,𝑗)
(i,j) and (𝑗,𝑖)(j,i) are added with capacity as 𝑝𝑖𝑗pij between two adjacent pixels.
Then the minimum s-t cut represents pixels assigned to the foreground 𝑃P and pixels
assigned to the background in 𝑄Q.
vv