Common graph creation methods for bipartite graphs

Source: Internet
Author: User
 

Bipartite graphs are an important part of graph theory and are widely used in real life. For example, the problem of matching must be solved by a bipartite graph. However, the application of the bipartite graph is not only used for these intuitive matching problems, but also has many practical problems that can be solved by the nature of the bipartite graph. For example: how to install the least number of cameras in a supermarket to cover the entire supermarket, how to set up the least number of guards in the border to cover the entire military camp, and so on, is called the minimum point coverage in the bipartite graph. Of course, the minimum edge coverage, the minimum dominant set, and the maximum independent set can all be applied to practical problems.

These properties are of course important and are the theoretical basis of our application. However, many problems in practice are not directly related to the bipartite graph. Therefore, we need to master some basic graph creation methods. After converting the actual problem into a bipartite graph, we can make good use of the nature of the bipartite graph to serve us.

 

The text is as follows:

Common graph creation models

Method 1 row-column matching

1

0

1

0

1

0

1

0

0

          

It is a 3*3 matrix. 1 in the square indicates that there are enemies in this place, and 0 indicates that there are no enemies. Now we have many arrows, each arrow can kill one or more enemies. The problem is that we want to kill all the enemies for use.

How many arrows?

At first glance, it seems that there is no correlation with the maximum bipartite graph. However, if we change our perspective, we think: we want to kill an enemy, you only need to let an arrow go through his position. That is to say, all positions can be overwritten by arrows. That is, the minimum overwrite of vertices. Since it is the minimum overwrite of vertices, and we want to kill enemies, then our point should be the enemy's seat, that is, can I create the following model for the figure above?

The coordinates of someone are (,). We can use the horizontal and vertical coordinates of these points to create a graph.

     

(The abscissa of each point is the first part, and the ordinate is the other part. Two numbers connected by edges represent a point)

As we have said above, the minimum vertex overwrite of a bipartite graph is to find the least edge to overwrite all the vertices, which meets the requirements of this question. The above also gives a property, that is, the minimum vertex overwrite of a bipartite graph is equal to the maximum matching of a bipartite graph. Therefore, we only need to match the above bipartite graph with the maximum value. This makes it easy to change the original problem.

 

 

Method 2 black and white staining

1

0

1

1

1

1

0

0

1

Another graph requires that all 1 in the square be changed to zero, and the adjacent two can be modified at most at a time. How many times does it need to be modified at least? It is also the most worthwhile question, but it seems that it is used to find the most value algorithm (greedy, dynamic planning ......) It is useless. Since it is proposed here, he will certainly be able to solve the problem with the maximum matching of a bipartite graph. The key is how to create a graph?

Since we can only get two adjacent ones at a time, we can also find two matching results when matching them. Is this where the question matches the biggest bipartite graph? Right. But each point can match the four points around him. How can we divide all the points into that part? Right, put the I point in the first part, put the four points around the I point in the second part, and put the 16 points around the four points in the second part.

With this idea, we only need to make such changes to the source image: black and white colors make the surrounding and middle colors different.

 

White 1

Black

White 5

Black 2

White 3

Black 4

White

Black

White 6

Black and White in the figure means to classify the points. The values of 1, 2, 3, 4, 5, and 6 represent the number of 1 in the 0, 1 graph above.

Create a graph to connect adjacent points, such as 1 and 2 2 and 3 .......

White and Black

Then, we need to change all vertices to zero, that is, we need to operate on each vertex and each vertex must have it. Isn't that the minimum vertex overwrite? Yes, this problem has been solved.

 

Method 3 anti-construction

Background: An extremely feudal teacher wants to bring his classmates out to play, but he is afraid of a relationship between his classmates on the way.

The teacher studied and found that there is little chance of a relationship between two students meeting the following conditions.

1, height difference> 40 2> Same Gender

3. Love different music 4> love sports of the same type

Obviously, if we use the edge building between students who meet the above conditions, the final building is not a bipartite graph. Let's take a look at it. Boys and girls share the same gender. Therefore, we can divide men and women into two parts. How can we build borders between men and women? If we connect men and women to meet their needs without having a relationship, the greatest matching is not representative and we cannot get the desired result. Therefore, we use the anti-construction method to establish the sides of a possible relationship between men and women. That is to say, the height difference is equal to or equal to 40. Then find the largest independent set. Isn't the principle of the largest independent set finding a point set so that the points in the set are not connected to each other and there are as many points as possible? We connect men and women who may have a relationship. Isn't the largest set of independence the set of people we are looking for that cannot have a relationship? So, this problem has been solved!

 

 

Method 4 split points method

 

The split-point method is used to solve the problem of least path coverage.

 

To find several paths, you can pass through all the points, and the paths cannot cross. Our practice is to split the vertex into two parts (split point 1 into x1, split point 2 into x2, y2 ......)

If we find that the greatest matching of a bipartite graph corresponds to a path overwrite for each matching, the maximum matching of the bipartite graph is: the minimum path in the source image overwrites the number of edges (the path consists of 0, 1, or multiple edges ). Then, the minimum path overwrites of the source image = the number of source image vertices-the number of edges on the minimum path, that is, the minimum path overwrites of the source image = the number of source image vertices-the maximum number of matching for the bipartite graph.

 

Method 5: One row is changed to multiple rows, and one column is changed to multiple columns.

 

 

 

###

 

###

 

 

 

 

 

###

###

 

###

 

 

 

The above is a 4*4 square, with ### in the square representing the wall. We need to build a bunker where there is no wall in the table, in addition, to ensure that no two bunker blocks can attack each other, ask how many bunker blocks can be built at most? Is it like the first question? If we create a graph like the first question, the final maximum match is the matching of rows and columns. In addition, this match satisfies that all the matches are different columns in different rows (the matching itself is that each vertex or multiple columns belong to a matching edge ). But what should we do if we build a graph like this? A wall is equivalent to dividing this row and this column into two rows and two columns.

 

Example

###

 

 

 

Equivalent

 

 

 

Or a row

 

###

 

 

Equivalent

###

###

 

And

 

###

###

 

A row is converted into two rows.

1, 1

1, 2

###

1, 4

###

2, 2

2, 3

2, 4

3, 1

3, 2

###

###

4, 1

###

4, 3

4, 4

 

SOURCE image

1, 1

1, 2

###

2, 4

###

3, 2

3, 3

3, 4

4, 5

4, 2

###

###

5, 5

###

6, 6

6, 7

 

(Because of the wall, the first line is changed to two rows)

(Because there are two rows above, and the solid line can only start from the third row)

(Because the first column has a wall, the number of fixed columns is increased to 5)

(Columns 3 and 4 have walls, and the number of fixed columns increases to 6 and 7 ).

One row is changed to multiple rows. After one column is changed to multiple columns, we can create a diagram based on the number:

Find the maximum matching value for the bipartite graph. This problem has also been solved!

An algorithm used to find binary graph matching-the Hungary algorithm, cleverly applied the method of finding the augmented track, making it efficient and easy to understand to find the maximum matching of binary graphs,

This has the artistic feeling. However, an operation applied to a bipartite graph can use clever methods to take things that seem irrelevant to a bipartite graph, how wonderful it is to convert an artistic hand into a bipartite graph. Algorithms are amazing and confusing. When you think you are familiar with an algorithm, you will immediately find that you only have a little understanding of it, this is the algorithm.

 

The source network of this subject is organized by myself.

 

 

Common graph creation methods for bipartite graphs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.