Statement

Hall’s marriage theorem gives a necessary and sufficient condition for whether a bipartite graph has a perfect matching: for every 𝑆𝐿, if 𝑇 is the neighborhood of 𝑆 in 𝑅, then |𝑆| must be |𝑇|. Here, the neighborhood of 𝑆 refers to the set of all nodes in 𝑅 that are connected directly to a node in 𝑆.

bg-white

An 𝑋-perfect matching. We can verify Hall’s condition on, for instance, 𝑆={1,2,3}, whose neighborhood is the first four nodes in 𝑌. |𝑆|=3<4, therefore the condition is satisfied.

Proof 1 (Flows)

If there exists |𝑆| with |𝑆|>|𝑇|, then a perfect matching is obviously impossible. It remains to prove sufficiency, which can also be done fairly easily by the max-flow min-cut theorem (for more, see flow).

Set up the following flow network:

  • Connect the source node with edges of capacity 1 to every node in 𝑋.
  • Direct every edge between 𝑋 and 𝑌 toward 𝑌 with capacity .
  • Connect every node in 𝑌 to the sink with edges of capacity 1.

Clearly, a flow in this network corresponds to a matching on the original bipartite graph. Now, consider any cut in this flow network with finite capacity. Let 𝑆 be the set of nodes in 𝑋 which are still connected to the source. Then, the smallest set 𝑇 we can cut on the right side is exactly the neighborhood of 𝑆. The size of the resultant cut is then (|𝑋||𝑆|)+|𝑇|, but since we have |𝑆||𝑇| for all |𝑆|, this quantity must then be |𝑋| for all possible cuts, and thus the min-cut is exactly |𝑋| with equality achieved when 𝑆=. Therefore, an |𝑋|-flow must exist.

Proof 2 (Constructive)

We induct, and consider 2 cases.

Case 1: For every 𝑆 with |𝑆|<|𝐿| and its neighborhood 𝑇, |𝑆|<|𝑇|. In this case, we can just pair any two connected nodes 𝑢 and 𝑣, as this decreases the RHS of the above inequality by at most 1 for all 𝑆.

Case 2: There exists 𝑆 with |𝑆|<|𝐿| and |𝑆|=|𝑇|. By induction, we can perfectly match 𝑆 to 𝑇. Every remaining subset will still satisfy Hall’s condition because |𝑆| is subtracted from the LHS and at most |𝑇|=|𝑆| is subtracted from the RHS.

Takeaways

I think this theorem is quite beautiful as it essentially just compounds necessary conditions until their sum ends up being sufficient. What I mean is this:

When you see the problem, you’ll likely observe that trivially, |𝑋| must be |𝑌|, which is certainly necessary but definitely not sufficient. But then you simply apply this condition to all subsets of 𝑋, and that turns out to be sufficient! Isn’t that elegant?

Problems

There are 2𝑛 candies, each with a potentially different color. Determine whether it’s possible to split them into 𝑛 pairs such that no pair contains two candies of the same color.

The next few problems are from https://cjquines.com/files/halls.pdf. Also in solutions, 𝑁(𝑊) will denote the neighborhood of 𝑊.