core25 min studyLesson 216 in Mathematics

Bipartite matchings and Hall's theorem

Translate distinct assignments into matchings, detect collective shortages, and improve a matching with alternating paths.

On this page

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 LL and RR, with every edge joining one class to the other. A matching is a set of edges with no shared endpoints. It saturates LL if every vertex of LL belongs to a selected edge. Saturation need not cover all of RR 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 S⊆LS\subseteq L, let N(S)N(S) be the union of all its neighbors in RR. If a matching saturates LL, its edges must send the distinct vertices of SS to distinct members of N(S)N(S). Hence ∣N(S)∣≥∣S∣|N(S)|\ge|S| 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.

N(S)={r∈R:∃ℓ∈S with ℓr∈E},∣N(S)∣≥∣S∣(S⊆L)N(S)=\{r\in R:\exists\ell\in S\text{ with }\ell r\in E\},\qquad |N(S)|\ge|S|\quad(S\subseteq L)
Hall's condition demands enough distinct right-side options for every left-side group, including the whole class.↔ Scroll wide equations horizontally.

The shortage condition is also sufficient

Hall's theorem states that a finite bipartite graph has a matching saturating LL if and only if this neighbor inequality holds for every subset of LL. 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 SS be the reached left vertices and TT the reached right vertices. Every neighbor of SS lies in TT: nonmatching edges are explored, and the matching partner of a reached matched left vertex was already reached. Every vertex in TT is matched back into SS, while the starting left vertex is unmatched. Thus ∣T∣=∣S∣−1|T|=|S|-1, contradicting Hall because T=N(S)T=N(S). This argument proves sufficiency and explains how a failed search produces a concrete shortage certificate.

∃ a matching saturating L⟺∀S⊆L, ∣N(S)∣≥∣S∣\exists\text{ a matching saturating }L\quad\Longleftrightarrow\quad\forall S\subseteq L,\ |N(S)|\ge|S|
Hall's theorem concerns finite bipartite graphs and saturation of the specified left class, not stable matching.↔ Scroll wide equations horizontally.

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.

Undo a locally reasonable assignment

Let L={a,b,c}L=\{a,b,c\} and R={1,2,3}R=\{1,2,3\}, with N(a)={1,2}N(a)=\{1,2\}, N(b)={1}N(b)=\{1\}, and N(c)={2,3}N(c)=\{2,3\}. Start with matching M={a1,c2}M=\{a1,c2\}. Can every left vertex be assigned?

  1. 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.

  2. 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.

  3. 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.

The result

A length-five augmenting path changes two earlier choices and increases the matching size from two to three.

Explore the model

Interactive lab

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.

A visible collective shortageAddition 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. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

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.

Check your understanding

Three left vertices each have at least two neighbors, but their combined neighbor set has size two. Which conclusion follows?

Try it yourself

Let N(a)=N(b)={1,2}N(a)=N(b)=\{1,2\} and N(c)={2,3}N(c)=\{2,3\}. Give a matching saturating {a,b,c}\{a,b,c\}. Then remove edge c3c3 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.

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.