Maximum Cardinality -Matching in Time
Abstract
We present an algorithm that finds a maximum cardinality -matching of a simple graph in time . Here is a given function, and an -matching is a subgraph wherein each vertex has degree . This result generalizes a string of algorithms, concentrating on simple bipartite graphs. The bipartite case is based on the notion of level graph, introduced by Dinic for network flow. For general graphs the “level” of a vertex is unclear: A given vertex can occur on many different levels in augmenting trails. In fact there does not seem to be a unique level graph, our notion of level graph depends on the trails being analyzed. Our analysis presents new properties of blossoms of shortest augmenting trails.
Our algorithm, unmodified, is also efficient on multigraphs, achieving time , for .
1 Introduction
The method of shortest augmenting paths leads to many fundamental algorithms for graphs and networks. Dinic [4] as well as Edmonds and Karp [9] introduced the method for maximum network flow. Its use for matching and small networks was given by Hopcroft and Karp [16], Karzanov [18, 19], and Even and Tarjan [10]. These papers show that a maximum cardinality -matching on a bipartite graph can be found in time
(1.1) |
(For definitions of -matching and other terms please see the Terminology section below.) These bounds extend to problems with edge weights via cost-scaling, in work by Gabow and Tarjan [15] (the time increases by a logarithmic factor for scaling).111The above bound are the best known for combinatorial algorithms. Chen and Kyng et.al. [3] use interior point methods to achieve time with high probability, even for the general problem of maximum flow in arbitrary networks.
Extending these results from bipartite to general graphs is a big jump, because of complications caused by blossoms, introduced by Edmonds [7] in the first efficient general graph matching algorithm. For general graphs with , i.e., ordinary matching, Micali and Vazirani [21, 24, 25] use the shortest-augmenting-path method to achieve time . Huang and Pettie [17] achieve time for general multigraphs (using scaling).
All of the above cited algorithms find shortest augmenting paths using the natural, breadth-first-search notion of a level graph ([23, pp. 153-155], [20, p.166], [2, called the “layered network”, Section 7.5]).
The main contribution of this paper is to extend the simple graph bound from bipartite to general graphs. The difficulty is that the natural notion of level graph does not capture the structure of blossoms needed for this bound. Fundamentally:
Vertices no longer have unique levels. An size graph can have different levels.
Our level graph is not unique. It depends on the augmenting trails being analyzed.
Our analysis uses the natural version of our level graph to prove basic properties of blossoms. But we need to remove redundancies to deduce the final bound.
In spite of these difficulties we wind up with only two levels for each vertex, just like the bipartite case.
Previous work on simple general graphs was essentially introduced in the break-through paper of Duan, He, and Zhang [5]. They present a scaling algorithm for maximum weight -matching of simple (general) graphs. It comes within logarithmic factors of the bipartite bound, ( the maximum edge weight). In fact when all weights are 1 this is the first algorithm to achieve the bound to within logarithmic factors, for unweighted -factors of simple general graphs. (See also [14] for a algorithm on multigraphs with time .)
Our algorithm also runs in time on multigraphs. The first bound is a slight improvement of the above bound of [17] (and avoids scaling).
Content and structure of the paper
We call the new type of vertex levels “petalevels”. (They are caused by the petals of blossoms.) We present a family of example graphs that has a quadratic number of petalevels. The construction is not needed to prove our upper bound, but provides motivation. We also present formulas for ordinary levels and petalevels, without proof but for more motivation. The formulas can be proved using the approach of [11] for matching. In fact our algorithm follows the weighted matching approach to maximum cardinality matching introduced by Gabow [11].
The paper is organized as follows. Section 2 sets the stage. It starts by reviewing the shortest-augmenting-trail approach (Section 2.1) and the -matching algorithm (Section 2.2). Section 2.3 presents our example graph with multiple petalevels. Section 3 proves the main result, the bound on iterations for simple graphs. Section 4 completes our result by providing details of the matching algorithm. Appendix A completes the description of how the -matching algorithm searches the example graph.
Terminology and conventions
We often omit set braces from singleton sets, denoting as . So denotes . We abbreviate expressions to . We use a common summing notation: If is a function on elements and is a set of elements then denotes .
The trees in this paper are out-trees (i.e., a root has indegree 0 and all other nodes have indegree 1). An out-forest is a collection of disjoint out-trees. (We sometimes erroneously say “out-tree” when “out-forest” is the proper term; this is done for convenience and intuition.) Writing for an arc of a tree implies the arc joins parent to child . In this case we also define to be arc . (Mnemonically, stands for directed to.)
We extend parent and child relations to tree arcs, e.g., arc is the parent of . A node is an ancestor of a node allows the possibility , unless is a proper ancestor of .
Graphs in this paper are undirected multigraphs. Loops are allowed (even in simple graphs). A cycle is a connected degree 2 subgraph, be it a loop, 2 parallel edges, or an undirected graph cycle. A trail is a path that is allowed to repeat vertices but not edges. For vertices an -trail has ends and .
In graph for and , () denotes the set of edges of with exactly one (respectively two) endpoints in . We sometimes write For a set of vertices and a subgraph of , (). () denotes the degree of vertex in . When referring to the given graph we often omit the last argument and write, e.g., . (For example a vertex has .)
We omit (writing or ) when . A loop at belongs to . For multigraphs all of these sets are multisets.
For an undirected multigraph with function , an -matching is a subgraph where each vertex has degree at most . A maximum (cardinality) -matching contains the greatest possible number of edges. Vertex is free if strict inequality holds.
We often call an -matching a matching. We refer to an ordinary matching as a 1-matching (i.e., is identically 1 for all vertices). is the deficiency of vertex in the current matching , .
Consider a graph with an -matching . An augmenting trail is an alternating trail that begins and ends at a free vertex, such that is a valid matching, i.e., the two ends of the trail still satisfy their degree bound . (The trail may be closed, i.e., begins and ends at the same vertex. Alternating means consecutive edges of have opposite M-types.)
Additional notation for matchings is given at the start of Section 2.2.
2 Background
2.1 Shortest Augmenting Trails
Consider an -matching . Let be an augmenting trail for . denotes the length of . is a shortest augmenting trail if it has the minimum length possible. We call a sat.
Hopcroft and Karp [16] and Karzanov [18] proved the fundamental result that for 1-matching the length of a sat is nondecreasing. The proof immediately extends to -matching. For completeness we sketch it.
Lemma 2.1
Let be an arbitrary -matching. Let be a sat for and a sat for . Then .
Proof: Let be the -matching resulting from augmenting the two sats, . Since we have
We claim contains two edge-disjoint trails that are augmenting for . This implies
Combining these two inequalities gives , as desired. So to complete the proof we need only prove the claim.
For let trail have ends and .
(These four ends need not be distinct, in fact all four may be
the same vertex.) Enlarge to an -matching by adding
artificial edges , . Every vertex
has . So is a collection of edge-disjoint
alternating circuits. Removing the two artificial edges creates
two alternating trails that begin and end
with edges of and hence are augmenting for
. (In detail let be the circuit containing , .
If then the desired augmenting trails are
. If then
is the disjoint union of trails and .)
The lemma leads to the following high-level algorithm for finding a maximum cardinality -matching. Define a blocking set to be a maximal size collection of edge-disjoint shortest augmenting trails. The algorithm repeatedly finds a blocking set and augments each of its trails. When no augmenting trail exists the matching is maximum.
Our goal is to show a maximum cardinality -matching on a general graph can be found in time (1.1). Section 4 shows a blocking set can be found in time . So the goal is achieved by showing the high-level algorithm finds blocking sets on multigraphs and blocking sets on simple graphs. The arguments are as follows.
Let be the -matching at some point in the high-level algorithm. Let be the length of a sat for . We start with the simple analysis for multigraphs.
Proof of the bound
A maximum cardinality matching gives a collection of disjoint augmenting trails. Each such trail is alternating. Its length is . So it has matched edges. This imples there are trails. When there are such trails. So the number of searches in the algorithm is .
Proof of the bound
Any vertex occurs at most twice in a sat. In proof, if a sat enters on edge and reenters on , then the two edges have opposite M-types (otherwise we can omit the subtrail from to .) Thus the algorithm halts with .
Proof of the bound, high level
The key property is
Any -matching has at most more edges than .
Taking shows after searches, at most augmenting trails need be found. So the total number of searches is at most .
Section 3 will prove . We do this by defining a level graph and identifying a bottleneck level, as in [10] and [18]. Ultimately the argument is similar to the bipartite argument: We show some layer of has nodes, hence edges.
Our approach, both for proving and for our corresponding efficient algorithm, is via weighted matching, as presented for ordinary matching by Gabow [11]. In detail suppose we seek a sat for a given -matching . Assign weights to the edges of by
(2.1) |
The (incremental) weight of an alternating trail is defined as
An alternating trail that starts with an unmatched edge emanating from a free vertex has length
(2.2) |
So a sat is an augmenting trail with the greatest possible weight. Edmonds’ algorithm for ordinary matching, as extended to -matchings by Gabow [12], finds such a trail.
Combining this idea with the high-level algorithm of Hopcroft and Karp gives the pseudocode for our algorithm in Fig. 1. We fill in the details of this algorithm in Section 4. First we will use this outline to prove , in Section 3.
Initialize to for multigraphs or for simple
graphs. Then execute the following:
a maximal -matching,
while ()
for (every edge ) if () else
for (every vertex )
execute an -matching search to find a maximum weight augmenting trail
if (no augmenting trail is found) return
a blocking trail set
augment the trails of
loop
search for an augmenting trail
if (no augmenting trail is found) return
augment
2.2 Weighted Blossoms
The proof of requires some basic properties of -matching blossoms. We present them here. Readers familiar with [12] need only skim this section to review the notation. Fig. 2 illustrates the discussion.
We begin with more terminology for matchings.
Contracting a subgraph contracted vertex (all internal edges including internal loops disappear). We will even contract subgraphs that just contain a loop. We use the following notation for contractions. Let be a graph derived from by contracting a number of vertex-disjoint subgraphs. () denotes the vertex set of (), respectively. A vertex of that belongs to (i.e., it is not in a contracted subgraph) is an atom. We identify an edge of with its corresponding edge in . Thus an edge of incident to a contracted vertex is denoted as , where and are -vertices in distinct -vertices, and . Let be a subgraph of . The preimage of is a subgraph of consisting of the edges of , plus the subgraphs whose contractions are vertices of , plus the atoms of . () denotes the vertex set of (the preimage of ), respectively. Similarly () denotes the edge set of (the preimage of ), respectively.
Figures in this paper use the following conventions. Matched edges are drawn heavy, unmatched edges light. Free vertices are drawn as rectangles. Edge weights are always given by (2.1). Trails are indicated by arrowheads on their edges.
When discussing a matching , the M-type of an edge is or depending on whether is matched or unmatched, respectively. We usually denote an arbitrary M-type as , and denotes the M-type of edge .
Let be a graph with an -matching. A trail is closed if it starts and ends at the same vertex. A trail is alternating if every 2 consecutive edges have opposite M-types. The first and last edges of a closed trail are not consecutive.
Blossoms are defined recursively as follows. Let be a graph derived from by contracting a family of zero or more vertex-disjoint blossoms. Let be a closed trail in that starts and ends at a vertex . The preimage of is a blossom with base vertex if has the following properties:
If is an atom then starts and ends with edges of the same -type. has this -type and .
If then has the same -type as and .
If is an atom of then every 2 consecutive edges of alternate.
If then . Furthermore if then contains an edge of opposite -type from .
Note that as a subgraph of , a blossom has vertex and edge sets and . Also note in Fig.2 the blossom of part (b) can be viewed as being formed from the blossom of part (c) or the blossom of part (d). (This nonuniqueness is usually irrelevant.)
In addition we define the base edge of a blossom , denoted . is an edge that leaves from vertex , and it has opposite -type from . Every blossom with base has the same base edge . So now assume is the maximal blossom with base vertex . If is in the closed trail of some blossom, is the edge required in the above definition. (In case both edges of qualify, the choice for is arbitrary.) If is a maximal blossom (i.e., not in such a closed trail) is some chosen edge (of opposite -type from ); it will be clear from context.
Blossoms where is a free vertex are a special case. We say the blossom is free. A free blossom has -type (since an augmenting trail always begins with an unmatched edge). Also the vertex has deficiency 1. (Otherwise the edges of contain an augmenting trail, and the blossom structure is irrelevant.) For a free blossom is a matched edge from an artificial vertex to .
For any blossom , any edge leaving other than is a petal of . Blossom is heavy (light) if its M-type is (), respectively.
In a blossom with base vertex , each vertex has 2 associated -trails in , , . Each is alternating and ends with an edge whose -type is that of . The starting edge for has the same -type as ; it has the opposite -type for . There is one exceptional trail: is the length 0 trail .
Next we describe the linear program dual variables for weighted matching, as they are maintained in [12] (extending [8]). Assume every edge of has a numerical weight . We define a subset of the edges incident to a blossom by
(Here is the matching and stands for “incident”.) There are two dual functions , . Define by
(2.3) |
The duals satisfy the LP feasibility conditions, which (using CS for blossoms) are:
matched | is underrated, i.e., | |||
unmatched | is dominated, i.e., is |
We say is tight if equality holds, otherwise loose. The terms strictly dominated and strictly underrated refer to the possibilities and respectively.
A positive blossom has positive -value. For any positive blossom every edge of is tight. (A zero blossom has . Note that the subgraph of a zero blossom can be part of the subgraph of a positive blossom. For example the blossoms of Fig.2(b)–(d) are zero blossoms. We can make (b) a positive blossom (lower to ) but (c) or (d) remains a zero blossom.)
The last property of duals is that all free vertices have the same -value . A structured matching consists of a matching, duals , and positive blossoms wherein every unmatched (matched) edge is dominated (underrated) respectively; every edge in a positive blossom subgraph is tight; and every free vertex has the same -value.
Edmonds’ algorithm and its extension to -matching both work by constructing a “search structure” . The structure consists of atoms and blossoms, and denotes with all blossoms contracted. is a forest, and we call the elements of “nodes”. (Recall our tree terminology from Section 1.) Every edge of is tight. The roots of are the free vertices/blossoms. If is an atom of then alternates with each child edge of . (For a free vertex take .) The base edge of a blossom in is its parent edge .
Every node of has a corresponding path to the root of its search tree. These paths expand to trails in for every vertex of . We denote the trails as , defined as follows. Call an atom of inner if is unmatched and outer if is matched. Correspondingly an io-type is or , for inner and outer respectively. A vertex in a blossom has both io-types. Any vertex of has a trail . Here is the io-type of . starts with an edge from that is unmatched (matched) for (). It ends on an unmatched edge to a free vertex. starts with if is atomic. If is in a blossom starts with the trail , where is chosen to correspond with . A node on a path to the root in expands in a trail in the obvious way. Every trail is alternating.
For a blossom , two edges of alternate if one of the edges is . The motivation for this definition is that the two edges can be combined with the appropriate trail to form an alternating trail in . Note that with this definition, is an alternating forest, i.e., its edges alternate at every node.
is a shortest alternating trail that starts with an unmatched (matched) edge for () and ends with an unmatched edge to a free vertex. (This can be proved following the development in [11] for 1-matching, or using the tracking algorithm of Section 3. But we do not use this fact.) We denote the length of as . is the basic level of a vertex in the level graph. But unlike level graphs of previous papers, vertices have other levels. We call these other levels petalevels, since they are caused by petals in shortest trails.222In more detail ordinary levels are formed by trails that enter every positive blossom on its base edge. So they are “basic levels”. In contrast petalevels enter at least one positive blossom on a petal. Fig. 2(c)-(d) show a vertex with ordinary level and petalevel 4.
6 | ||||
8 | 9 | |||
10 | 11 | 12 | ||
12 | 13 | 14 | 15 |
2.3 Multiple Petalevels
This section provides a central motivation for our proof of , an example graph with too many petalevels to include in the desired level graph. Strictly speaking the example is not needed to prove . But we include it here to provide an in-depth look at the search structure , to illustrate how multiple petalevels arise, and to provide details about how the example graph’s search structure can actually occur in our algorithm Fig. 1. (The remaining details for this are given in Appendix A.)
The example graph has blossoms, for any even . has vertices and edges. It has sat length and importantly, petalevels. Fig.3 gives a simple example, with and sat length 17. Its table shows there are 6 petalevels (that are not ordinary levels).
As usual vertical level in the figure corresponds to level, i.e., shortest distance from a free vertex. So the two vertices with -value 0 are at level 8. Edges drawn vertically are in the search structure .
The blossoms are alternately heavy and light. The triangle blossom has a slightly different structure from the others. Changing it to have the same structure gives a similar construction, with multiple petalevels. We do not present it because that structure cannot be grown using the algorithm of Fig.1. Fig.5 shows how the algorithm grows the search structure of Fig. 3.
Note also that a similar example uses only light blossoms. So our construction can be modified for ordinary matching. The given construction has the advantage of being smaller.
Fig.4 illustrates the general structure of the example graph . In addition we assume . The remaining vertices are saturated, as implied by the figure, and their -value is 1 or 2. The figure implies the following expressions that combine to define the augmenting trail of a cross edge .
Let be the io-type () for odd (even). Let . For every ,
To calculate the length of ’s trail first note . So .
The augmenting trail for is
(2.6) |
Its length is as desired.
It is clear that the graph has size , and (2.4) implies there are petalevels. It only remains to prove the augmenting trails of (2.4) are all sats, i.e., . Appendix A shows this by exhibiting the optimum dual values. Here we present a path-tracing argument for greater intuition.
Let be a sat. The degree constraints imply contains both free vertices and . So contains a cross edge . The alternation of implies similar properties on both sides of the cross edge:
Proposition 2.2
(a) is the path .
(b) For contains or its reverse.
(c) For if contains the directed edge then it contains . ( is defined as in (2.5).)
Proof: (a) A cross edge directed to alternates with , but not (see Fig. 4(c)). Using this, a simple downward induction (starting at ) shows contains directed edge .
The arguments for (b)–(c) are similar to (a): Arriving at a vertex on a directed edge , alternation implies there is only one possibility for the next edge.
(b) Examining Fig. 4(b), we use the nonalteration of directed edge .
(c)
Examining Fig. 4(a)-(b), we successively
use nonalteration of
directed edges , ,
.
Part (a) of the lemma shows consists of the trail and a trail from to , that begins with an edge of opposite M-type from the cross edge . We claim that trail must be . (2.6) then shows as desired.
Before proving the claim we show another simple property (self-evident from Fig. 4(a)-(b)).
Proposition 2.3
A shortest path tree for is .
Proof:
First observe that for any , the directed edge
is not in a shortest path
tree of . This follows since the path
is shorter than .
Using this, an easy induction shows no edge
is in a shortest path tree for . This easily gives the
proposition.
For a shortest path from to is . For every , a shortest path from to is .
Proof of the Claim: We first assume . The two exceptions are minor variants, which we treat after the main case.
enters blossom on cross edge . To reach it leaves either on edge or . Observe that in both cases contains an alternating trail from to the edge : To leave on alteration implies uses both edges descending from the cross edge, and alteration at implies uses as claimed. To leave on , alteration at also implies uses .
Now Proposition 2.2(c) shows contains
The rest of joins to . Proposition 2.3 implies a shortest such path path is
can use this path, since it alternates with . Since is a sat we can assume uses it. Now (2.4) shows the claim holds.
Case : After the unmatched cross edge must contain the two matched edges incident to (in either order). So contains the entire triangle. Then it can follow the path . As in the main case we can assume it is used. So wlog contains as desired.
Case : The matched cross edge implies contains an alternating trail beginning and ending with unmatched edges, i.e., and . The latter implies contains . The rest of the argument is the same as .
3 The Simple Graph Bound
As shown in the previous section the vertices of a given graph may have different petalevels. Most of these must be discarded in our desired level graph.
Motivation
We begin by discussing an approach to define a small level graph that is tempting but, to the best of our knowledge, fails.
Like [5, 6] it is based on classifying each blossom as “big” or “small”, depending on whether its “size” (appropriately defined) is or . Assuming disjointness there are big blossoms, so augmenting trails through their base edges can be ignored. A vertex in a small blossom can be traversed on an edge of at most to times, so only petalevels are needed for . And over levels, some level has such petalevels, so augmenting trails pass through that layer of . Unfortunately it does not seem possible to complete this approach. For instance the edges of cannot be accounted for. In fact our approach ignores the notion of big blossoms entirely.
Instead, our approach resembles previous definitions of the level graph: Every vertex is represented at most twice in the level graph (just once for the previous definitions). An important difference is that our level graph depends on the collection of augmenting trails being analyzed. In contrast previous definitions have a unique level graph.
To begin consider a graph with edge weights (2.1). All references to a matching, blossoms, dual variables, etc. refer to some fixed structured matching. (The structured matching will be provided by the algorithm of Fig.1.)
We start with some motivation. We shall see the following formula for the ordinary level of a vertex and any :
(3.1) |
where
The formula is valid for any search structure containing the corrsponding trail .
Reading in reverse, note that it enters every blossom containing through its base edge (e.g., for either in Fig.3). When occurs on a petalevel in some , a blossom containing can be entered on a petal (e.g., in in Fig.3). Equation (3.1) generalizes to give the length of petalevels as follows.
Consider an alternating trail from free vertex to , ending in an edge of io-type . Let be the “entrance sequence” of in , i.e., for every positive blossom containing , is if enters on its base edge, if it enters on a petal ( is mnemonic for “in” value). We write if the vertex is not clear. Define the petalevel
(3.2) |
where for ,
.
When enters and leaves more than once, is defined by the last entry. Here the dual values are for any structured matching. As an example in Fig.3 vertex in has .
Natural petalevels
We will present two versions of the petalevels of (3.2). The natural petalevels define using the following rule. The dummy vertex leading to free vertices is not in any blossom and so has an empty entrance sequence. Suppose advances on an edge , with already defined. For any positive blossom containing ,
(3.3) |
These natural petalevels are consistent with the description of petalevels in (3.2) Note this definition makes empty if is atomic. Also note that the entry for a base edge is consistent: For blossoms with the same base edge , .
We will analyze the natural petalevels before discussing the second version of petalevels. The following lemma is the basis of the crucial property that goes from one level of to the next, unless it falls back to a lower level. The lemma gets extended to the variant petalevels in the corollary below.
We associate an i/o type with an edge by using its M-type and assuming we are advancing along the edge. Specifically for an M-type define
(3.4) |
When considering an edge we usually define . Also for denotes the opposite i/o value from . Similarly for .
Lemma 3.1
Consider an edge in an augmenting trail , where all petalevels are natural.
(a) For ,
(3.5) |
(b) Equality holds in (a) iff is tight and it alternates at every positive blossom that it leaves, i.e., for every positive blossom with , either or .
Proof: The two possibilities matched and unmatched are symmetric, so we cover them in parallel. We begin by reducing the lemma to symmetric inequalities (3.8) and (3.11), and their tightness.
Case : The lemma’s inequality is , i.e., . Rearrange this to the equivalent inequality
(3.6) |
Since is undervalued,
(3.7) |
We will show
(3.8) |
Part (a) follows from (3.7) and (3.8). So we need only prove the latter for part (a). Equality in (3.5) is equivalent to equality in (3.7) and (3.8). So for (b) we need only prove equality in (3.8) is equivalent to (b)’s second condition.
Case : We wish to prove , i.e., Rearrange this to the equivalent inequality
(3.9) |
Since is dominated,
(3.10) |
We will show
(3.11) |
(3.5) follows from (3.10)–(3.11), so we need only prove (3.11) for (a). Similarly equality in (3.5) amounts to equality in the two above inequalities. So (b) amounts to showing equality in (3.11) is equivalent to (b)’s second condition.
We will show that the desired inequalities (3.8) and (3.11) hold blossom-by-blossom, i.e., any blossom contributes at least as much to the LHS as the RHS. To do this, in the context of the chosen blossom we let be ’s contribution to the LHS of (3.8) (respectively (3.11)) and similarly for , when discussing the set (resectively ). We will show . In addition we will show some has iff does not alternate at , more precisely, with and a petal of . This clearly implies part (b) of the lemma.
A blossom contributing to a term in (3.8) or (3.11) contains at least one of . (In particular we are done if neither vertex is in a blossom. A vertex not in a blossom is either atomic or it does not belong to .) We consider three cases, , , or a petal of .
Case : contributes to . We show it makes the same contribution to the other side of (3.8) and (3.11).
(3.3) for this case implies . This value is either b or p. Thus contributes to exactly one of the terms , in (3.8), and exactly one of the terms , in (3.11).
So as desired.
Case : First assume is matched. We will show . The case makes , so .
Suppose . Thus enters on its base . So does not enter on a petal, i.e., it does not contribute to the RHS term . Also , so does not contribute to the RHS term . So as desired.
Suppose . Thus leaves on its base . So enters on a petal. Thus does not contribute to the RHS term . Also , so does not contribute to the RHS term . So as desired.
Next assume is unmatched. Opposite from before we show . The case makes , so .
Suppose . Thus enters on its base . So contributes to the LHS term . Also , so does not contribute to the LHS term . So as desired.
Suppose . Thus leaves on its base . So enters on a petal. This makes contribute to the LHS term . Also , so does not contribute to the LHS term . So as desired.
Case a petal of : First assume is matched. Clearly so . Since contains only one of the vertices , only one of the RHS terms , can be positive. Thus as desired.
Suppose . Note the RHS term has a contribution from iff , which may or may not hold for . implies . Also alternates at , as desired for (b). implies . does not alternate at . Again (b) holds.
Suppose . contributes to the RHS term , so .
Next assume is unmatched. Clearly so . Thus as desired.
Suppose . The LHS term has a contribution from iff . implies . alternates at , as desired for (b). implies . does not alternate at . Again (b) holds.
Suppose . does not
contributes to the RHS term , so .
Shortened petalevels
As noted there are too many natural petalevels to use in the level graph. But some of them are extraneous. The following property is the source of the redundancy.
Proposition 3.2
Let and be in-values for vertex that are identical except that positive blossoms have and . Then for any , .
Proof:
If is outer contributes to the petalevel
and 0 to the version. If is inner the contribution is
0 to the petalevel
and to the version.
For clarity we write to denote our version of the level graph (using to denote generic level graphs). The petalevels used in sometimes make the change of the proposition, i.e., p entries are changed to . In keeping with the proposition we call this change a shortening. Intuitively, shortening destroys progress of towards the goal, the last level of . But that progress is not needed, since advances from the shortened petalevel to the goal only one level at a time.
We integrate shortening into the tracking as follows. To set the stage, we are given a collection of edge disjoint augmenting trails. Start by choosing an arbitrary orientation for every -trail. For each positive blossom we will define a unique value such that every vertex has in each of its petalevels. Specifically we define if some trail enters on its base. Otherwise .
Observe this is well-defined, since any base edge is on at most one -trail. The effect of this rule is to change an in-value to when enters on a petal, but some other -trail enters on its base.
This translates to the new version of (3.3):
(3.12) |
This change means that in-values no longer correspond exactly to the direction a blossom is entered. The reader should bear this distinction in mind throughout the rest of this section. Now we show the lemma for natural petalevels is preserved by shortening.
Corollary 3.3
Remark: The shortening affects the shortened petalevel
as well as
all of the following petalevels. Because of the latter
the corollary
does not immediately follow from
Proposition 3.2.
Proof: As in the lemma consider an edge . We will refer to the proof of the lemma, explicitly pointing out any changes needed for the corollary. All case references below are to the corresponding case in the lemma’s proof.
In the first two cases , , the reductions to (3.8) and (3.11) are unchanged. The and quantities are now interpreted using (3.12) for -values.
Case : The proof is unchanged: The claim that follows from the first case of (3.3), which is also the first case of (3.12).
Case : First assume is matched.
Suppose . Thus enters on its base . The second case of (3.12) shows . Thus does not contribute to the RHS term , as in the lemma.
Suppose . As in the lemma enters on a petal, say . As in the lemma the term is 0, but now the following argument is used. The first case of (3.12) implies . No -trail enters on its base (since leaves on its base edge , and uses edge only once). Thus (3.12) defines as . So and as desired.
Now assume is unmatched.
Suppose . As in the lemma this means enters on its base . satisfies the second line of (3.12), i.e., and enters on its base. So contributes to the LHS term . As in the lemma does not contribute to the LHS term .
Suppose . As in the lemma this means leaves on its base . Let be the edge of that enters before leaving on . uses only once, so by the third line of (3.12). The first line implies . Thus contributes to the LHS term , as desired.
Case a petal of : First suppose is matched. If the argument does not change: The RHS term has a contribution from iff , which may or may not hold for . If it does then .
If then enters on a petal. The second or third line of (3.12) applies. The third line keeps so as in the lemma, contributes to the RHS term . The second line means does not contribute to the RHS and .
Next assume is unmatched. As in the lemma
this makes so
as desired.
In more detail suppose .
may or may not have . The former gives strict inequality
. Suppose . may or may not have .
The former gives strict inequality.
Analysis
We prove properties of shortened petalevels that lead to the definition of our level graph and its correctness.
The first fact will be used to define the last level of our level graph. Consider an iteration of the matching algorithm Fig.1. The algorithm uses the -matching search algorithm of [12] to find an augmenting trail. The search ends with a structured matching for an augmenting trail. Let denote the -value of free vertices in this structured matching. Define .
Lemma 3.4
The last vertex of any -trail has petalevel .
Remark: The lemma does not preclude multiple visits to this petalevel.
Proof: Suppose starts at a free vertex and ends at a free vertex on an odd petalevel . The edge leading to is unmatched, and possibly in various blossoms with base vertex . (It is also possible that .) The definition of petalevels (3.2) gives . We will show the term equals 0. This makes the petalevel equal to , as claimed.
To analyze the term we start with this observation: Let be the base vertex of a positive blossom . (There may be many such .) is on at most one -trail , and is the first or last vertex of but not both. In proof, since is positive the -trail forming is not augmenting. Thus . Thus occurs at most once as an end of a -trail.
Now return to the given trail ending at . Take any
positive blossom with base vertex . ends on the base
edge of , . The observation implies
no -trail enters on its base .
Thus (3.12) shows . Hence
as desired.
Recall the lemma tracks -trails with shortened petalevels. A version of the lemma with natural petalevels is useful:
Corollary 3.5
Tracking an augmenting trail with natural petalevels, its last vertex has petalevel .
Proof:
The argument is simpler – it is obvious that enters
a blossom containing on a petal.
We now present the details of our level graph. We call it , to distinguish it from references to generic level graphs . We use the term node to refer to vertices in the level graph. Define the last level of to be .
Each edge of advances at most one level in . We conclude every -trail uses an edge in every layer of . (N.B. The edges of that advance from level 0 to need not form an augmenting trail or even contain one: Loose edges retreat in and lead to duplicate advances. may leave the search graph and reenter at a different point, etc.)
We complete the definition of by specifying the petalevels that it uses. Every vertex has at most two petalevels in , . Here ranges over the io-types i,o, and the in-values are consistent with our shortening rule: For every positive blossom containing ,
(3.13) |
If is atomic, i.e., not in any positive blossom, these petalevels are ordinary levels , by (3.1). contains every possible edge that joins two such nodes on consecutive levels.
We show this level graph tracks every -trail from level 0 to level . To be precise assume (3.12) is used to define the petalevels that track . Let denote the set of edges of that are in the final set of tracked advances. ( need not include every forward edge of . For example a petal that enters a positive blossom becomes a backup edge if it gets shortened.)
Lemma 3.6
Suppose edge advances from level to (where these petalevels are defined using (3.12)). The level graph has a corresponding edge from node on level to node on level .
Proof: The main argument is to show the vertex has a corresponding node on level . (Here is an arbitrary vertex, so this suffices to show also has its corresponding vertex.)
First suppose is an atom, i.e., not in any positive blossom. As previously noted, (3.12) and (3.1) define as , and has been defined to contain the corresponding node.
Next suppose is contained in various positive blossoms, and fix such a blossom . Suppose enters on edge and follows the trail to , , that is contained in . (3.12) defines according to line 2 or 3, i.e., for ,
iff some -trail enters on .
The first line of (3.12) defines as . Thus holds for every , including . for is identical to the definition of in (3.13), as desired.
We conclude that contains the desired nodes for and
. By definition
contains every possible edge in the layer for ,
so it contains the desired edge for .
Let denote the length of a sat in . We will show is the number of levels in , . The reason is that the -matching search algorithm finds a sat. This can be seen from first principles, but we prefer to use our tracking of natural petalevels.
Let be the augmenting trail found by the -matching algorithm in Fig.1. Recall that is discovered as an alternating path in the algorithm’s search structure . The subtrail of through any contracted blossom of is the appropriate trail (recall Section 2.2). The construction of these trails (Lemma 4.4 of [12]) easily shows that they alternate at every blossom they traverse. (This includes all subblossoms of .) We conclude that every edge of satisfies the conditions of Lemma 3.1 (b). Thus every edge of advances to the next highest petalevel.
Corollary 3.5 shows ends at petalevel . never visits a petalevel twice, since it always advances petalevels. Thus ends the first time it reaches , . Lemma 3.4 shows every augmenting trail has length . Thus is a sat and , as desired.
We finally note has the desired size and our overall efficiency bound holds: The vertices of have corresponding nodes in . has layers. Some layer of has nodes. Thus has edges. Every -trail uses an edge in . So has at most trails. This is the desired key property .
4 The Cardinality Matching Algorithm
This section presents the details of our cardinality matching algorithm, Fig. 1.
Details and correctness
We use the algorithm of [12] for the -matching search. The previous section shows it finds a sat. It remains only to give the details for finding the blocking set.
We use the blocking flow algorithm of [13]. By definition, that algorithm finds a maximal collection of disjoint augmenting trails. So a priori it is not guaranteed to find the -set that we seek. We will prove that in our context, [13] does find sats. Thus Fig.1 is correct.
We call [13] with the set of tight edges and the blossoms found in the -matching search. (In general [13] is called with a graph and a matching, and an optional set of blossoms.) The algorithm finds a maximal set of edge-disjoint augmenting trails. We will show that in our context a trail is augmenting iff it is a sat. This establishes the validity of our use of [13].
Time bound
Each iteration of our algorithm uses time . Specifically the time for an -matching search is . This follows from the algorithm description in [12], using data structures given in [11, Section 5] for ordinary matching. (Adapting them for -matching is straightforward. We use the fact that .)
The time to find the blocking set is [13]. (Note that the trails returned by [13] have all positive blossoms contracted. Our algorithm expands these blossoms – the trail through a blossom is the appropriate trail. These trails can be computed in linear time [13, Appendix C].)
Theorem 4.1
A maximum cardinality -matching can be found in time for simple graphs and for a multigraphs.
A The Search of the Example Graph
This section gives shows the -matching algorithm can grow the search structure of our example graph.
The search in
Fig.5 shows how the -matching algorithm grows the search structure of Fig.3. Parts (a)–(d) show how the blossoms are formed. In addition we must check that no cross edge enters until the sat’s are discovered (i.e., ). This follows from the fact that cross edges are loose (with one minor exception) before that point. In proof enters strictly before . The next dual adjustment makes an unmatched cross edge strictly dominated ( increases by 1, see part (e)) and a matched cross edge strictly underrated ( decreases by 1, see part (f)). As long as is atomic, dual adjustments keep the cross edge loose: For an unmatched (matched) cross edge, decreases by 0 or 1 (increases by 0 or 1), respectively. After is formed, dual adjustments reduce the slack in ’s inequality: If is unmatched decreases by 1 () or 2 (). If is matched increases by 1 () or 2 (). Each is tight when the sat’s are discovered (recall Fig.3). So was strictly dominated before that point.
The general search structure
Fig. 6 and 7 illustrate the final search structure constructed by the -matching algorithm. Start by considering the blossom structure, illustrated in Fig. 6(a)–(b). In the definition of ((2.3)) abbreviate the term to . The edge is tight, i.e., . This relation, and the tightness of all 6 edges shown in Fig. 6(a)–(b), implies all the values shown. For example, in (a) edge has (we use , contributes to both ’s).
The relations between the ’s gives the following constraints. Let and be the two children of , and let be their -value.
(A.1) | |||||
(A.2) | |||||
(A.3) | |||||
(A.4) |
In proof the relation gives (A.1) and (A.2). The last two lines come from tightness of the triangle blossom: Tightness of the unmatched edge gives , i.e., (A.3). Tightness of the matched edge gives , so giving (A.4). There are no other constraints on the ’s.
It is easy to see the above system gives these values:
(A.5) |
Using verifies the -values shown in Fig.6(c). Grow steps in the -matching algorithm give the two alternating paths that end at , and . We define to start with the cross edge from (ending at , the inner vertex with -value ). Recalling Fig.4(c), we must check that the various cross edges do not preempt the grow steps for (e.g., Fig. 7 indicates potential grow steps for ’s cross edge). An easy alternative is to enlarge the example graph with alternating paths similar to but starting at each base . The disadvantage is that the example graph grows to size .
No preemptions
The grow step to vertex occurs either from vertex or from a vertex on ’s grow path. We show that both of these grow steps become possible when
(A.6) |
Thus the algorithm can choose to grow from , as desired.
We start with the case. The blossoms are formed in consecutive dual adjustments. is formed in the penultimate search, i.e., . So in general each blossom is formed when
(A.7) |
Using A.5, the -value of when is formed is
(A.8) |
At that point, assuming ’s cross edge is still not in , .
Suppose is odd. is unmatched. is strictly dominated (since is positive) and the next dual adjustments make tight, . Using (A.7) these duals adjustments decrease to . Thus (A.6) holds in the odd case.
Suppose is even. is matched. is strictly underated (since is negative). Since belongs to and no other sets, each dual adjustment increases the value of by 1. So the next dual adjustments make tight. Using (A.7) these duals adjustments decrease to . Thus (A.6) holds for even.
We turn to ’s path. We will show that the algorithm can grow the path shown in Fig. 6(c). View the graph as in Fig.4(c), i.e., is the vertex on at distance from free vertex . Execute the search algorithm, always choosing to grow path whenever possible.
Consider the cross edge for ending at . (A.6) shows it becomes tight when . This is before any other cross edge becomes tight, so it is added to . Inductively assume path has been extended, with no cross edge from a , grown, when gets decreased to the value of (A.6) , when cross edge becomes tight. Note that path extends by 2 edges every other dual adjustment. More precisely when
the grow path can be extended to length , i.e., the vertices at distance and can be added. (For example the case correponds to the above grow step when .) Eyeballing Fig.4(c), the distance of ’s end from the start of is
(A.9) |
Suppose is odd. Since the distance (A.9) is odd, can be extended to this ’s end when , . This corresponds to . (A.6) gives the same value for the grow step from . So our rule grows as desired.
Suppose is even. The distance of ’s end from the start of , (A.9), is even. So can be extended to ’s end when . This corresponds to . (A.6) gives the same value for the grow step from . Again our rule grows as desired.
Edge triggers a blossom step in the -matching algorithm.
In summary, the uniqueness of the structured matching, plus the above growth argument, implies that the -matching algorithm finds the search structure that we show.
We turn to the structure of the cross edges. The alternating trail from free vertex to the cross edge from is 3 edges longer than the similar trail for . This is follows since the trail has 3 extra edges. It can be constructed from by replacing with and extending it with edge . Fig.7 illustrates the cross edges as they switch the path leading to . The pattern repeats every 3 cross overs.
References
- [1]
- [2] R.K. Ahuja, T.L. Magnanti, and J.B. Orlin, Network Flows: Theory, Algorithms, and Applications, Prentice-Hall, Saddle River, New Jersey, 1993.
- [3] L. Chen, R. Kyng, Y. Liu, R. Peng, M.P. Gutenberg, S. Sachdeva, “Maximum flow and minimum-cost flow in almost-linear time”, arXiv:2010.01102, 2022.
- [4] E.A. Dinic, “Algorithm for solution of a problem of maximum flow in networks with power estimation”, in Russian, Soviet Mathematics Doklody 11, 1970, pp. 1277–1280.
- [5] R. Duan, H. He, and T. Zhang, ”A scaling algorithm for weighted f-factors in general graphs”, Proc. of the 47th International Colloquium on Automata, Languages, and Programming (ICALP 2020), Vol. 168 of LIPIcs, pp. 41:1–41:17, 2020.
- [6] R. Duan, S. Pettie, and H-H. Su, ”Scaling algorithms for weighted matching in general graphs”, ACM Trans. Algorithms 14, 1, 2018, Article 8, 35 pages.
- [7] J. Edmonds, ”Paths, trees, and flowers”, Canad. J. Math. 17, 1965, pp. 449–467.
- [8] J. Edmonds, “Maximum matching and a polyhedron with 0,1-vertices”, J. Res. Nat. Bur. Standards 69B, 1965, pp. 125–130.
- [9] J. Edmonds and R.M. Karp, ”Theoretical improvements in algorithmic efficiency for network flow problems”, J. ACM, 19, 1972, pp. 248–264.
- [10] S. Even and R.E. Tarjan, “Network flow and testing graph connectivity”, SIAM J. Comput., 4, 1975, pp. 507–518.
- [11] H.N. Gabow, ”The weighted matching approach to maximum cardinality matching,” Fundamenta Informaticae (Elegant Structures in Computation: To Andrzej Ehrenfeucht on His 85th Birthday) 154, 1-4, 2017, pp. 109–130.
- [12] H.N. Gabow, ”Data structures for weighted matching and extensions to -matching and -factors,” ACM Trans. Algorithms 14, 3, 2018, Article 39, 80 pages.
- [13] H.N. Gabow, “Blocking trails for -factors of multigraphs,” Algorithmica, https://doi.org/10.1007/s00453-023-01126-y, 2023.
- [14] H.N. Gabow, ”A weight-scaling algorithm for -factors of multigraphs,” Algorithmica, https://doi.org/10.1007/s00453-023-01127-x, 2023.
- [15] H.N. Gabow and R.E. Tarjan, “Faster scaling algorithms for network problems,” SIAM J. Comput., 18, 5, 1989, pp. 1013–1036.
- [16] J.E. Hopcroft and R.M. Karp, “An algorithm for maximum matchings in bipartite graphs”, SIAM J. Comput., 2, 1973, pp. 225–231.
- [17] D. Huang and S. Pettie, “Approximate generalized matching: -matchings and -edge covers”, Algorithmica 84, 7, 2022, pp. 1952–1992.
- [18] A.V. Karzanov, “On finding maximum flows in network with special structure and some applications”, in Russian, Math. Problems for Production Control 5, Moscow State University Press, 1973, pp. 81–94.
- [19] A.V. Karzanov, “An exact estimate of an algorithm for finding a maximum flow, applied to the problems ’of representatives’“, in Russian, Voprosy Kibernetiki, Trudy Seminara po Kombinatorno Matematike 5, Sovetskoe Radio, Moscow, 1973, pp. 66–70.
- [20] B. Korte and J. Vygen, Combinatorial Optimization: Theory and Algorithms, 3rd Ed., Springer, NY, 2005.
- [21] S. Micali and V.V. Vazirani, ”An algorithm for finding maximum matching in general graphs”, Proc. 21st Annual Symp. on Found. of Comp. Sci., 1980, pp. 17–27.
- [22] J.B. Orlin and R.K. Ahuja, “New scaling algorithms for the assignment and minimum mean cycle problems”, Math. Programming 54, 1992, pp. 41–56.
- [23] A. Schrijver, Combinatorial Optimization: Polyhedra and Efficiency, Springer, NY, 2003.
- [24] V.V. Vazirani, “A theory of alternating paths and blossoms for proving correctness of the general graph maximum matching algorithm”, Combinatorica, 14, 1, 1994, pp. 71–109.
- [25] V.V. Vazirani, “A simplification of the MV matching algorithm and its proof”, CoRR, abs/1210.4594v5, Aug.27, 2013, 32 pages; also “A proof of the MV matching algorithm”, manuscript, May 13, 2014, 42 pages.