Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bipartite Graph Matching and Vertex Cover

Bipartite Graph Matching and Vertex Cover

Illustration of bipartite graph maximum matching and equivalence with the minimum vertex cover problem. Simple algorithms for their computation are shown

Gustavo Torres

June 03, 2012
Tweet

More Decks by Gustavo Torres

Other Decks in Programming

Transcript

  1. of 31 BIPARTITE GRAPH BIPARTITE GRAPH 3 u1 u2 u3

    v1 v2 b c a G2 G1 A graph is bipartite iff it can be divided in two sets U and V such that there is no edge from U to V
  2. of 31 TESTING BIPARTITENESS TESTING BIPARTITENESS 4 u1 u2 u3

    v1 v2 b c a Start with any node and color it red
  3. of 31 TESTING BIPARTITENESS TESTING BIPARTITENESS 5 u1 u2 u3

    v1 v2 b c a Color all its neighbors with the opposite color (blue)
  4. of 31 TESTING BIPARTITENESS TESTING BIPARTITENESS 6 u1 u2 u3

    v1 v2 b c a Repeat the same with the recently colored neighbors, using a queue, until there is an inconsitency or the queue is empty
  5. of 31 TREE BIPARTITE TREE BIPARTITE 8 a b c

    d r f e A tree is an undirected graph that is connected and has no cycles
  6. of 31 TREE BIPARTITE TREE BIPARTITE 9 a b c

    d r f e Nodes at even distance from a root are blue and nodes at odd are red
  7. of 31 TREE BIPARTITE TREE BIPARTITE 10 a b c

    d r f e Nodes at even distance from a root are blue and nodes at odd are red
  8. of 31 MATCHING MATCHING 11 u1 u2 u3 v1 v2

    u1 u2 u3 v1 v2 A matching is a set of edges without common vertices M1 M2
  9. of 31 MAXIMAL MATCHIING MAXIMUM MATCHING 12 u1 u2 u3

    v1 v2 u1 u2 u3 v1 v2 A maximum matching is a matching with a maximum number of edges Maximum Not maximum
  10. of 31 AUGMENTING PATH AUGMENTING PATH 13 u1 u2 u3

    v1 v2 An alternating path is a path in which the edges belong alternatively in the matching and not in it u1 v1 u2 An augmenting path is an alternating path with starts an ends in unmatched vertices u1 v1 u2 v2
  11. of 31 FINDING MAXIMUM MATCH FINDING MAXIMUM MATCHING 14 u1

    u2 u3 v1 v2 Start with any edge as a starting matching (v1,u2)
  12. of 31 FINDING MAXIMUM MATCH FINDING MAXIMUM MATCHING 15 u1

    u2 u3 v1 v2 While you can find an augmenting path from U to V u1 v1 u2 v2
  13. of 31 FINDING MAXIMUM MATCH FINDING MAXIMUM MATCHING 16 u1

    u2 u3 v1 v2 Create a new matching by switching the edges u1 v1 u2 v2
  14. of 31 FINDING MAXIMUM MATCH FINDING MAXIMUM MATCHING 17 Given

    a G=(V, E) we have that there are at most |V| augmenting paths. And since each augmenting path can be found with BFS in O(|V| + |E|). Thus we can find a maximum matching in a bipartite graph in O(|V|2+ |V||E|)
  15. of 31 VERTEX COVER VERTEX COVER 18 A vertex cover

    is a set of vertices such that each edge in the graph is incident to at least one vertex in the set u1 u2 u3 v1 v2
  16. of 31 MINIMUM VERTEX COVER MINIMUM VERTEX COVER 19 A

    minimum vertex cover is one with the minimal amount of vertices in the cover u1 u2 u3 v1 v2
  17. of 31 KÖNIG’S THEOREM KÖNIG’S THEOREM 20 u1 u2 u3

    v1 v2 In any bipartite graph, the number of edges in a maximum matching equals the number of vertices in a minimum vertex cover
  18. of 31 KÖNIG’S THEOREM KÖNIG’S THEOREM 21 u1 u2 u3

    v1 v2 Given G = (U∪V, E), and the maximum matching M then a minimum vertex cover of G is given by (U - T) ∪ (V ∩ T) Where T is the set of vertices which can be reached by a directed path from a matched vertex in U
  19. of 31 KÖNIG’S THEOREM KÖNIG’S THEOREM 22 u1 u2 u3

    v1 v2 T = {u1, u2, u3, v1, v2} The vertex cover given by (U - T) ∪ (V ∩ T) is v1 v2
  20. of 31 KÖNIG’S THEOREM KÖNIG’S THEOREM 23 u1 u2 u3

    v1 v2 T = {u1, u2, u3, v1, v2} The vertex cover given by (U - T) ∪ (V ∩ T) is v1 v2