# Bipartite Matching, Extremal Problems, Matrix Tree Theorem.

## Presentation on theme: "Bipartite Matching, Extremal Problems, Matrix Tree Theorem."— Presentation transcript:

Bipartite Matching, Extremal Problems, Matrix Tree Theorem.

Today’s Plan Proof of Hall’s theorem Algorithms for bipartite matching
Extremal problems Matrix tree theorem

Perfect Matching Does a perfect matching always exist? Of course not.
If there are more vertices on one side, then of course it is impossible. N(S) S Let N(S) be the neighbours of vertices in S. If |N(S)| < |S|, then it is impossible to have a perfect matching.

A Necessary and Sufficient Condition
Is it the only situation when a bipartite graph does not have a perfect matching? 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. This is a deep theorem. It tells you exactly when a bipartite graph does not have a perfect matching. (Now you can convince the king.)

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|, 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 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 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) G2 = N(T). By assumption, |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 T |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.

Today’s Plan Proof of Hall’s theorem Algorithms for bipartite matching
Extremal problems Matrix tree theorem

First Try Greedy method? (add an edge with both endpoints unmatched)

Key Questions How to tell if a graph does not have a (perfect) matching? How to determine the size of a maximum matching? How to find a maximum matching efficiently?

Existence of Perfect Matching
Hall’s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that “saturates” A if and only if |N(S)| >= |S| for every subset S of A. N(S) S

Bound for Maximum Matching
What is a good upper bound on the size of a maximum matching? König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Min-max theorem NP and co-NP Implies Hall’s theorem.

Algorithmic Idea? Any idea to find a larger matching?

Augmenting Path Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path whose endpoints are unmatched by M is an M-augmenting path.

Optimality Condition What if there is no more M-augmenting path?
If there is no M-augmenting path, then M is maximum! Prove the contrapositive: A bigger matching  an M-augmenting path Consider Every vertex in has degree at most 2 A component in is an even cycle or a path Since , an M-augmenting path!

Algorithm Key: M is maximum  no M-augmenting path
How to find efficiently? How to find efficiently?

Finding M-augmenting paths
Orient the edges (edges in M go up, others go down) An M-augmenting path  a directed path between two unmatched vertices

Complexity At most n iterations
An augmenting path in time by a DFS or a BFS Total running time

Minimum Vertex Cover Hall’s Theorem [1935]:
A bipartite graph G=(A,B;E) has a matching that “saturates” A if and only if |N(S)| >= |S| for every subset S of A. König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Idea: consider why the algorithm got stuck…

Today’s Plan Proof of Hall’s theorem Algorithms for bipartite matching
Extremal problems Matrix tree theorem