1 / 39

Bipartite Matching

Bipartite Matching. Lecture 8: Oct 7. This Lecture. Graph matching is an important problem in graph theory. It has many applications and is the basis of more advanced problems. In the last lecture we consider the stable matching problem. Today we will study the bipartite matching problem.

kotter
Download Presentation

Bipartite Matching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bipartite Matching Lecture 8: Oct 7

  2. This Lecture Graph matching is an important problem in graph theory. It has many applications and is the basis of more advanced problems. In the last lecture we consider the stable matching problem. Today we will study the bipartite matching problem. • Problem and Hall’s theorem • Reductions and Applications • Proof of Hall’s theorem (optional)

  3. Bipartite Matching • The Bipartite Marriage Problem: • There are n boys and n girls. • For each pair, it is either compatible or not. Goal: to find the maximum number of compatible pairs.

  4. Bipartite Matching • The Bipartite Marriage Problem: • There are n boys and n girls. • For each pair, it is either compatible or not. Goal: to find the maximum number of compatible pairs.

  5. Graph Problem A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that each edge has one endpoint in A and the other endpoint in B. B A A matching is a subset of edges so that every vertex has degree at most one.

  6. Maximum Matching The bipartite matching problem: Find a matching with the maximum number of edges. A perfect matching is a matching in which every vertex is matched (i.e. of degree 1). The perfect matching problem: Is there a perfect matching? Once you know how to solve perfect matching, you can also do maximum matching.

  7. Examples Which bipartite graphs have a perfect matching?

  8. Examples Which bipartite graphs have a perfect matching?

  9. Working for the King Suppose you work for the King, and your job is to find a perfect matching between 200 men and 200 women. If there is a perfect matching, then you can show it to the King. But suppose there is no perfect matching, how can you convince the King this fact (i.e. there is really no perfect matching, not because you are incompetent)? One attempt is to try all the possibilities and show that none works, but you can imagine the King won’t have the time and patience for that. Is that a smarter way? It is difficult to argue that no solution exists.

  10. Examples Which bipartite graphs have a perfect matching?

  11. Some Notation N(S) S Let S be a subset of vertices on one side, and |S| be the number of vertices in S. Let N(S) be the neighbours of vertices in S, i.e. a vertex v belongs to N(S) iff v is a neighbor of some vertex in S. Let |N(S)| be the number of vertices in N(S).

  12. A Necessary Condition N(S) S If |N(S)| < |S| for some S, then it is impossible to have a perfect matching. In other words, in order to have a perfect matching, a necessary condition is that for all subsets S on one side, we must have |N(S)| >= |S|.

  13. Hall’s Theorem Is it the only situation when a bipartite graph does not have a perfect matching? Hall said yes in 1935. Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V and for every subset S of W. This is a deep theorem. It characterizes exactly when a bipartite graph does not have a perfect matching. (Now you can convince the king.)

  14. This Lecture • Problem and Hall’s theorem • Reductions and Applications • Proof of Hall’s theorem (optional)

  15. Application 1: Job Assignment Job Assignment Problem: There are n persons and n jobs. Each person is willing to do a subset of jobs. Can you find an assignment so that all jobs are taken care of while everyone is responsible for at most one job? Leo Jesse Tom Hackson Marking Tutorials Solutions Newsgroup A perfect matching corresponds to a perfect assignment.

  16. Application 1: Job Assignment Job Assignment Problem: There are n persons and n jobs. Each person is willing to do a subset of jobs. Can you find an assignment so that all jobs are taken care of while everyone is responsible for at most one job? We can model the job assignment problem as a bipartite matching problem. We create a vertex for each person, and we create a vertex for each job. If a person is willing to do a job, then we add an edge between them. Then a perfect matching corresponds to a perfect “assignment”. This problem can be generalized to give different workload to each person. In fact, there is an efficient algorithm to find such as assignment! (CSC 3160)

  17. Application 2: Domino Puzzle Can you fill a (incomplete) chessboard perfectly with dominos?

  18. Application 2: Domino Puzzle Create a vertex for each square in the board. Add an edge for two squares if they are adjacent. This is a bipartite graph with the black and white squares form the two sides. A perfect matching in this graph corresponds to a perfect placement of dominos.

  19. Application 2: Domino Puzzle This is another example where we can model a problem as a graph problem.

  20. Application 3: Partial Latin Square • Latin Square: an nxn square, the goal is to fill the square • with numbers from 1 to n so that: • Each row contains every number from 1 to n. • Each column contains every number from 1 to n.

  21. Application 3: Partial Latin Square Suppose you are given a partial Latin Square when some rows are already filled in. Can you always extend it to a Latin Square? Using bipartite matching, we can prove that the answer is yes. • The proof consists of two steps: • Reduce the problem into a bipartite matching problem. • Prove that the bipartite matching problem always has a solution by Hall’s theorem.

  22. Step 1: Reduction to Bipartite Matching First, we reduce the problem to a bipartite matching problem. Given a partial Latin square, we construct a bipartite graph to fill in the next row. 1 2 3 4 5 column number 1 2 3 4 5 We want to “match” the numbers to the columns. Create one vertex for each column, and one vertex for each number. Add an edge between column i and color j if color j can be put in column i.

  23. Step 1: Reduction to Bipartite Matching Given a partial Latin square, we construct a bipartite graph to fill in the next row. 1 2 3 4 5 column 1 5 2 4 3 number 1 2 3 4 5 A perfect matching corresponds to a valid assignment of the next row. If we can always complete the next row, then by induction we are done. The key is to prove that the bipartite graph always has a perfect matching.

  24. Using Hall’s Theorem Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V and W. A graph is k-regular if every vertex is of degree k. A 3-regular bipartite graph

  25. Using Hall’s Theorem Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V and W. Claim: Every k-regular bipartite graph has a perfect matching. A 3-regular bipartite graph

  26. Using Hall’s Theorem Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V and W. Claim: Every k-regular bipartite graph has a perfect matching. To prove this claim using Hall’s theorem, we need to verify |N(S)| >= |S| for every subset S. • Proof by contradiction: • Suppose there is a subset S with |S| > |N(S)|. • All the edges from S go to N(S). • There are total k|S| edges from S to N(S). • But the total degree of N(S) is k|N(S)| < k|S|. • A contradiction. N(S) S

  27. Step 2: Completing Latin Square Claim: Every k-regular bipartite graph has a perfect matching. 1 2 3 4 5 column number 1 2 3 4 5 The bipartite graphs coming from Latin square are always regular because: Suppose there are k unfilled rows. Then each column has n-k distinct numbers, and so connected to k numbers. Each number appeared in n-k columns above, and so connected to k columns. So, the bipartite graph is k-regular, and thus always has a perfect matching.

  28. More Applications (Optional) The bipartite matching problem is an important problem and has many applications. One important application is the “maximum flow problem”. This is to find the maximum number of “edge disjoint paths” between two nodes. This can be applied to find the maximum amount of information one can send from one point in the network to another point in the network. This problem can be reduced to the bipartite matching problem (CSC 3160).

  29. This Lecture • Problem and Hall’s theorem • Reductions and Applications • Proof of Hall’s theorem (optional)

  30. Proof of Hall’s Theorem (easy direction) Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V. One direction is easy, if there is a perfect matching, then |N(S)| >= |S| for every subset S of V. N(S) S Just consider the neighbours of S in the perfect matching.

  31. Proof of Hall’s Theorem (difficult direction) Hall’s Theorem: A bipartite graph G=(V,W;E) has a perfect matching if and only if |N(S)| >= |S| for every subset S of V. Another direction is more interesting, we need to show whenever |N(S)| >= |S| for all S, then there is a perfect matching! How to prove such kind of statement? Proof by strong induction on the number of edges.

  32. Proof of Hall’s Theorem Hall’s Theorem: If |N(S)| >= |S| for every subset S of V, then there is a perfect matching. Case 1: Every proper subset S has |N(S)| > |S|. (Easy case) • Just delete an edge. • By deleting an edge, |N(S)| can decrease by at most 1. • Since |N(S)| > |S| before, • we still have |N(S)| >= |S| after deleting an edge. • Since the graph is smaller (one fewer edge), by induction, • there is a perfect matching in this smaller graph, • hence there is a perfect matching in the original graph.

  33. Proof of Hall’s Theorem Hall’s Theorem: If |N(S)| >= |S| for every subset S of V, then there is a perfect matching. Case 2: Suppose there is a proper subset S with |N(S)| = |S|. Divide the graph into two smaller graphs G1 and G2 (so we can apply induction) Find a perfect matching in G1 by induction. G1 Then we are done. N(S) G2 S Find a perfect matching in G2 by induction.

  34. Proof of Hall’s Theorem Why there is a perfect matching in G2? Hall’s Theorem: If |N(S)| >= |S| for every subset S of V, then there is a perfect matching. To apply Hall’s, we want to show for any subset T of S, |N(T) G2| >= |T|. T |N(T) G2| N(S) G2 S

  35. Proof of Hall’s Theorem Why there is a perfect matching in G2? For any subset T S, N(T) is contained in G2. Hence, |N(T) G2| = |N(T)| >= |T|. Therefore, by induction, there is a perfect matching in G2. T |N(T) G2| N(S) G2 S Find a perfect matching in G2 by induction.

  36. Proof of Hall’s Theorem Why there is a perfect matching in G1? For any subset T, we want to show |N(T) G1| >= |T| to apply induction. • Consider T, by assumption, |N(T)| >= |T| • Can we conclude that |N(T) G1| >= |T|? • No, because N(T) may intersect N(S)! Now what? N(T) G1 T N(S) S

  37. Proof of Hall’s Theorem Why there is a perfect matching in G1? For any subset T, we want to show |N(T) G1| >= |T| to apply induction. • Consider S T, by assumption, |N(S T)| >= |S T| (the green areas). • Since |S|=|N(S)|, |N(S T) – N(S)| >= |S T - S| (the red areas). • So |N(T) G1| = |N(S T) – N(S)| >= |S T – S| = |T|, as required. N(T) G1 (red) T N(S T) (green) |S|=|N(S)| N(S) S

  38. Proof of Hall’s Theorem Hall’s Theorem: If |N(S)| >= |S| for every subset S of V, then there is a perfect matching. Case 2: Suppose there is a subset S with |N(S)| = |S|. Divide the graph into two smaller graphs G1 and G2 (so we can apply induction) Find a perfect matching in G1 by induction. G1 Now we are done. N(S) G2 S Find a perfect matching in G2 by induction.

  39. Bipartite Matching and Hall’s Theorem • Hall’s theorem is a fundamental theorem in graph theory. • In this course, it is important to learn • how to use bipartite matching to solve problems, and • how to apply Hall’s theorem. • The proof of Hall’s theorem is optional.

More Related