Chapter 6 Matchings
Our goal in this chapter is to determine a necessary and sufficient condition for a bipartite graph to have a perfect matching. Along the way we will see a connection between matchings and vertex covers.
We will start with a few activities to become familiar with these concepts.
Activity 18.
A matching of a (usually bipartite) graph is a 1-regular subgraph. That is, a subset of non-adjacent edges (an independent set of edges). If a matching happens to be a spanning subgraph (so a 1-factor) then we call it a perfect matching.
Whether or not a graph has a perfect matching, we can try to find a maximum matching: one that uses the largest number of edges possible.
(a)
Through trial and error, find a maximum matching of the graph below.
(b)
Your friend claims that she has found the largest partial matching for the graph below (her matching is in bold). She explains that no other edge can be added, because all the edges not used in her partial matching are connected to matched vertices. Is she correct?
(c)
What about these matchings? Are they maximal?
In particular, how does the matching on the right relate to the matching on the left?
Activity 19.
Given any matching \(M\) of a graph \(G\text{,}\) and any unmatched vertex \(v\text{,}\) we can consider paths starting at \(v\) that consist of edges not in the matching and in the matching, alternating between the two types. We call such a path an alternating path (or sometimes an \(M\)-alternating path).
An alternating path that ends in an unmatched vertex (i.e., a vertex that is not incident to any edge in the matching) is called an augmenting path. Why is this a good name?
(a)
Suppose a particular graph has matching \(M\text{.}\) What can you say about the matching if there is some unmatched vertex \(v\) from which there is an \(M\)-augmenting path? Could the matching be a maximum matching?
(b)
Suppose a particular graph has a matching \(M\) for which there are no \(M\)-augmenting paths (from any unmatched vertex). What can you say about \(M\text{?}\) Must the matching be a maximum matching?
(c)
Describe an algorithm that always produces a maximum matching of a given bipartite graph \(G\text{.}\)
Activity 20.
A vertex cover is a subset \(U \subseteq V\) of vertices such that every edge of the graph is incident to a vertex of \(U\text{.}\)
Notice that if we take \(U = V\text{,}\) we get a vertex cover. The interesting question here is to find the minimum vertex cover: the cover of smallest size.
(a)
Through trial and error, find a minimum vertex cover for each of the graphs below.
(b)
One of the graphs above has a maximal matching shown below. Is there a minimum vertex cover that uses exactly one vertex from each edge in the matching?
(c)
Here is a matching of another graph above. Is there a minimum vertex cover that uses exactly one vertex from each edge in the matching?
(d)
For each of the graphs in the first task, find a maximal matching and compare it to your minimum vertex cover.
Let us reiterate the important definitions we will use.
Definition 6.0.1.
[definition of matching, maximum matching, perfect matching]
Definition 6.0.2.
[definition of vertex cover]
As we saw in the activities, an important tool in understanding both matchings and vertex covers is to consider paths that alternate between edges in and out of the matching.
Definition 6.0.3.
A path is called alternating if the path starts at a vertex not in the matching, and edges between subsequent vertices in the path alternate between not in the matching and in the matching. A path is called augmenting if it is an alternating path that starts and ends with edges not in the matching.
Before describing when a bipartite graph has a perfect matching, let us consider the connection between matchings and vertex covers. While these two concepts do not immediately seem related, note that any vertex cover must cover all the edges in a matching (in particular), and therefore must contain at least one of the vertices incident to each edge in the matching. In other words, there is no way for a vertex cover to use fewer vertices than there are edges in any matching.
This says that the size of a minimum vertex cover cannot be smaller than the size of a maximum matching. Surprisingly, these two quantities always align.
Theorem 6.0.4. Kőnig's Theorem.
In any bipartite graph, the size of a minimum vertex cover is equal to the size of a maximum matching.
Proof.
Let \(G=(V,E)\) be a bipartite graph. Let \(M\text{,}\) a subset of \(E\text{,}\) be a matching of \(G\text{,}\) meaning every vertex of \(G\) is incident with at most one edge in \(M\text{.}\) Let \(U\text{,}\) a subset of \(V\text{,}\) be a vertex cover, meaning every edge of \(G\) is incident to a vertex of \(U\text{,}\) alternatively, the subgraph \(G\setminus U\) will have no edges. To make this proof easier to follow let \(m(G)\) be the number of edges in the maximum matching of \(G\) and \(c(G)\) be the number of vertices in the minimum vertex cover of \(G\text{.}\) We will show that \(m(G)=c(G)\text{.}\)
Let \(G\) be a minimal counterexample,







