Perfect Matching — Definition, Formula & Examples
A perfect matching is a set of edges in a graph such that every vertex is included in exactly one edge. In other words, every vertex is paired with exactly one neighbor, with no vertex left unmatched.
Given a graph , a perfect matching is a set of pairwise non-adjacent edges (no two edges share a vertex) such that every vertex is an endpoint of exactly one edge in . A necessary condition is that is even. For bipartite graphs, Hall's marriage theorem gives a necessary and sufficient condition for the existence of a perfect matching.
Key Formula
Where:
- = The perfect matching — the set of selected edges
- = The total number of vertices in the graph (must be even)
How It Works
To find a perfect matching, you need to select edges so that each vertex appears in exactly one selected edge. Start by checking whether the graph has an even number of vertices — if it does not, no perfect matching can exist. For bipartite graphs with , Hall's theorem states a perfect matching exists if and only if for every subset , the neighborhood satisfies . Algorithms such as the Hopcroft–Karp algorithm efficiently find perfect matchings in bipartite graphs, while Edmonds' blossom algorithm handles general graphs.
Worked Example
Problem: Determine whether the complete bipartite graph (with vertex sets and ) has a perfect matching, and if so, find one.
Step 1: Check that the total number of vertices is even.
Step 2: Verify Hall's condition. In , every vertex in is adjacent to all three vertices in , so for any subset , the neighborhood whenever . Thus for all .
Step 3: Construct a perfect matching by pairing each vertex in with a distinct vertex in .
Step 4: Confirm: , every vertex appears exactly once, and no two edges share a vertex.
Answer: Yes, has a perfect matching. One example is .
Another Example
Problem: Does the cycle graph (a 5-vertex cycle) have a perfect matching?
Step 1: Count the vertices in .
Step 2: A perfect matching requires , which must be an integer. Since , this is impossible.
Answer: No. cannot have a perfect matching because it has an odd number of vertices.
Why It Matters
Perfect matchings appear throughout combinatorics courses and algorithms classes when studying assignment problems, scheduling, and network flows. In operations research, assigning workers to tasks at minimum cost reduces to finding a minimum-weight perfect matching. They also underpin results in chemistry (Kekulé structures of molecules) and computer science (stable marriage algorithms).
Common Mistakes
Mistake: Forgetting that the graph must have an even number of vertices for a perfect matching to exist.
Correction: Always check first. If is odd, you can immediately conclude no perfect matching exists.
Mistake: Confusing a maximum matching with a perfect matching.
Correction: A maximum matching is the largest matching possible in the graph, but it may still leave some vertices unmatched. A perfect matching leaves zero vertices unmatched. A perfect matching is maximum, but a maximum matching is not necessarily perfect.
