# Gallai–Edmonds decomposition

In graph theory, the Gallai–Edmonds decomposition is a partition of the vertices of a graph into three subsets which provides information on the structure of maximum matchings in the graph. Tibor Gallai and Jack Edmonds independently discovered it and proved its key properties.
The Gallai–Edmonds decomposition of a graph can be found using the blossom algorithm.

## Properties

Given a graph $G$, its Gallai–Edmonds decomposition consists of three disjoint sets of vertices, $A(G)$, $C(G)$, and $D(G)$, whose union is $V(G)$: the set of all vertices of $G$. First, the vertices of $G$ are divided into essential vertices (vertices which are covered by every maximum matching in $G$) and inessential vertices (vertices which are left uncovered by at least one maximum matching in $G$). The set $D(G)$ is defined to contain all the inessential vertices. Essential vertices are split into $A(G)$ and $C(G)$: the set $A(G)$ is defined to contain all essential vertices adjacent to at least one vertex of $D(G)$, and $C(G)$ is defined to contain all essential vertices not adjacent to any vertices of $D(G)$.
It is common to identify the sets $A(G)$, $C(G)$, and $D(G)$ with the subgraphs induced by those sets. For example, we say "the components of $D(G)$" to mean the connected components of the subgraph induced by $D(G)$.
The Gallai–Edmonds decomposition has the following properties:
* The components of $D(G)$ are factor-critical graphs: each component has an odd number of vertices, and when any one of these vertices is left out, there is a perfect matching of the remaining vertices. In particular, each component has a near-perfect matching: a matching that covers all but one of the vertices.
* The subgraph induced by $C(G)$ has a perfect matching.
* Every non-empty subset $X\subseteq A(G)$ has neighbors in at least $|X|+1$ components of $D(G)$.
* Every maximum matching in $G$ has the following structure: it consists of a near-perfect matching of each component of $D(G)$, a perfect matching of $C(G)$, and edges from all vertices in $A(G)$ to distinct components of $D(G)$.
* If $D(G)$ has $k$ components, then the number of edges in any maximum matching in $G$ is ${\frac {1}{2}}(|V(G)|-k+|A(G)|)$.

## Construction

The Gallai–Edmonds decomposition of a graph $G$ can be found, somewhat inefficiently, by starting with any algorithm for finding a maximum matching. From the definition, a vertex $v$ is in $D(G)$ if and only if $G-v$ (the graph obtained from $G$ by deleting $v$) has a maximum matching of the same size as $G$. Therefore we can identify $D(G)$ by computing a maximum matching in $G$ and in $G-v$ for every vertex $v$. The complement of $D(G)$ can be partitioned into $A(G)$ and $C(G)$ directly from the definition.
One particular method for finding a maximum matching in a graph is Edmonds' blossom algorithm, and the processing done by this algorithm enables us to find the Gallai–Edmonds decomposition directly.
To find a maximum matching in a graph $G$, the blossom algorithm starts with a small matching and goes through multiple iterations in which it increases the size of the matching by one edge. We can find the Gallai–Edmonds decomposition from the blossom algorithm's work in the last iteration: the work done when it has a maximum matching $M$, which it fails to make any larger.
In every iteration, the blossom algorithm passes from $G$ to smaller graphs by contracting subgraphs called "blossoms" to single vertices. When this is done in the last iteration, the blossoms have a special property:
* All vertices of a blossom are inessential vertices of the bigger graph.
* The vertex formed by contracting the blossom is an inessential vertex of the smaller graph.
The first property follows from the algorithm: every vertex of a blossom is the endpoint of an alternating path that starts at a vertex uncovered by the matching. The second property follows from the first by the lemma below:
    Let $G$ be a graph, $M$ a matching in $G$, and let $Z$ be a cycle of length $2k+1$which contains $k$ edges of $M$ and is vertex-disjoint from the rest of $M$. Construct a new graph $G'$ from $G$ by shrinking $Z$ to a single vertex. Then $M'=M-E(Z)$ is a maximum matching in $G'$ if and only if $M$ is a maximum matching in $G$.
This lemma also implies that when a blossom is contracted, the set of inessential vertices outside the blossom remains the same.
Once every blossom has been contracted by the algorithm, the result is a smaller graph $G'$, a maximum matching $M'$ in $G'$ of the same size as $M$, and an alternating forest $F'$ in $G'$ with respect to $M'$. In $G'$, the Gallai–Edmonds decomposition has a short description. The vertices in $F'$ are classified into inner vertices (vertices at an odd distance in $F'$ from a root) and outer vertices (vertices at an even distance in $F'$ from a root); $A(G')$ is exactly the set of inner vertices, and $D(G')$ is exactly the set of outer vertices. Vertices of $G'$ that are not in $F'$ form $C(G')$.
Contracting blossoms preserves the set of inessential vertices; therefore $D(G)$ can be found from $D(G')$ by taking all vertices of $G$ which were contracted as part of a blossom, as well as all vertices in $D(G')$. The vertices in $A(G)$ and $C(G)$ are never contracted; $A(G)=A(G')$ and $C(G)=C(G')$.

## Generalizations

The Gallai–Edmonds decomposition is a generalization of Dulmage–Mendelsohn decomposition from bipartite graphs to general graphs.
An extension of the Gallai–Edmonds decomposition theorem to multi-edge matchings is given in Katarzyna Paluch's "Capacitated Rank-Maximal Matchings".