This article speaks of the maximum matching (maximum matching) and perfect match (perfect matching) of the No-power binary graph (unweighted bipartite graph), and the Hungarian algorithm for solving the match (Hungarian algorithm); Do not talk about the best match with the weighted binary graph.
two-part diagram: In simple terms, if the midpoint of the diagram can be divided into two groups, and all edges cross the boundary of the group, then this is a two-part graph. To be exact: dividing the vertices of a graph into two disjoint setsUAndV, so that each edge is connected separatelyU、the vertex in V . If such a division exists, the graph is a two-part graph. An equivalent definition of a binary graph is: A graph that does not contain "rings with odd numbers of edges".
Figure 1 is a two-part diagram. In order to be clear, we will later draw it into the form of Figure 2.
match : In graph theory, a "match" (matching) is a set of edges in which any two edges have no public vertices. For example, the red edge in Figure 3, Figure 4, is the match of Figure 2.
We define matching points , matching edges , unmatched points , mismatched edges , and they are very obvious. Example 3, 1, 4, 5, 7 is the matching point, the other vertices are unmatched points, 1-5, 4-7 is the matching edge, the other edges are non-matching edges.
Maximum match : A match with the largest number of matched edges in all matches of a graph, called the maximum match for this graph. Figure 4 is a maximum match that contains 4 matching edges.
Perfect Match : if one of the graphs has a match, all vertices are matching points, then it is a perfect match. Figure 4 is a perfect match. Obviously, the perfect match must be the maximum match (any point of the perfect match has already been matched, adding a new matching edge will certainly conflict with the existing matching edge). But not every diagram has a perfect match.
For example: as shown, if there is a connecting edge between a pair of boys and girls, it means they like each other. Is it possible for all boys and girls to be paired 22 so that each pair likes each other? In graph theory, this is the perfect match problem. If it's a different story: how many boys/girls do you like to pair with each other? This is the maximum matching problem.
The basic concept is finished. One of the algorithms for solving the maximum matching problem is the Hungarian algorithm , and the concepts below are for this algorithm service.
Alternate Path : From an unmatched point, followed by a non-matching edge, matching edge, non-matching edge ... The formed path is called alternating road.
Augmented Road : From an unmatched point, take the alternate road, if the way another unmatched point (the point of departure does not count), then this alternate road is called the augmented path (agumenting path). For example, Figure 5 shows an augmented path of 6 (the matching points in the figure are marked in red):
There is an important feature of the augmented path: a non-matching edge is more than a matching edge. Therefore, the significance of studying the augmented path is to improve the matching . Simply swap the identities of the matching and non-matching edges in the augmented path. This does not break the matching character because there are no other matching edges in the middle of the matching node. After the swap, the number of matching edges in the figure is 1 more than the original one.
We can add matching edges and matching points in the match by constantly looking for the augmented path. When the augmented path is not found, the maximum match is reached (this is the augmented path theorem). This is exactly what the Hungarian algorithm does. Before you give the Hungarian algorithm DFS and BFS versions of the code, first talk about the Hungarian tree.
The Hungarian tree is generally constructed from BFS (similar to the BFS tree). Run BFS from an unmatched point (the only limitation is that you must take the alternate path) until you can no longer expand. For example, from Figure 7, you can get 8 of a BFS tree:
This tree has a leaf node as a non-matching point (number 7th), but the Hungarian tree requires all leaf nodes to be the matching points, so this is not a Hungarian tree. If the original image does not contain the number 7th node, then a Hungarian tree will be obtained from node 2nd. This scenario is shown in 9 (by the way, in Figure 8, the root node 2 to the non-matching leaf node 7 is obviously an augmented path that will be a perfect match along the augmented path).
Transferred from: http://blog.csdn.net/pi9nc/article/details/11848327
Maximum matching of binary graphs--Hungarian algorithm