bipartite matchings and stable marriage
play

Bipartite Matchings and Stable Marriage Meghana Nasre Department of - PowerPoint PPT Presentation

Bipartite Matchings and Stable Marriage Meghana Nasre Department of Computer Science and Engineering Indian Institute of Technology, Madras Faculty Development Program SSN College of Engineering, Chennai December 12, 2014 Why matchings?


  1. Bipartite Matchings and Stable Marriage Meghana Nasre Department of Computer Science and Engineering Indian Institute of Technology, Madras Faculty Development Program SSN College of Engineering, Chennai December 12, 2014

  2. Why matchings? Several real world applications involve assigning: • jobs to machines. • students to projects. • jobs to applicants. • roommate to another.

  3. Outline of Talk • Quick introduction to graphs. • Matchings in graphs. • Bipartite matching algorithm. • Stable matchings.

  4. Introduction to graphs

  5. Representation and search techniques G = ( V , E ). v2 v1 v6 v3 v5 n = | V | = 6, m = | E | = 8. v4 How large can m be?

  6. Representation and search techniques G = ( V , E ). v2 v1 v6 v3 v5 n = | V | = 6, m = | E | = 8. v4 How large can m be? Representation: • Adjacency Lists – O ( m + n ) space. • Adjacency Matrix – O ( n 2 ) space.

  7. Representation and search techniques G = ( V , E ). v2 v1 v6 v3 v5 n = | V | = 6, m = | E | = 8. v4 How large can m be? Representation: • Adjacency Lists – O ( m + n ) space. • Adjacency Matrix – O ( n 2 ) space. Search methods: • Breadth First Search. • Depth First Search.

  8. Matching in a graph

  9. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v1 v6 v5 v3 v4

  10. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v1 v6 v5 v3 v4

  11. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v1 v6 v5 v3 v4 • Goal: compute a maximum sized matching. • Question: is the above matching maximum sized?

  12. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v2 v1 v1 v6 v6 v5 v3 v5 v3 v4 v4

  13. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v2 v1 v1 v6 v6 v5 v3 v5 v3 v4 v4 • Maximal: No more edges can be added to the matching.

  14. Matching in a graph A matching M is a set of vertex disjoint edges. v2 v2 v1 v1 v6 v6 v5 v3 v5 v3 v4 v4 • Maximal: No more edges can be added to the matching. Size may not be largest possible. • Maximum: Has size as large as possible. Note that every maximum matching is maximal.

  15. Alternating paths A path having alternate matched and unmatched edges. v2 v1 v6 v5 v3 v4

  16. Alternating paths A path having alternate matched and unmatched edges. v2 v1 v6 v5 v3 v4 • Is there any other alternating path?

  17. Alternating paths A path having alternate matched and unmatched edges. v2 v1 v6 v5 v3 v4 • Is there any other alternating path? • Which paths are not alternating?

  18. Augmenting paths An alternating path starting and ending in free edges. v2 v1 v6 v5 v3 v4

  19. Augmenting paths An alternating path starting and ending in free edges. v2 v1 v6 v5 v3 v4 • How are augmenting paths useful? • Properties of augmenting paths.

  20. Using augmenting paths Berge’s Theorem • If aug. path P is present ⇒ size of matching can be increased.

  21. Using augmenting paths Berge’s Theorem • If aug. path P is present ⇒ size of matching can be increased. • M ′ = M ⊕ P . v2 v2 v1 v1 v6 augment M with P v6 P P v5 v3 v5 v3 v4 v4 M M’

  22. Using augmenting paths Berge’s Theorem • If no aug. path w.r.t. M ⇒ M is maximum. Proof (by contradiction) • Suppose M does not admit any aug. path and still it is not maximum. • Some other matching M ′ is maximum.

  23. Using augmenting paths Berge’s Theorem • If no aug. path w.r.t. M ⇒ M is maximum. Proof (by contradiction) • Suppose M does not admit any aug. path and still it is not maximum. • Some other matching M ′ is maximum. • Consider M ⊕ M ′ . • Construct an aug. path w.r.t. M .

  24. Maximum matching algorithm Given G = ( V , E ), compute a maximum sized matching.

  25. Maximum matching algorithm Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M .

  26. Maximum matching algorithm Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Two questions that need to be always asked: 1. Correctness? 2. Complexity/ Running time?

  27. Maximum matching algorithm Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Two questions that need to be always asked: 1. Correctness? 2. Complexity/ Running time? How to efficiently compute an augmenting path?

  28. Bipartite matching algorithm

  29. Bipartite graphs G = ( A ∪ B , E ). B A Equivalent statements • Vertices can be partitioned into 2 disjoint sets. • G is bipartite iff G does not have any odd cycle. • Graph is 2 colorable iff it is bipartite.

  30. Finding aug. path in bipartite graphs b1 a1 a2 b2 a3 b3 b4 a4 b5 a5 B A

  31. Finding aug. path in bipartite graphs b1 a1 Aug. paths w.r.t. M : a2 • � a 1 , b 2 � . b2 • � a 5 , b 5 � . a3 b3 b4 a4 b5 a5 B A

  32. Finding aug. path in bipartite graphs b1 a1 Aug. paths w.r.t. M : a2 • � a 1 , b 2 � . b2 • � a 5 , b 5 � . a3 b3 • � a 4 , b 3 , a 2 , b 4 � . b4 a4 b5 a5 B A

  33. Finding aug. path in bipartite graphs b1 a1 Aug. paths w.r.t. M : a2 • � a 1 , b 2 � . b2 • � a 5 , b 5 � . a3 b3 • � a 4 , b 3 , a 2 , b 4 � . b4 a4 Finding aug. paths – reachability in a modified graph. b5 a5 B A

  34. Finding aug. path in bipartite graphs b1 b1 a1 a1 a2 b2 a2 b2 a3 b3 t a3 b3 s b4 b4 a4 a4 b5 b5 a5 a5 B A B A

  35. Finding aug. path in bipartite graphs b1 b1 a1 a1 a2 b2 a2 b2 a3 b3 t a3 b3 s b4 b4 a4 a4 b5 b5 a5 a5 B A B A • Add dummy nodes s and t . • Add edges from s to unmatched vertices in A . • Add edges from unmatched vertices in B to t . • Matched edges: B → A . • Unmatched edges: A → B .

  36. Finding aug. path in bipartite graphs b1 b1 a1 a1 a2 b2 a2 b2 a3 b3 t a3 b3 s b4 b4 a4 a4 b5 b5 a5 a5 B A B A Aug. path in G w.r.t. M is a simple directed s to t path in G ′ .

  37. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time?

  38. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time? 1. How many iterations?

  39. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time? 1. How many iterations? at most n / 2.

  40. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time? 1. How many iterations? at most n / 2. 2. How long does each iteration take?

  41. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time? 1. How many iterations? at most n / 2. 2. How long does each iteration take? at most O ( m + n ).

  42. Maximum matching in bipartite graph Given G = ( V , E ), compute a maximum sized matching. Iterative Improvement • Initialize M to be empty. • while there exists an aug. path P w.r.t. M • M = M ⊕ P . • return M . Running time? 1. How many iterations? at most n / 2. 2. How long does each iteration take? at most O ( m + n ). 3. Total running time: O ( mn ).

  43. Efficient algorithms • The best known for both bipartite and general graphs is O ( √ nm ) time algorithms. • Algorithms on general graphs are significantly involved.

  44. Efficient algorithms • The best known for both bipartite and general graphs is O ( √ nm ) time algorithms. • Algorithms on general graphs are significantly involved. Edmond’s Blossom Shrinking algorithm. (Also the paper where the notion of polynomial time being efficient was formalized). • Weighted matchings can also be done in polynomial time. • Beautiful theory of Linear Programming Duality involved.

  45. Stable matching problem

  46. A bit of history.. • Introduced by Gale and Shapley in 1962 while studying college admissions. • Bipartite matching problem with preferences. • Arises in several places like TA-allocation, project allocation. • Classical setting: marriage between n men and n women.

  47. Setting Input: m 1 : w 1 , w 2 , w 3 w 1 : m 3 , m 2 , m 1 m 2 : w 2 , w 3 , w 1 w 2 : m 2 , m 1 , m 3 m 3 : w 3 , w 1 , w 2 w 3 : m 1 , m 3 , m 2 Goal: To compute a matching that is “optimal”.

Recommend


More recommend