Bipartite matchings and Hall's theorem
Translate distinct assignments into matchings, detect collective shortages, and improve a matching with alternating paths.
On this page
The question for today
What you’ll understand
- Model a distinct assignment as a bipartite matching.
- Use Hall's condition to certify or obstruct saturation of one side.
- Trace an augmenting path and distinguish maximal from maximum matchings.
Suppose each student lists acceptable project slots, and each slot can take one student. Giving every student at least one option is insufficient: several students might depend on the same small set of slots. A bipartite graph captures eligibility, and Hall's theorem identifies exactly which collective shortages prevent a complete assignment. The lesson concerns feasible distinct assignments, without preferences or a stability requirement.
Edges as possible assignments
A bipartite graph has disjoint vertex classes and , with every edge joining one class to the other. A matching is a set of edges with no shared endpoints. It saturates if every vertex of belongs to a selected edge. Saturation need not cover all of when the classes have different sizes. A perfect matching covers both classes. These distinctions matter in applications with more available slots than applicants.
For a subset , let be the union of all its neighbors in . If a matching saturates , its edges must send the distinct vertices of to distinct members of . Hence for every such subset. Checking only individual vertices misses bottlenecks: three applicants may each have two choices while all three share the same two slots. The failure is visible only after grouping the competing applicants.
The shortage condition is also sufficient
Hall's theorem states that a finite bipartite graph has a matching saturating if and only if this neighbor inequality holds for every subset of . Necessity is the assignment count just given. For the sufficiency idea, choose a maximum matching and suppose some left vertex is unmatched. Search from it by alternating unmatched edges from left to right and matched edges from right to left. If an unmatched right vertex is reached, flipping the path increases the matching, contradicting maximum size.
If no unmatched right vertex is reached, let be the reached left vertices and the reached right vertices. Every neighbor of lies in : nonmatching edges are explored, and the matching partner of a reached matched left vertex was already reached. Every vertex in is matched back into , while the starting left vertex is unmatched. Thus , contradicting Hall because . This argument proves sufficiency and explains how a failed search produces a concrete shortage certificate.
Improve by rearranging earlier choices
An augmenting path begins and ends at unmatched vertices and alternates between edges outside and inside the current matching. Flipping membership along it adds one more unmatched edge than it removes, increasing the matching size by one while preserving the endpoint constraint. An early choice need not be permanent: a chain of reassigned slots can free a desirable slot for a previously unmatched applicant. A greedy procedure that never revisits choices can stop too soon.
A maximal matching cannot be enlarged by simply adding one edge, but a maximum matching has the greatest possible size among all matchings. The first is a local property and the second is global. In a three-edge path, selecting the middle edge is maximal, yet the two outside edges form a larger matching. Hall's theorem is an existence criterion; augmenting paths provide a constructive improvement mechanism. When eligibility has capacities or weights, those must be added to the model rather than silently changing the meaning of a matching.
Work it through
Undo a locally reasonable assignment
Let and , with , , and . Start with matching . Can every left vertex be assigned?
The unmatched applicant b can use slot 1, currently assigned to a. Applicant a can move to slot 2, currently assigned to c, and c can move to the free slot 3.
This is the alternating path b–1–a–2–c–3. Its first, third, and fifth edges are outside M, while its second and fourth are in M. Flip all five memberships.
The new matching is {b1,a2,c3}, with three distinct left and right endpoints. It saturates L and is perfect because the classes both have size three. This explicit assignment also confirms that every Hall inequality holds, without enumerating all eight subsets.
A length-five augmenting path changes two earlier choices and increases the matching size from two to three.
The living notebook
Explore the model
Interactive lab · modular
A visible collective shortage
Pause and Reset, then set m = 6 and a = 2. Predict the reachable options from zero are only {0,2,4}; Step three times to verify. Imagine four applicants whose entire allowed-slot set is these three residues: Hall fails for that four-applicant group. Reset and set both m = 6 and a = 1 to compare six available orbit labels. The orbit is an eligibility-set illustration, not a matching solver.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA group cannot receive distinct assignments from fewer available slots than members, even if every individual has options.
Pause & reason
Check your understanding
Your turn
Try it yourself
Let and . Give a matching saturating . Then remove edge and identify an exact Hall obstruction.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
First reserve slot 3 for the only applicant who can use it. After deleting that option, examine the neighborhood of the entire left class.
Compare with the solution
The edges a1,b2,c3 form a perfect matching in the original graph. After removing c3, every left vertex has neighbors only in {1,2}; the subset {a,b,c} has size three but neighborhood size two. Hall's condition therefore fails, so no matching saturates all three. A matching of size two still exists, for example a1,b2. The obstruction certifies the maximum size is two because only two right vertices have any eligible incident edge.
Keep the idea
Take it with you
- Hall's condition checks every group of competing left vertices.
- An augmenting path can improve a matching by rearranging earlier choices.
- Maximal means no single edge can be added; maximum means no larger matching exists.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.