Bipartite Matching Lecture 8: Oct 7.

Slides:



Advertisements
Similar presentations
CS 336 March 19, 2012 Tandy Warnow.
Advertisements

Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Playing Fair at Sudoku Joshua Cooper USC Department of Mathematics.
Tutorial 6 of CSCI2110 Bipartite Matching Tutor: Zhou Hong ( 周宏 )
1 Weighted Bipartite Matching Lecture 4: Jan Weighted Bipartite Matching Given a weighted bipartite graph, find a matching with maximum total weight.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
1 Bipartite Matching Lecture 3: Jan Bipartite Matching A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that.
1 Bipartite Matching Polytope, Stable Matching Polytope x1 x2 x3 Lecture 10: Feb 15.
Matching Polytope, Stable Matching Polytope Lecture 8: Feb 2 x1 x2 x3 x1 x2 x3.
9.2 Graph Terminology and Special Types Graphs
 Jim has six children.  Chris fights with Bob,Faye, and Eve all the time; Eve fights (besides with Chris) with Al and Di all the time; and Al and Bob.
10.4 How to Find a Perfect Matching We have a condition for the existence of a perfect matching in a graph that is necessary and sufficient. Does this.
Lecture 5.2: Special Graphs and Matrix Representation CS 250, Discrete Structures, Fall 2013 Nitesh Saxena Adopted from previous lectures by Zeph Grunschlag.
Lecture 22 More NPC problems
10.3 The Main Theorem. Theorem (The Marriage Theorem) A bipartite graph has a perfect matching if and only if IAI = IBI and for any subset of (say)
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Matching Lecture 19: Nov 23.
Introduction to Graph Theory
Introduction to Graph Theory
Proof of correctness of Dijkstra’s algorithm: Basically, we need to prove two claims. (1)Let S be the set of vertices for which the shortest path from.
1 Graphs Chapters 10.1 and 10.2 University of Maryland Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Hex: a Game of Connecting Faces. Player 1 Player 2 Players take turns placing blue chips (player 1) and red chips (player 2). Player 1 plays first. Player.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
More NP-Complete and NP-hard Problems
More NP-complete problems
Planar Graphs Hubert Chan (Chapter 9.7) [O2 Proof Techniques]
מתמטיקה בדידה Discrete Math Lecture 12 1 TexPoint fonts used in EMF.
Graph Coloring.
Mathematical Foundations of AI
Lap Chi Lau we will only use slides 4 to 19
Lecture 5.2: Special Graphs and Matrix Representation
Applied Discrete Mathematics Week 13: Graphs
Special Graphs By: Sandeep Tuli Astt. Prof. CSE.
Copyright © Zeph Grunschlag,
Redraw these graphs so that none of the line intersect except at the vertices B C D E F G H.
Topics in Algorithms Lap Chi Lau.
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
Graph theory Definitions Trees, cycles, directed graphs.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Bipartite Graphs What is a bipartite graph?
Perfect Matchings in Bipartite Graphs
Algorithms and Networks
Algorithm Design and Analysis
Gray Code Can you find an ordering of all the n-bit strings in such a way that two consecutive n-bit strings differed by only one bit? This is called the.
Great Theoretical Ideas in Computer Science
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Chapter 5. Optimal Matchings
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Graphs Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Discrete Mathematics for Computer Science
CSE 421: Introduction to Algorithms
Graph Algorithms – 2 DAGs Topological order
3.3 Applications of Maximum Flow and Minimum Cut
Parameterised Complexity
Instructor: Shengyu Zhang
Chapters 8.1 and 8.2 Based on slides by Y. Peng University of Maryland
Lectures on Graph Algorithms: searching, testing and sorting
Linear Programming Duality, Reductions, and Bipartite Matching
Graph Coloring.
Systems of distinct representations
Bipartite Graph 1. A graph G is bipartite if the node set V can be partitioned into two sets V1 and V2 in such a way that no nodes from the same set are.
CSE 6408 Advanced Algorithms.
V12 Menger’s theorem Borrowing terminology from operations research
Graph Theory Proof In Class Exercise.
CS 173, Lecture B Tandy Warnow
Presentation transcript:

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. Problem and Hall’s theorem Reductions and Applications Proof of Hall’s theorem (optional)

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.

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.

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. A B A matching is a subset of edges so that every vertex has degree at most one.

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.

Examples Which bipartite graphs have a perfect matching?

Examples Which bipartite graphs have a perfect matching?

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.

Examples Which bipartite graphs have a perfect matching?

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).

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|.

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.)

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

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 Hackson Jesse Tom Marking Tutorials Solutions Newsgroup A perfect matching corresponds to a perfect assignment.

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)

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

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.

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

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.

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.

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.

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.

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

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

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

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.

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).

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

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. S N(S) Just consider the neighbours of S in the perfect matching.

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.

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.

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. G2 S N(S) Find a perfect matching in G2 by induction.

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| G2 S N(S)

Find a perfect matching in G2 by induction. 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| G2 S N(S) Find a perfect matching in G2 by induction.

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 S N(S)

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)| S N(S)

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. G2 S N(S) Find a perfect matching in G2 by induction.

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.