Maximum Flow and Minimum Cut
Abstract
The max-flow min-cut theorem is a network flow theorem that draws a relation between maximum flow and minimum cut of any given flow network.
It sates that maximum flow through any graph is exactly equal to minimum cut of the same graph. Due to which its application in a variety of areas, like in computing it is used in network reliability, connectivity, etc. in mathematics is used to do maximum bipartite matching, in other less technical areas it can be used for scheduling problems.
Takeaways
Maximum flow from the source node to sink node in a given graph will always be equal to the minimum sum of weights of edges which if removed disconnects the graph into two components.
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.
Minimum Cut Problem
Let us assume for some reason we want to split any given image into two non-similar portions. If we approach this problem in terms of graph data structure we would consider pixels as the vertices of the graph and edges between two similar pixels of the image. In this case, a minimum cut will be analogous to the partition of pixels into two parts where the two parts are the most dissimilar.
To understand the minimum cut (or simply min-cut) concept, we will take the help of an example a simple undirected graph with five vertices and six edges as shown below -
To obtain the minimum cut of this graph, we will be interested in disconnecting this graph into two components by removing the minimum possible number of edges. This can be done by removing two edges, and as shown below.
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.
Karger's algorithm is a randomized algorithm that is used to find the minimum cut of any given graph has been discussed in the Minimum cut article. We would strongly recommend you to refer it to have an idea of its implementation.
Maximum Flow Problem
If we consider a rail network that connects two cities (say and ) by way of several intermediate cities, where each railway line has some value assigned to it denoting its capacity.
Assuming steady conditions (number of trains on a railway line never exceeds its capacity), if we need to find what is the maximum number of trains (maximum flow) that we can send from City to city then the problem is known as the "Maximum Flow Problem".
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 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 - is written over edge 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 -
Max Flow Min Cut Theorem
The max-flow min-cut theorem is the network flow theorem that says, maximum flow from the source node to sink node in a given graph will always be equal to the minimum sum of weights of edges which if removed disconnects the graph into two components size of the minimum cut of the graph .
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.
Let's have a look at an example to understand this clearly -
In the above-shown network, edge has a capacity of 50 units but we can't send that much flow through them because in the later stage we have edges with capacities of 3 and 5 respectively. Hence, the maximum flow we can have through this graph is only 8.
Another important observation in this graph is the size of the minimum cut is also 8, which can be obtained by removing edges with the total sum of weights as 8 as shown below -
Proof of Max-Flow Min-Cut Theorem
Before beginning with the proof let's define some variables which we will use frequently while proving the max-flow min-cut theorem - - The given network. - Set that includes the source node . - Set that includes the sink node . - A function represent flow through the network. - Function 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 and cut in a network, we can say that -
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:
Because of lemma 1, for maximum flow and minimum cut we have -
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 be . Now we will search for an augmenting path between and in the residual graph which has been formed at each step of the process. Let in an augmenting path from to , is the minimum capacity of any edge along the path.
So we will add this flow () in our maximum flow -
This process is repeated until there are more augmenting paths in the residual network. Once there is no augmenting path left, we denote all vertices which are reachable from the source as and all vertices which are not reachable from the source as . It is obvious that sink can't be in set as there are no more paths between and .
For any pair of vertices, where is in set and is in set . The flow is maximized as no augmenting paths are left also flow of is 0 due to same reason.
Therefore we can say that,
And by corollary 2 we can conclude that -
Applications
-
Generalized max-flow min-cut theorem
If we define the capacity of vertices along with edges in a flow network. Then, flow along a path also needs to satisfy the capacity constraint of vertices a 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.
So using this we can pose a generalized max-flow min-cut theorem will state that maximum flow is equal to the minimum capacity of a cut in a different sense to solve other complex problems.
-
Project Selection Problem
In the project selection problem, we have projects and machines. For completing a project successfully we require some machines for each project (a machine can also be shared for completing several projects), on completing each project we earn a revenue of , and each machine costs .
We want to choose projects such that the revenue we get at the end is maximized. So we define a dummy source node connected the projects with capacity and a dummy sink node which is connected by all the machines with capacities also an edge is is added between if project requires machine .
Let's assume we have 3 projects and 3 machines with requirements and costs as shown in the table below -
No. 1 50 100 2 100 50 3 75 25 The network formed based on the data will look like -
Then one can either solve this problem with the approach used in the maximum flow problem or by finding the minimum cut of the network formed.
-
Image Segmentation Problem
In the image segmentation problem, we have been given an image, we want to find what is the foreground and what is the background? We have two non-negative values defined for each pixel among pixels of the given image.
- probability that pixel is in the foreground.
- probability that pixel is in the background.
We will consider a pixel in the foreground if and background in the other case.
In terms of graph data structure, we consider every pixel as a vertex and edge between vertex if they are adjacent to each other as shown below -
Now we introduce a new term penalty which we have for each adjacent pair of pixels in case one is in the foreground and other in the background.
We will define a dummy source node connected with all vertices with capacities and a sink node which is also connected to all the vertices with capacities also, edges and are added with capacity as between two adjacent pixels.
Then the minimum s-t cut represents pixels assigned to the foreground and pixels assigned to the background in .
Conclusion
- In this article, we have revised the concept of Minimum cut and Maximum flow in a network.
- Then we have seen one of the most important theorems in graph theory "Max-flow Min-cut theorem" along with its intuitive proof.
- At last, we have seen some of the important applications of the theorem in the real world.