 Given a graph G, a matching M consists of a set of non-adjacent edges. The most common matching problems are related to bipartite graphs. In particular, given a bipartite graph with partite sets X and Y, can you find a set of non-adjacent edges that include every vertex in X? Some applications. Can you select a set of representatives from different groups so that every group has a representative and no one represents more than one group? This is the problem of finding a system of distinct representatives. Another possibility, can you match jobs to people so that every job is done by a different person? Or can you match women to men they would want to marry? Let's consider the jobs problem. Suppose a company has five jobs and eight employees. The table shows which jobs can be done by which employee. Can each job be assigned to a single person? So first, we'll draw a graph with the employees and the jobs representative's vertices and edges joining an employee who can do a job. We'll try to implement Kuhn's algorithm. We'll choose an edge, A-M. We find an M augmented path, B-M-M-A-N. So we switch edges. We can't include C in any M augmenting path. So we go on to the next. D has apparently no skills beyond convincing the company to hire them. But if we start at E, we find that E-N-N-A-M is not M augmenting. But E-N-N-A-P is, so we switch edges. F-O is an edge not in our matching, so we include it. However, we've run out of employees and these assignments leave Q undone. Now, since the actual assignments depend on the order we take the vertices, suppose we start with the lower set, Q-P-O-N-M, and apply Kuhn's algorithm, and we'll also take the opposite in reverse order. So we choose our first edge, Q-F, then P-E, then O-F, F-Q, Q-E, E-P, P-A is M augmenting. So we switch edges. If we start at N, we find, well, that's not M augmenting. We could try N still not M augmenting. And we try out other paths from N. And since no path from N is M augmenting, we go to the next vertex, M. Remember, we're looking at a depth for a search, so if we don't succeed, we just go on to the next thing. So if we start at vertex M and look for an M augmenting path, we find, but so MC is M augmenting because it augments the empty set, and so we include it, but now job N isn't getting done. So here's the thing to consider. Either we're not clever enough to find a matching or a matching doesn't exist. So we could spend more time trying to find a matching or we could find a reason why a matching is impossible to find. We'll note one important thing. Strictly speaking, since our algorithm finds maximal matchings, the fact that we couldn't find one that matched all jobs to a person guarantees it can't be done, but it doesn't tell us how to fix the problem. Now if we look closely at the jobs, we note that this job, nail binding, ordering, printing, and queuing can only be done by three employees. Since there are fewer people than jobs, it's not possible for each job to be assigned to one person and so the company should probably hire some additional staff. To proceed, let's introduce sub notation and terminology. Let S be a subset of vertices of some graph G. The neighborhood of S and G designated this way is the set of vertices adjacent to a vertex in S. So in the graph shown, let's find the neighborhood in G of the vertex at A, B, E. We see that vertex is adjacent to vertices M and Q. Vertex B is adjacent to M and E. Vertex E is adjacent to. And so our neighborhood is the set of adjacent vertices and since it is a set, we don't list repeated elements more than once. Now the observation that there were four jobs that could only be done by three people is equivalent to noting that the neighborhood of the vertices N, O, P, and Q is the vertex at A, E, and F. And informally, we had too few people for the number of jobs. Formally, we had a subset S where the neighborhood of S was smaller than S itself. And this is the first part of one of the most important theorems in discrete mathematics and graph theory, which is known as Hall's theorem. Suppose G is a bipartite graph with partite sets X and Y. If there exists a subset S where the neighborhood of S is smaller than S itself, then no matching saturates X. So let's prove that. Suppose we have some subset S of X where the neighborhood of S is smaller than S itself. A matching must consist of non-adjacent edges. Now the edges in any matching of G must connect the vertex of S to a vertex of the neighborhood of S because these are the only vertices that are going to be adjacent. But since the neighborhood of S is smaller than S, then at least one vertex in S cannot be saturated in a matching. And that's because, well, I'm sure there's a good reason for it. And so no matching can saturate X. Now at this point it's worth remembering consider the converse. If the existence of a subset whose neighborhood is smaller than the set guarantees that no matching is possible, might having the neighborhood be larger than the set true for all subsets guarantee that matching is possible. Perhaps. Well, yes, but let's not spoil the suspense. We'll take a look at that next.