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.
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 betweenXandY.As you said, first you have to find a maximum matching (which can be achieved with Dinic's algorithm for instance). Let's call
Mthis maximum matching.Then to construct your minimum vertex cover:
Uthe set (possibly empty) of unmatched vertices inX1, ie. not connected to any edge inMZthe set or vertices either inU, or connected toUby alternating paths (paths that alternate between edges ofMand edges not inM)K = (X \ Z) U (Y ∩ Z)is your minimum vertex coverThe Wikipedia article has details about how you can prove
Kis indeed a minimum vertex cover.1 Or Y, both are symmetrical