Matchings
Definition 1.
- A matching is a subset of edges of a graph such that there is no vertex that is adjacent to two different edges in .
- Given a matching in a vertex is free/open/unmatched if no edge in is incident to . Otherwise it is called covered/closed/matched.
- A matching in such that every vertex is matched is called a perfect matching.
For a perfect matching to exist, the graph must have an even number of vertices.
Definition 2.
- A maximum matching covers the largest possible number of vertices.
- A matching is called a maximal matching if it is no longer a matching after the addition of any edge.
Perfect matchings in bipartite graphs
Hall’s condition is an easy to verify necessary condition for the existence of a perfect matching in a bipartite graph. A bipartite graph with bipartition satisfies Hall’s condition if for every , , where is the neighborhood of .
Interestingly, it also happens to be a sufficient condition.
Theorem 3(Hall's Theorem).
There exists a perfect matching exhausting in a bipartite graph iff for every subset , .
When the sets of the bipartition have the same size, Hall’s Theorem is called Hall’s Marriage Theorem.
Proof of
We induct on . The implication trivially holds for . For , choose an arbitrary vertex . Since , there exists a neighbor of in , which we’ll call .
Corollary
For , every -regular bipartite graph has a perfect matching.
Counting perfect matchings in bipartite graphs
A bipartite graph is called balanced if .
Definition 4.
The Edmonds matrix of a balanced bipartite graph with sets of vertices and is defined by
where are indeterminates.
A bipartite graph admits a perfect matching iff the polynomial in the s is not identically zero.
There is a natural correspondence between perfect matchings and permutations. Each permutation represents a possible matching . The realizability of this matching depends on whether has the edges it requires (that is, is nonzero for all ): If yes, the monomial corresponding to will survive, and if not, it will vanish. Therefore, the number of perfect matchings in equal to the number of monomials in the polynomial .
One way to compute the number of monomials in is to use what’s called the permanent:
Definition 5.
The permanent of a matrix , denoted , is defined similarly to the determinant but without the sign alternation.
The number of monomials in and are the same, but allows us to count them by simply substituting every .
The downside of the permanent is that it is incredibly expensive to compute. For matrices, the permanent can be expressed as a determinant like so:
However, for and larger matrices, a permanent cannot be expressed as a determinant (prove this!). The best known deterministic algorithm to calculate the permanent (Ryser’s formula) takes steps (reduced from by PIE).
As stated before, if we only wish to know whether a perfect matching exists or not, it suffices to compute the determinant of the Edmonds matrix and check if it is identically zero. In order to avoid symbolic computation (which is expensive), one may ask: is it possible to substitute numerical values into in the Edmonds matrix and construe any useful information from the resulting determinant? It turns out that this works with high probability. The key tool that enables this is the Schwartz–Zippel Lemma, which gives a probabilistic bound on when a multivariate polynomial evaluates to zero.
Theorem 6(Schwartz–Zippel Lemma).
Let be a non-zero polynomial of total degree at most over a field , and let be a finite subset. Then:
In practice, is taken to be a sufficiently large finite field (finite fields are ideal for randomized algorithms because arithmetic over them is well-defined, exact (no floating point issues), and operations can be implemented efficiently). This also allows us to take to be the entire field and sample freely.
So, to test if a perfect matching exists, you
- choose a large finite field , typically with prime ;
- assign each variable a random value (say, uniformly from );
- evaluate .
If the result is nonzero, then a perfect matching definitely exists. If the result is zero, there’s a small chance you hit a root; repeat with new random values to reduce error probability.
The Tutte matrix generalizes the Edmonds matrix to arbitrary (not necessarily bipartite) graphs.