[Figure cut] The most straightforward interpretation of the maximum flow and minimum cut

It will be easier to understand by looking at the example first

What is a graph?

The graphs in this article are mainly directed graphs. The specific definition will not be given first. Let's look at a specific example:

Figure 1: Example directed graph

The above picture is a directed graph, we can give our own definition without looking at the official definition:

1. A directed graph contains vertices and edges;

2. Each side has two end points, and the pointing direction between the two end points is indicated;

3. Each edge has a corresponding value (the specific meaning is related to the specific modeling scenario).

Although the above definition is not an official definition, in this article, such a definition is sufficient. In order to better describe the definition we summarized, I give a formal definition of directed graph:

Figure 2: Formal definition of directed graph

In the above definition, V represents a set of vertices, and E represents a set of directed edges. When k=0, then the directed edge between the two vertices is invalid.

What is the maximum flow?

Before officially introducing the maximum flow, a small problem left over from the previous chapter must be determined, that is, what does the value of the directed edge mean? Here it is defined as the capacity of an edge, which represents the maximum value that the edge can pass. There are many analogies on the Internet. For example, some analogies regard a directed graph as a water pipe, and the capacity is the highest unit flow that can pass through the water pipe section. Based on the analogy, the maximum flow is the highest unit flow that can be reached from the start point to the end point. For the convenience of the following presentation, a formal definition of capacity and maximum flow is given:

Figure 3: Capacity and maximum flow definition

(The above two formulas are too ugly. The first capacity definition formula may give readers a fixed and ambiguous understanding. The actual meaning that the reader wants to express is that the capacity is the value bound by the directed edge. The maximum flow definition is also ugly. I really don’t know how to express it better, so I used the Chinese description directly. I apologize for the ugly expression above.)

Maximum flow calculation method

In order to describe the algorithm effectively, it is necessary to introduce several definitions before the specific description. (Sorry, there will be so many definitions, but readers are still requested to be patient):

Path: the path from the start point (S) of the graph to the end point (T) of the graph, consisting of a series of vertices;

Path flow: the maximum unit flow that can be reached on the path;

Saturation edge: a directed edge whose capacity is equal to the flow rate of the channel.

Specific algorithm description :

Step1: Initialize the maximum flow Flow=0;

Step2: Find a path in the picture, if the path does not exist, end;

Step3: Flow = Flow + channel flow;

Step4: Update the capacity of all sides on the channel Cij = Cij-channel flow;

Step5: Jump to Step2

Note: In the above algorithm, when the capacity is 0, it means that the edge is invalid and cannot be used as the edge in the path.

Interpretation of the effectiveness of the algorithm :

The interpretation is used here instead of the proof, which means that the following statement is described from an intuitive perspective, not a rigorous proof of reasoning. The algorithm is effective, because when there is no path in the graph, it is no longer possible to increase the flow of the graph, so at least the maximum flow in this calculation process has been reached. The remaining part is how to show that the order of path selection has nothing to do with the final calculated maximum flow result? If the two paths are independent, the path selected first will not affect the path selected later. If the two paths are not independent, then it can be simply proved that the order of the paths has nothing to do with the maximum flow on the two paths. If the two paths can be proved, treat the two paths as one path and prove that the same holds in the case of N+1.

What is the minimum cut?

A cut is a set of edges. The set of edges will be removed from the set of edges in the graph. Then the graph is divided into two parts without any edge connection between the two parts. If it is a bit convoluted, then in the simplest terms, a piece of meat is separated from it and divided into two parts. The set of disconnected connections in the middle is the cut.

The minimum cut is the set of cuts with the least cost when the graph is cut into two parts. The cost is the sum of the capacity of the edges (the capacity of the edges from part S to part T). Take pork as an analogy. The smallest cut is to find the smallest part of a piece of meat and split it with one knife. The connection of that part is the smallest cut.

How to find this minimum cut?

When a graph is divided into two parts, there is no longer a path from S to T, so the cost of cutting must be greater than or equal to the maximum flow of the graph (does this require additional explanation? It shouldn't be necessary, it is a very obvious conclusion Right). In other words, the minimum code for cutting cannot be less than the maximum flow of the graph, that is, the cost of cutting is equal to the maximum flow of the graph.

Now the cost of cutting is determined, but how to find such a set of cuttings? Before the specific algorithm description, an additional concept is given:

Affecting edge: In the algorithm for calculating the maximum flow, the capacity of the edge is modified, and the edge with a modified capacity of 0 in a path is called the impact edge of the modified capacity non-zero edge;

Algorithm Description:

Step1: Initialize the edge effect edge set;

Step2: Initialize the minimum cutting edge set;

Step3: The original capacity of the recording side Rij=Cij;

Step3: Find a path, if there is no path, end;

Step4: Correction edge capacity Cij = Cij-path flow;

Step5: Find an edge with Cij=0 among the edges of the passage as the pre-cut edge;

Step6: If the capacity of the pre-cut edge is equal to the original capacity of the edge (Cij=Rij), then add the edge to the minimum cut edge set; otherwise, find all the influence edges of this edge, and remove the influence edge from the minimum cut edge set , Add this edge to the minimum cutting edge set;

Step7: Record the influence side on other sides of the channel;

Interpretation of the effectiveness of the algorithm :

The core principle of the algorithm is to find a set of edges whose cost is equal to the maximum flow and can effectively divide the traversed path in the process of searching for the maximum flow.

Instance

According to the algorithm described in this article, the initial graph is solved for minimum cut.

Step 1: Find the first path

Figure 4: The first path mark

The red font indicates the channel flow of the channel. Correct the capacity according to the algorithm:

Figure 5: The first channel capacity correction

The revised capacity is indicated in red font. In this path, the AC edge capacity is 0, so this edge is added to the minimum cut edge set {AC}, and the influence edge information is recorded at the same time, the influence edge of SA {AC}, the influence edge of CT {AC}.

Step 2: Find the second path:

Figure 6: The second path mark

 

Figure 7: The second channel capacity correction

At this time, the minimum cut edge set is {AC, DT}

Step 3: Find the third path:

Figure 8: The third access mark

 

Figure 9: The third channel capacity correction

At this time, the minimum cutting edge set is: {AC, DT, DC}

At this point, there is no more path, so the current minimum cut edge set is the minimum cut to be solved, and its cost is 23.

Concluding remarks

The algorithm description of the minimum cut in this article does not refer to the specific algorithm, but an algorithm that is naturally generated when looking at the maximum flow algorithm, so this algorithm has not been described in other documents. I do not prohibit readers from using this algorithm in their own projects and papers. Waiting for the document to be written, but be sure to inform the author before using it.



Author: Bobo 2
link: https: //www.jianshu.com/p/beca253fdc9f
Source: Jane books
are copyrighted by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

Guess you like

Origin blog.csdn.net/u013066730/article/details/108529466
cut