Couples dancing at a square dance in McIntosh County, Oklahoma, photographed on colour film in 1939 or 1940
Unit 05 · All masterclasses · 75 min

Matchings and Bipartite Graphs

Hall's theorem, Kőnig's theorem, and the stable matchings of Gale and Shapley
Image: Russell Lee, Farm Security Administration, Library of Congress

Matchings, augmenting paths, and Berge's theorem that a matching is maximum exactly when no augmenting path exists. Hall's marriage theorem and Kőnig's theorem for bipartite graphs with their proofs, the Hungarian method, and the theorems of Tutte and Petersen for general graphs. The unit ends with stable matchings: the Gale and Shapley procedure and the markets built on it, from hospital residencies to kidney exchange.

Preview: the beginning of the unit

Five applicants, five vacant posts, and for each applicant a list of the posts they would accept: can everyone be placed? Four young doctors and four hospitals, each with a ranking of the other side: is there an assignment that no doctor and no hospital would want to leave? Both questions ask for a set of edges that pair off the vertices of a graph, and both have complete answers: Hall’s theorem of 1935 answers the first question and the procedure of Gale and Shapley of 1962 the second. Between them lies the idea of an augmenting path, which turns every question about the largest possible pairing into something a computer, or a patient reader with a pencil, can settle. The same mathematics places medical graduates in hospitals every spring and arranges kidney transplants between strangers.

1 Matchings and augmenting paths

A matching in a graph \(G\) is a set \(M\) of edges of which no two share a vertex. A vertex that is an end of an edge of \(M\) is matched by \(M\), and the two ends of a matching edge are each other’s partners; a vertex that lies on no edge of \(M\) is unmatched. Three degrees of quality of a matching are distinguished, and the difference between the first two is easy to overlook. A matching is maximal when no edge of \(G\) can be added to it without breaking the rule, it is maximum when no matching of \(G\) has more edges, and it is perfect when every vertex of \(G\) is matched. The number of edges of a maximum matching is the matching number \(\nu(G)\), written with the Greek letter nu. A perfect matching has \(n/2\) edges, where \(n\) is the number of vertices of \(G\) as in the earlier units, so a graph with an odd number of vertices has none, and a graph has a perfect matching exactly when \(\nu(G) = n/2\).

Maximal and maximum are not the same thing. In the path \(P_4\) on the four vertices \(1, 2, 3, 4\) in a row, which has three edges, the matching that consists of the middle edge \(23\) alone is maximal, because both remaining edges touch it, but the matching \(\{12, 34\}\) has two edges, so \(\nu(P_4) = 2\). A maximal matching is what a greedy procedure produces when it adds edges until it is stuck; a maximum matching is what one actually wants.

Figure 1(a) shows the graph that serves this unit as its running example, a bipartite graph with the parts \(X = \{a, b, c, d, e\}\) and \(Y = \{1, 2, 3, 4, 5\}\) and the nine edges \(a3\), \(a5\), \(b2\), \(b3\), \(c1\), \(c4\), \(c5\), \(d3\), and \(e5\). Unit 2 defined bipartite graphs and showed how to recognize them; here the two parts are drawn as two rows, and the reader is invited to copy the graph, since every argument of Sections 1 to 3 is carried out on it. The three thick edges \(a3\), \(b2\), and \(c5\) form a matching \(M_0\), and \(M_0\) is maximal: the vertex \(d\) has the single neighbour \(3\) and the vertex \(e\) has the single neighbour \(5\), both of which are already matched, and every other edge touches a matched vertex as well. Yet \(M_0\) is not maximum, as panel (b) shows, and the way from (a) to (b) is the central idea of the unit.

The full unit is part of the program

Want to see a complete unit first? Unit 3, Euler Tours and Hamilton Cycles, is free to read.