Learning bipartite graph matching note

Learning bipartite graph matching note

This blog is currently not done more

Just started to play when the cancer was dead. .

Leve1  Luo Gu P3386 [template] bipartite graph matching 

Hungarian algorithm [Hungury algorithm]

Title effect: Given a bipartite graph, each represent a number of nodes n, m, side is e, seeking bipartite graph largest number of matched

Primary codes

1  into the DFS, determines whether there has been accessed
 2  and enumerate each of the adjacent sides
 3  and then get another point, to do so, it is determined whether there is a change can not access their own or a matching point
 4  then dfs back, apparently this point it is possible to match the
 5 and then return to

Here to talk about the meaning of the third step

For example this picture, this process is like Zhao Xifu

He began to find a point of not being accessed

OK, now we have left of the first point to find a wife

Then the first point to complete the scan of the left two points, two points when the first left angry to find that the first point to the left to grab the only thing he could grab the wife, this not OK, ah, from negotiations.

Then follow the path to the left blue dot interference launched the first point, the first point say, well, anyway, a lot of my wife

Keep foreign armed intervention forces affect ......

Happiness and happy ending ......

 

Obviously, this question bare hack data is carefully constructed, then it would be a misunderstanding novice (like me),

hack data:

input
5 5 11
1 2
1 5
2 2
2 3
2 4
3 1
3 5
4 1
4 2
4 5
5 2
output 
4

 

Guess you like

Origin www.cnblogs.com/zsx6/p/11104792.html