问题
I am trying to figure out an algorithm for finding minimum vertex cover of a bipartite graph.
I was thinking about a solution, that reduces the problem to maximum matching in bipartite graph. It's known that it can be found using max flow in networ created from the bip. graph.
Max matching M should determine min. vertex cover C, but I can't cope with choosing the vertices to set C. Let's say bip. graph has parts X, Y and vertices that are endpoints of max matching edges are in set A, those who are not belong to B.
I would say I should choose one vertex for an edge in M to C. Specifically the endpoint of edge e in M that is connected to vertex in set B, else if it is connected only to vertices in A it does not matter. This idea unfortunately doesn't work generally as there can be counterexamples found to my algorithm, since vertices in A can be also connected by other edges than those who are included in M.
Any help would be appriciated.
回答1:
Kőnig's theorem proof does exactly that - building a minimum vertex cover from a maximum matching in a bipartite graph.
Let's say you have G = (V, E)
a bipartite graph, separated between X
and Y
.
As you said, first you have to find a maximum matching (which can be achieved with Dinic's algorithm for instance). Let's call M
this maximum matching.
Then to construct your minimum vertex cover:
- Find
U
the set (possibly empty) of unmatched vertices inX
1, ie. not connected to any edge inM
- Build
Z
the set or vertices either inU
, or connected toU
by alternating paths (paths that alternate between edges ofM
and edges not inM
) - Then
K = (X \ Z) U (Y ∩ Z)
is your minimum vertex cover
The Wikipedia article has details about how you can prove K
is indeed a minimum vertex cover.
1 Or Y, both are symmetrical
来源:https://stackoverflow.com/questions/42836016/algorithm-for-minimum-vertex-cover-in-bipartite-graph