## Graph Theory Lecture Notes15

### Finding a Maximal Matching

#### M-Augmenting Chains

Def: Given a matching M in a graph, a simple chain,
u1, e1, u2, e2, u3, e3, ..., ut, et, ut+1
is called M-alternating if the edges e2, e4, ... etc. are in M.

An M-alternating chain is an M-augmenting chain if the end vertices are not on any edge of M (i.e., are unsaturated).

If there is an M-augmenting chain in a graph, a larger matching can be obtained by "switching" the edges in this chain, i.e., remove from M the edges that are in the chain, and add to M the edges that are not in M. (There will be one more of these than the number you removed).

Theorem: A matching M in a graph is maximum if and only if the graph contains no M-augmenting chains.

Pf: Clearly, a matching M is not maximum if there is an M-augmenting chain. We will prove the theorem by showing that if M is not maximum then there is an M-augmenting chain in the graph.

Assume that there is a matching M' with |M'| > |M|. Let H be the subgraph consisting of all the vertices of the original graph and those edges that appear in either M or M' but not both. In H there are more M' edges than M edges by our assumption. Each vertex in H has degree at most 2 (in H), being on at most one edge of M and one edge of M'. The connected components of H are either circuits or simple chains, in which M and M' edges alternate. The circuits must have even length, and so, the same number of M and M' edges. Therefore, some component some component must be a simple chain with more M' edges than M edges, i.e., this component is an M-augmenting chain.

### Algorithm for Finding M-Augmenting Chains in Bipartite Graphs

Start with a matching M and an unsaturated vertex x. The algorithm produces either an M- augmenting chain starting at x, or the message that none exists.

There are four lists that are maintained throughout the algorithm; two lists of vertices called O and I (standing for outer and inner vertices respectively) and two lists of edges called T and T' (the T edges will form a tree). Initialize all lists to be empty, then put x in list O.

Step 1: Find an edge not in T or T' with initial vertex in O.
- if this can not be done, then exit with message that there are no augmenting chains.

Step 2: If {u,v} is the edge found in Step 1 with u in O, then
a) if v is in I, put the edge in T' and return to Step 1, otherwise put the edge in T.
b) if v is unsaturated, stop the edges in T contain a unique augmenting chain from x to v.
c) if v is saturated, with edge {v,w} in M, then put v in I, w in O, the edge {v,w} in T and return to Step 1.

Example: Consider this graph, having the indicated matching and unsaturated vertex 1. We start with O = {1}, I = {}, T = {}, T' = {}.

Find edge {1,4} in Step 1. Since vertex 4 is saturated by edge {4,5} we update our lists to:
O = {1, 5}, I = {4}, T = { {1,4}, {4,5} }, T' = {}. Find edge {1,2} in Step 1. Since vertex 2 is saturated by edge {2,3} we update our lists to: O = {1, 5, 3}, I = {4, 2}, T = { {1,4}, {4,5}, {1,2}, {2,3} }, T' = {}.

Find edge {3,4} in Step 1. Since vertex 4 is in I, we update our lists to:
O = {1, 5, 3}, I = {4, 2}, T = { {1,4}, {4,5}, {1,2}, {2,3} }, T' = {{3,4}}.

Find edge {3,6} in Step 1. Since vertex 6 is saturated by edge {6,7} we update our lists to:
O = {1, 5, 3, 7}, I = {4, 2, 6}, T = { {1,4}, {4,5}, {1,2}, {2,3}, {3,6}, {6,7}}, T' = {{3,4}}.

Find edge {7,4} in Step 1. Since vertex 4 is in I, we update our lists to:
O = {1, 5, 3, 7}, I = {4, 2, 6}, T = {{1,4}, {4,5}, {1,2}, {2,3}, {3,6}, {6,7}}, T' = {{3,4},{7,4}}.

Find edge {7,8} in Step 1. Since vertex 8 is unsaturated, we find the unique chain in T from 1 to 8.
T = {{1,4}, {4,5}, {1,2}, {2,3}, {3,6}, {6,7}, {7,8}},

which is {1,2}, {2,3}, {3,6}, {6,7}, {7,8} an M-augmenting chain from 1 to 8.

### Matching as Many Elements as Possible

In those cases where an X-saturating matching in a bipartite graph is impossible, we may want to know the size of a maximum matching. Lets call this number m(G).

If S is a subset of vertices of X, define the deficiency of S as d(S) = |S| - |N(S)|, and let the deficiency of G, d(G) be the maximum of the deficiencies of all the subsets of X. Then,

Theorem: If G is a bipartite graph, m(G) = |X| - d(G).