In both cases we reach contradictions, hence \(m(G)\) cannot be strictly less than \(c(G)\text{.}\) So, we can conclude \(m(G)=c(G)\) when \(G\) is bipartite.
We have seen another theorem proved by Kőnig about bipartite graphs: Theorem 4.2.3. The proof of that theorem also used alternating paths. Could these two theorems be related somehow?
Question 6.0.5.
How are the two Kőnig theorems related?
Now on to perfect matchings. From here on out, we will assume that all our bipartite graphs have a bipartition \((A,B)\) with \(|A| = |B|\) (although most of what we will say would be true if the two sides were not equal, we would just speak of perfect matchings of \(A\text{,}\) in which every vertex of \(A\) is matched).
Recall that the neighborhood of a set of vertices \(S\text{,}\) written \(N(S)\) is the set of all vertices adjacent to a vertex of \(S\text{.}\) If a bipartite graph contains some subset \(S \subseteq A\) for which \(|S| \gt |N(S)|\text{,}\) then it is clear that there is no way to match all the vertices of \(S\text{,}\) so there cannot be a perfect matching. This “obvious” necessary condition is also sufficient.
Theorem 6.0.6. Hall's Theorem.
A bipartite graph \(G = (A,B)\) with \(|A| = |B|\) has a perfect matching if and only if \(|N(S)| \ge |S|\) for all \(S \subseteq A\text{.}\)
Proof.
First, consider the forward direction of Hall's Theorem and let \(G\) be a bipartite graph with \(|A| = |B|\) have a perfect matching. We will show that \(|N(S)| \ge |S|\) for all \(S \subseteq A\text{.}\) This is true somewhat trivially. If \(G\) has a perfect matching then each \(s \in S\) is matched with some vertex in \(B\) such that \(|N(S)| = |S|\text{,}\) so the condition is satisfied.
Second, consider the backwards direction of Hall's Theorem and let \(G\text{,}\) a bipartite graph with \(|A| = |B|\text{,}\) satisfy \(|N(S)| \ge |S|\text{.}\) We will show that \(G\) has a perfect matching. Suppose not, such that \(G\) satisfies \(|N(S)| \ge |S|\text{,}\) but a perfect matching does not exist. By considering the maximum matching, we know \(\exists a \in A\) such that \(a\) is unmatched. Now consider all alternating paths in \(G\) that start at \(a\text{.}\) Let \(X=N(a)\subseteq B\) and \(S=N(N(a))\subseteq A\text{.}\) There then cannot exist a maximal alternating path that ends at a vertex in \(B\text{,}\) otherewise that would be an augmenting path that would increase our matching. Thus every vertex in \(X\) is matched to a vertex in \(S-\{a\}\text{.}\) Similarly, every vertex in \(S-\{a\}\) is matched to a vertex in \(X\text{.}\) So, we then have a bijection between of \(S-\{a\}\) and \(X\text{,}\) and so \(|S| = |X+1|\text{.}\) But \(N(S)\subseteq X\text{,}\) so let \(b\in B\) be connected to a vertex \(s \in S\text{.}\) The edge \((s,a)\) must be in our matching or else \(s\) is adjacent to \(b\) by an alternating path that doesn't contain \(a\text{.}\) We can take that alternating path ending in \(B\) and extend it with \(b\text{,}\) yielding an augmenting path and therefore a contradiction. Hence \(b\) must be in \(X\text{,}\) and so \(|N(S)| \le |X| = |S| − 1\text{.}\) Therefore \(|N(S)| ≤ |S|\text{,}\) and \(G\) must have a perfect matching.
There are a couple other interesting proofs of Hall's Theorem that are worth considering. First, we can give a proof by induction.
Inductive Proof of Theorem 6.0.6.
For \(|A|=1\) the theorem holds. Assume that for \(|A| \ge 2\) there is a perfect matching if \(|N(S)| \ge |S|\) for all \(S \subseteq A\text{.}\)
If \(|N(S)| \ge |S| +1\) for all non-empty set \(S \subset A\) then pick an edge \(ab \in G\) and consider the graph \(G' = G - \{a,b\}\text{.}\) Then for every non-empty set \(S \subseteq A \setminus \{a\}\) we have that \(|N_{G'}(S)| \ge |N_G(S)|-1 \ge |S|\text{.}\) So by assumption \(G'\) contains a matching of \(A \setminus \{a\}\text{.}\) Adding in the edge \(ab\) produces a matching of \(A\) in \(G\text{.}\)
Now suppose there is some non-empty proper subset, \(A'\) where \(|N(A)| \not\ge |A| +1\text{.}\) By assumption \(|N(A)| \ge |A|\) so it must be that \(|N(A)| = |A|\text{.}\) Let \(B' = N(A')\text{.}\) By assumption \(G' = G[A' \cup B']\) contains a matching of \(A'\text{.}\) If we consider \(G - G'\) there cannot be any set \(S \subseteq A \setminus A'\) with \(|N_{G-G'}(S)| \lt |S|\) because that would mean \(|N_G(S \cup A')| \lt |S\cup A'|\text{.}\) So then by assumption \(G-G'\) contains a matching of \(A \setminus A'\text{.}\) Putting the two matching togethers produces a matching for \(A\) in \(G\text{.}\)
As a final proof, we consider again vertex covers. In light of Theorem 6.0.4, if we can prove that every graph satisfying the matching condition (\(|N(S)| \ge |S|\) for all \(S \subseteq A\)) has a minimum vertex cover of size \(|A|\text{,}\) we will have a proof of Theorem 6.0.6.
Proposition 6.0.7.
In any bipartite graph \(G= (A,B)\) that satisfies \(|N(S)| \ge |S|\) for all \(S \subseteq A\text{,}\) the size of a minimum vertex cover is \(|A|\text{.}\)
Proof.
Let \(G=(A,B,E)\) be a bipartite graph such that \(|N_{G} (S)|\geq |S|\) for all \(S\subseteq A\text{,}\) and assume for the sake of contradiction that the size of a minimum vertex cover is not \(|A|\text{.}\)
By Theorem 6.0.4, the size of such a minimum vertex cover is equal to the size of a maximum matching. But a maximum matching has size at most \(|A|\text{,}\) so we have that the size of a minimum vertex covering of \(G\text{,}\) call it \(U\text{,}\) is strictly less than the size of \(A\text{;}\) i.e., \(|U|\lt |A|\text{.}\)
Then for \(A'\subseteq A\text{,}\) \(B'\subseteq B\text{,}\) let \(U=A'+B'\text{.}\) Then we have that \(|A'|+|B'|=|U|\lt |A|\text{.}\)
Thus \(|B'|\lt |A|-|A'|=|A\backslash A'|\text{.}\) Let \(S=A\backslash A'\text{.}\)
Now \(U\) is a covering of the edges of \(G\text{,}\) so for any vertex \(v\in A\backslash A'\) there must be no an adjacent vertex \(b\in B\backslash B'\text{.}\) This implies that \(N_{G} (S)\leq |B'|\lt |S|\text{.}\)
But this violates the assumption that \(|N_{G} (S)|\geq |S|\) for all \(S\subseteq A\text{,}\) and we have a contradiction. Thus the size of a minimum vertex cover must be \(|A|\text{.}\)