Suppose a small company has four applicants and four jobs. Each applicant is qualified for some of the jobs, not all of them. Can you hand out the jobs so that every applicant gets exactly one job they are qualified for, and no job goes to two people? That single, deceptively practical question — assign everyone at once, with no clashes — is the whole of this page.
Draw applicants as dots on the left and jobs as dots on the right, and connect an applicant to a job when they are qualified for it. This is a bipartite graph: its vertices split into two sides, and every edge crosses from left to right. A valid assignment is a special set of edges, and it has a name.
A matching is a set of edges, no two of which share a vertex. Picture it as pairing up: each edge you pick "uses up" both of its endpoints, so once an applicant is matched to a job, neither of them can appear in any other chosen edge. A vertex that an edge of the matching touches is saturated (matched); one left over is unmatched.
Often we only care about one side. A matching saturates
On the left are three applicants
The highlighted edges are
When can we guarantee that everyone on the left gets matched? The delightful answer, found by Philip Hall in 1935, is a condition you can state in one line. Think of the left side as people and the right side as potential partners: an edge means "these two would be happy together". We want to marry everyone off — hence the nickname.
For a set
A bipartite graph with parts
Hall's condition is easy to violate. Here two applicants,
This is the pattern to hunt for: a group on the left whose combined list of options is smaller than the group itself. Find one such starved subset and you have proved no full matching can exist — a single counterexample settles it.
Hall's theorem tells you whether a matching exists; it does not hand you one. The algorithm that does is built on augmenting paths. Start with any matching (even the empty one). An augmenting path starts at an unmatched left vertex and zig-zags unmatched, matched, unmatched, … edges, ending at an unmatched right vertex.
The trick: flip every edge along that path — matched edges become unmatched and vice-versa. The path has one more unmatched edge than matched, so flipping grows the matching by exactly one. Keep finding augmenting paths until none remains; Berge's theorem promises that when you get stuck, your matching is maximum. This is the engine inside the classic Hopcroft–Karp assignment algorithm.
On bipartite graphs, matchings have a beautiful dual. A vertex cover is a set of vertices touching every edge. König's theorem says the size of a maximum matching equals the size of a minimum vertex cover. So the largest set of clash-free pairings and the smallest set of "watchdog" vertices are always the same number — and Hall's theorem drops out as a corollary. It is one of those places where two questions that sound unrelated turn out to be the same question wearing different hats.
Hall's theorem asks only whether a full matching exists. A richer question: suppose each person ranks the people on the other side. A matching is stable if no two people would both rather be with each other than with their assigned partners (such a pair would elope and wreck the matching). Astonishingly, a stable matching always exists, and the Gale–Shapley algorithm (1962) finds one by rounds of proposals and provisional acceptances.
This is not a toy: variants of Gale–Shapley assign medical graduates to hospitals and pupils to schools worldwide, and the idea won Roth and Shapley the 2012 Nobel Prize in Economics. Matchings pay rent.
"There are plenty of edges, so a perfect matching must exist." Tempting, and wrong. Sheer quantity of edges guarantees nothing — what matters is where they go. A graph can be dense with connections and still fail, because one starved subset is enough to block everything.
Imagine 100 applicants and 100 jobs, wired up with thousands of edges — but with two applicants who are both qualified for only the same single job. That subset of size 2 has neighbourhood of size 1, Hall's condition fails, and no perfect matching exists, no matter how many other edges you pile on. It is the subset / neighbourhood condition, checked over every subset, that decides it — never the total edge count.