 Suppose G is a bar-paratite graph with partite sets X and Y. Is it possible to select a set of edges E where every vertex in X is connected to exactly one vertex in Y? This is sometimes called the marriage problem after an archaic practice which still exists in backwards parts of the world where men can only marry females. Civilized places allow marriage between any two individuals provided both are consenting adults, so we might talk about the jobs problem. Let X be a set of jobs and Y a set of people where an edge joins a job to a person who can do it. Can we find a set of edges where each job is done by a specific person? Since renaming the problem risks being accused of empathy and consideration for others and we don't want to be accused of that, we'll refer to this as the matching problem. To state the problem formally, we'll introduce some terminology. Given a graph G, a matching M is a set of non-adjacent edges, in other words, edges that don't have a common vertex. Given any edge U, V in M, we say that U and V are matched in M. We say that M is a maximum matching if the cardinality is greater than or equal to the cardinality of any other matching. In other words, we have at least as many edges as any other matching we could find. If V is an endpoint of an edge in M, we say that M saturates V. And likewise, if all V and some set are saturated by M, we'll say that M saturates the set. And if M saturates all vertices in our graph, then M is a perfect matching. So let's find a matching in the graph shown. For our matching, we have to select non-adjacent edges, edges that don't connect to each other, in other words. One approach, we might select an edge, and then, since we can't select an adjacent edge, we'll delete all edges incident on the same vertices, then lather, rinse, repeat. So let's select, oh, how about this edge? This edge joins up to another edge, which we can't select, so we'll delete it. And we've changed the color of the selected edge to blue, so we know we've already selected it. We'll pick another edge, how about this one, delete all the connected edges, and lather, rinse, repeat, which gives us a matching even though it's not a perfect one. Remember, a useful idea in math, and while crossing the street, is to look both ways. So let's consider, a path is a sequence of connected edges with distinct vertices. So in some sense, a matching is the exact opposite of a path since none of the edges are connected. Or, every path creates several matchings, which we can produce by selecting non-consecutive edges in our path. And let's consider, in the sub-graph consisting of the path only, there are two perfect matchings formed by alternating the edges. If a path has an odd number of edges, then one of these will be the longer. And this leads to an important idea, let m be a matching in a graph. A m-augmented path alternates between the edges in m and the edges in the rest of the graph, where the first and last vertices are not saturated by m. It's worth pointing out that the m-augmented path does not actually need to include all of the edges in m, it could just include a few of them. The existence of m-augmented paths suggests a solution to the jobs problem. Match people to jobs any way you want to get a matching, and if your matching is m-augmented, switch the edges around. For example, here we have a graphing, let's try to find a larger matching, and our goal is we want to find a path that includes the edges in our matching. So with a little effort, we find... Here the important idea is that our new path in some sense starts before and ends after the current matching, and once we have this m-augmented path, we can switch the edges. In other words, we use the alternate edges as our new matching. Now, what we did presuppose is we can find an m-augmented path that includes all of our edges, but remember the m-augmented path doesn't have to include all the edges, so what if we can't? Well, let's try it and find out. So we have a matching. Let's consider any single edge, how about this one? We can certainly expand the matching. And in this case, we happen to not connect with any of the other edges in our current matching. And so notice that if we swap out our original edge for the new edges, we get a larger matching. And allow the rinse repeat, and as long as we can find m-augmented paths, we can keep increasing the size of our matching. While this is a way we could solve the jobs problem, it's not actually an algorithm since we can't guarantee it solves the problem. Even more important, find a path that includes the matching is a little too vague as an instruction. We sometimes call such approaches heuristics. Heuristics are the antithesis of what computers can do, but they're exactly what humans are good at, and they're a strategy for finding a proof. So in the next lecture, we'll talk about an important result called Berger's theorem about maximal matchings.