Contents / Combinatorics / Matroids and Matchings
Chapter 10
Matroids and Matchings
The structure that makes the greedy algorithm correct, and the matching theory of Hall and König that mirrors it.
Introduction
The structure that makes the greedy algorithm correct, and the matching theory of Hall and König that mirrors it.
Two questions run through this chapter, and they are the same question asked twice. The first is: when is it safe to be greedy? Sort the objects by value, sweep through them once, take whatever you can. Kruskal's algorithm does exactly this and returns a genuinely optimal spanning tree; the same sweep applied to the edges of a graph in search of a maximum-weight matching returns garbage. Something about forests makes greed correct and something about matchings does not, and matroid theory is the precise answer: greed is correct on a set system if and only if that system is a matroid.
The second question is what to do when greed fails. The answer for matchings is the augmenting path — a local certificate of improvability — and the theory built on it is a chain of theorems of a very recognisable shape: the maximum of one thing equals the minimum of another. Hall, König, Tutte–Berge and the matroid intersection formula all have this shape. The first half of the chapter builds the structure that makes a sweep optimal; the second builds the search that replaces the sweep when the structure is absent. Chapter Flows and Duality then explains why every min–max theorem here has the same proof underneath.
10.1Independence: the Axioms and Their Equivalents
Two familiar notions of "independence" behave identically even though they live in different worlds. In a vector space, a set of vectors is independent when none is a linear combination of the others; every maximal independent subset of a fixed set spans that set, and all such subsets have the same size. In a graph, a set of edges is independent when it contains no cycle; every maximal forest inside a fixed edge set has the same number of edges, namely the number of vertices of the graph minus the number of connected components that edge set leaves behind. Neither fact mentions the other's vocabulary, yet both are consequences of one short list of axioms.
Definition 10.1 (Matroid). A matroid is a pair where is a finite set — the ground set — and is a family of subsets of , called the independent sets, satisfying:
(I1) .
(I2) (hereditary) If and , then .
(I3) (augmentation, or the exchange axiom) If and , then there is an element with .
A subset of that is not independent is dependent.
Definition 10.2 (Basis, circuit, rank, closure). Let be a matroid and .
- A basis of is a maximal independent set; a basis of is a maximal independent subset of . The family of bases is written .
- A circuit is a minimal dependent set. A circuit of size one is a loop; two elements forming a circuit of size two are parallel.
- The rank is the size of a basis of , and .
- spans if , and the closure of is .
The rank is only well defined once we know that all bases of have the same size, which is the first thing to prove.
Intuition. Read "independent" as "carrying no redundancy". A committee in which every member brings a skill nobody else has is independent; the moment a member's skill is already covered, the committee is dependent. Axioms (I1) and (I2) are bookkeeping — the empty committee is fine, and dropping members cannot create redundancy.
Axiom (I3) is the whole content. It says that if your committee is smaller than a rival's, you can always poach some rival member who brings you something new. You are never stuck at a small committee for lack of a legal move — and that, as the greedy theorem will show, is exactly the property a one-pass algorithm needs.
Example 10.3 (Verifying the uniform matroid). Fix integers , let be a set with , and let . Show that is a matroid, and identify its bases, rank function and circuits.
Solution. (I1) . (I2) A subset of a set of size at most has size at most .
(I3) Let with . Then , and since the set is not contained in , so there is . Now , so .
The maximal independent sets are the -element subsets, so and . The minimal dependent sets are the -element subsets, so those are the circuits — and when there are none, giving the free matroid, in which every subset is independent.□
Pitfall. Axioms (I1) and (I2) alone define a hereditary family (an abstract simplicial complex), and hereditary families are far more common than matroids. On take
Theorem 10.4 (All bases of a set have the same size). Let be a matroid and . Then any two maximal independent subsets of have the same cardinality. In particular is well defined, and every basis of has elements.
Proof. Let and be maximal independent subsets of and suppose . Both are independent, so (I3) supplies with . But , so is an independent subset of strictly containing , contradicting maximality of . Hence , and by symmetry .∎
The proof used nothing special about , which is worth recording: for any the pair satisfies (I1)–(I3) and is itself a matroid, the restriction of to . Every statement about matroids is therefore automatically a statement about every restriction, and that is how the rank function inherits its properties.
Theorem 10.5 (The rank function is monotone and submodular). The rank function of a matroid satisfies, for all :
(R1) ;
(R2) (monotone) if then ;
(R3) (submodular) .
Proof. (R1) A basis of is an independent subset of , so its size lies between and .
(R2) A basis of is an independent subset of , so it extends to a maximal one, of size .
(R3) Choose a basis of and extend it — repeatedly applying (I3) inside the restriction — to a basis of . Put and .
First, . Indeed and give one inclusion; conversely, if some lay outside , then would be independent by (I2) and contained in , contradicting maximality of there.
Second, , while . Since and are independent subsets of and of respectively, inclusion–exclusion on cardinalities gives
Submodularity is the abstract form of the dimension identity from linear algebra — with an inequality in place of the equality, because a matroid need not come from a vector space. Together with the unit-increase property , which follows from (R2) and (R3) applied to and , the axioms (R1)–(R3) characterise rank functions completely: any integer-valued on subsets of obeying them arises from exactly one matroid, namely the one whose independent sets are .
Circuits give a third description, and the key fact about them is an elimination property.
Lemma 10.6 (Circuits in a circuit union). If are circuits of , then .
Proof. A circuit is dependent while every proper subset of it is independent, so . Since are both minimal dependent sets, neither contains the other, so is a proper subset of and is therefore independent: . Submodularity now gives
Theorem 10.7 (Circuit elimination). Let be circuits of and let . Then contains a circuit.
Proof. Write , so that . By Lemma Circuits in a circuit union together with monotonicity,
Corollary 10.8 (The unique circuit of an extension). If and is dependent, then contains exactly one circuit, and that circuit contains .
Proof. A dependent set contains a circuit , and — otherwise would be independent by (I2) — so . If were two circuits inside , both would contain by the same argument, and Lemma Circuits in a circuit union would give , so that is dependent. But is independent — a contradiction.∎
This corollary is the engine of every algorithm below: adding one element to an independent set creates exactly one circuit, so a greedy sweep always knows precisely what went wrong and which single element it may drop to repair it.
Finally the bases. That bases of a matroid can be exchanged one element at a time is easy; that this property alone rebuilds the matroid is the first genuine cryptomorphism, and it is worth proving in full, because it is the template for the rank and circuit versions.
Theorem 10.9 (Basis axioms). Let be finite and a family of subsets of . Then is the family of bases of a matroid on if and only if
(B1) , and
(B2) (basis exchange) for all and every there exists with .
In that case the matroid is unique, with .
Proof. () Let be the basis family of a matroid . It is non-empty because is independent and is finite, so a maximal independent set exists. For (B2), take and . The set is independent of size , so (I3) gives with independent. That set has elements, hence is a basis; and because , so .
() Suppose (B1) and (B2) hold, and set for some .
Step 1: all members of have the same size. If not, choose with and, among all such pairs, one for which is as small as possible. Since we have ; pick in it. By (B2) there is with . Then , while is strictly smaller than , contradicting the choice. Write for the common size.
Step 2: (I1) and (I2). is non-empty, so , and is downward closed by construction.
Step 3: (I3). Let with , and suppose for contradiction that for every . Then no member of containing can meet : if for some in , then would lie in . Consequently
Fix with , and among all containing choose minimising . If that quantity were positive, pick . Then , so (B2) yields with . Since we still have , and since ,
Now and , and these two sets are disjoint by the blocking property. Therefore
Finally, the maximal members of are exactly the members of — they all have size , and every member of sits inside one — so is the basis family of , and is forced by .∎
Remark. The same pattern recovers a matroid from its circuits and from its rank function. Circuit axioms: ; no member of contains another; and circuit elimination as proved above. Rank axioms: (R1)–(R3), with integer values. Closure axioms: , monotonicity, idempotence , and the Mac Lane–Steinitz exchange property — if then . Each of the four systems determines the other three; Oxley's Matroid Theory, Chapter 1, carries the remaining verifications, every one of which has the shape just displayed. These descriptions are called cryptomorphic rather than merely equivalent, because the translation between them is not a matching-up of axioms but a reconstruction of one structure from another.
10.2Where Matroids Come From
A definition with one example is a definition with no examples. The four families below are the ones the rest of the chapter uses, and they are genuinely different: each contributes matroids the others cannot produce.
Definition 10.10 (Linear matroid). Let be a field and an matrix over . Take to be the set of column indices and let consist of those whose columns are linearly independent over . This is the linear (or vector) matroid . A matroid isomorphic to some over is called -representable.
That is a matroid is the Steinitz exchange lemma of linear algebra: (I1) and (I2) are clear, and (I3) says that an independent set of vectors inside the span of a larger independent set can be enlarged using one of them. Its rank function is , its circuits are the minimal linear dependences, and its closure is genuine linear span intersected with .
Definition 10.11 (Graphic matroid). Let be a finite graph, possibly with loops and multiple edges. Let be the family of acyclic edge sets — the forests of . The matroid is the cycle matroid of , and a matroid of this form is graphic.
Theorem 10.12 (The cycle matroid is a matroid). For every finite graph , the forests of form the independent sets of a matroid on . Its rank function is
Proof. (I1) and (I2) are immediate: the empty edge set is acyclic, and deleting edges cannot create a cycle.
For the rank formula, let and let be a maximal forest of . Every component of has a spanning tree inside — if some component had two -pieces, an -edge joining them could be added to without closing a cycle, contradicting maximality — and a tree on vertices has edges. Summing over the components gives , a value independent of which maximal forest was chosen.
(I3) now follows. Let be forests with . Reading the formula with and , the spanning subgraph has components and has components. Since has strictly fewer components, some edge must join two distinct components of : otherwise every edge of would lie inside a component of , and each component of would be a union of components of , forcing . Adding such an to joins two components, so creates no cycle, and . Hence .
Finally, a minimal dependent set is a minimal edge set containing a cycle, which is the cycle itself.∎
Intuition. In , "independent" means "adds no redundant connection". A forest is a set of edges each of which genuinely merges two pieces of the graph; a cycle is the smallest set in which one edge is doing work another already did. Because , rank measures how much merging has been achieved, and the whole theory of spanning trees becomes the theory of bases of one matroid.
Example 10.13 (Bases and the circuit of a -cycle). Let have vertices and edges , , , . Describe : its rank, its bases, and its circuits.
Solution. The graph is connected with , so and every basis has three edges. Any three of the four edges omit one edge and form a path through all four vertices — a tree — so all triples are bases. The full set is the cycle, and removing any single edge leaves a tree, so it is a minimal dependent set: the unique circuit.
Note that is exactly . The same matroid therefore arises from a graph and from the "at most three of four" rule, which is the point of the abstraction — and a warning that a matroid does not remember the graph it came from.□
Definition 10.14 (Transversal matroid). Let be a finite set and a family of subsets of . A partial transversal of is a set of distinct elements that can be matched to distinct indices with for every . The transversal matroid has ground set and the partial transversals as independent sets.
Theorem 10.15 (Edmonds–Fulkerson). For every finite family of subsets of , the partial transversals of are the independent sets of a matroid on .
Proof (Sketch — rests on the augmenting-path machinery of the matching sections). Build the bipartite graph with parts and , joining to whenever . A partial transversal is precisely the set of -endpoints of a matching of , so (I1) and (I2) are clear. For (I3), let and be partial transversals with , realised by matchings and . The symmetric difference decomposes into paths and even cycles by Lemma Symmetric difference of two matchings, and since one of those components is a path with more -edges than -edges, hence an -augmenting path. Switching along it produces a matching covering together with one further element of . The full argument is Edmonds and Fulkerson's; it rests entirely on the augmenting-path machinery of section Matchings, Alternating Paths and Berge's Theorem, which is why the sketch is deferred rather than expanded here.∎
The partition matroid is the special case in which the sets are pairwise disjoint and repeated with multiplicity: partition and fix capacities ; then for all is a matroid of rank . Partition matroids are the plainest non-trivial matroids, and the intersection of two of them is precisely bipartite matching — a fact that section Greedy, Intersection and the Limits of Sweeping turns into König's theorem.
Pitfall. Partition matroids and transversal matroids are not the same thing, and listing them together — as older summaries often do — hides a real containment. Every partition matroid is transversal: take the family in which block is repeated times. The converse fails as soon as the sets overlap. With , and , every pair is a partial transversal — via ; via ; via — while no three elements can be matched to two indices. So . But is not a partition matroid: in a partition matroid, a block containing two elements and having capacity would make that pair dependent, so every block must have capacity at least its own size, which makes every subset independent and the rank , not .
Not every matroid is linear, and not every linear matroid is linear over every field. The smallest obstruction is tiny.
Proposition 10.16 ( is not binary). The uniform matroid is not representable over the two-element field , although it is representable over every field with at least three elements.
Proof. A representation of over would be four vectors in some spanning a space of dimension , so after a change of basis they lie in . Every pair is independent in , and pairwise independence forbids the zero vector and forbids two equal vectors, so the four would be four distinct non-zero elements of . But has only non-zero vectors. Over a field with , the four columns
Symmetrically, the Fano matroid — the rank- matroid on the seven points of the Fano plane, with the seven lines as its three-element circuits — is representable over only when , and its relative only when . Putting the two together, no field represents both, so there is no field over which all matroids of rank are representable. Worse, the Vámos matroid is representable over no field at all, and almost all matroids on elements are non-representable as grows. Representability is a genuinely restrictive property, and this is the reason for developing the theory axiomatically instead of as a branch of linear algebra.
Definition 10.17 (Dual matroid). Let have basis family . The dual is the matroid on whose bases are the complements .
Proposition 10.18 (The dual is a matroid, with rank ). is a matroid, , and its rank function is
Proof (Sketch — rests on Theorem *Basis axioms*). That the complements satisfy (B1) and (B2) is a direct check: complementing turns basis exchange for into basis exchange for with the roles of the exchanged elements swapped, so Theorem Basis axioms applies and is a matroid; involutivity is then immediate from complementing twice. The rank formula follows by choosing, for a given , a basis of and extending it to a basis of : the dual-independent part of is exactly . The details are Oxley, §2.1, and rest on nothing beyond Theorem Basis axioms.∎
Duality is what makes the theory close up on itself. The dual of a graphic matroid is graphic exactly when the graph is planar, and then for the planar dual — so the circuits of , called cocircuits of , are the minimal edge cuts of . The statement "cycles and cuts are dual notions", which in graph theory needs planarity to be a theorem about graphs, is in matroid theory a definition that always applies.
10.3Greedy, Intersection and the Limits of Sweeping
Matroids were not invented to generalise linear algebra for its own sake; the reason they matter to algorithms is a single theorem, and that theorem is an if and only if. A weighting is a function , extended to sets by .
Method 10.19 (The greedy algorithm). Input: a hereditary family given by an independence oracle, and weights .
- Sort as with .
- Set .
- For : if , replace by .
- Return .
The cost is one sort plus oracle calls: , where is the cost of an independence test.
Nothing in the recipe consults the future. Each decision is made once, on the strength of the weight order alone, and never revisited — which is why it is so fast, and why it has no business being correct.
Theorem 10.20 (Greedy characterises matroids). Let be a hereditary family satisfying (I1) and (I2). Then the greedy algorithm returns a maximum-weight member of for every weighting if and only if satisfies (I3) — that is, if and only if it is a matroid.
Proof. (, sufficiency of the matroid axioms.) Let be a matroid and a weighting. Let be the greedy output, indexed in the order the algorithm selected them, so . Since greedy only stops adding when nothing more can be added, is a maximal independent set, so by Theorem All bases of a set have the same size. Let be any independent set of the same size, indexed with ; it suffices to prove
Suppose the claim fails, and let be least with . Consider and , both independent with . By (I3) there is with . Now
(, necessity.) Suppose is hereditary but (I3) fails: there are with and for every . Discarding elements of if necessary — legitimate by (I2), and the failure persists because only shrinks — assume . Write and define
Intuition. The forward direction says a matroid never punishes impatience: taking the heaviest legal element first can never lock you out of an optimum, because (I3) guarantees a legal replacement is always available later. The backward direction says the converse failure is not subtle — one weighting exposes it, and you can read that weighting straight off the place where augmentation broke. Pay a little more for the elements of the stuck set than for the elements of the bigger set , and greed walks into the trap.
Corollary 10.21 (Kruskal's algorithm is optimal). Sorting the edges of a connected graph by weight and adding each edge that does not close a cycle produces a spanning tree of maximum total weight; sorting upwards instead produces one of minimum total weight.
Proof. The forests of form the matroid by Theorem The cycle matroid is a matroid, and Kruskal's rule is exactly Recipe The greedy algorithm with the acyclicity oracle, so Theorem Greedy characterises matroids applies. For the minimum version, run greedy on where ; this is non-negative, and since every basis has the same size , maximising over bases is the same as minimising over bases.∎
Example 10.22 (Greedy beaten by a non-matroid). Take and the hereditary family from the pitfall in section Independence: the Axioms and Their Equivalents. Produce a weighting on which greedy fails, and check it against the construction in the proof.
Solution. Augmentation fails at , , so and the recipe of the proof gives
The proof predicts and . Both match.□
Greed is therefore the exact algorithmic signature of one matroid. Two matroids at once is a different and much harder problem — but remarkably, still a tractable one.
Definition 10.23 (Matroid intersection). Given matroids and on a common ground set, a common independent set is a set in . The matroid intersection problem asks for one of maximum size (or of maximum weight).
Theorem 10.24 (Edmonds' matroid intersection theorem). For matroids on with rank functions ,
Proof. We prove the easy inequality in full; the reverse inequality is Edmonds' theorem and is discussed after the proof.
Let and let be arbitrary. Split along :
Proof (Sketch — Edmonds' exchange-digraph argument). For the reverse inequality, Edmonds' argument runs an augmenting-path search in an auxiliary exchange digraph on whose arcs record which element may replace which in and in . When no augmenting path exists, the set of vertices reachable from the -free elements is exactly a minimiser, and reading off certifies optimality. The structure of the argument — augment, or else read a tight dual object off the unreachable set — is the same one used for König's theorem below and for max-flow min-cut; Schrijver's Combinatorial Optimization, §41, gives it in full.∎
Example 10.25 (Bipartite matching is a matroid intersection). Let be bipartite with parts and and edge set . Exhibit two matroids on whose common independent sets are exactly the matchings of .
Solution. Let be the partition matroid on in which the blocks are the stars for , each with capacity ; define the same way using the vertices of . Because is bipartite, every edge lies in exactly one -block and exactly one -block, so the blocks really do partition in each case.
A set is independent in iff no two of its edges share a left endpoint, and independent in iff no two share a right endpoint. So iff no two edges of share any endpoint — that is, iff is a matching.
Applying Theorem Edmonds' matroid intersection theorem here yields , and unwinding the two partition ranks into "number of left vertices used" plus "number of right vertices used" turns that formula into König's theorem. The general min–max thus already contains the bipartite one.□
Pitfall. Three matroids is one too many. Deciding whether three matroids on a common ground set have a common independent set of size is NP-hard — it contains the Hamiltonian path problem, which is the intersection of two partition matroids (in-degree and out-degree at most one) with one graphic matroid. Nor does greed survive intersection: greedy on two matroids can fail badly, because the element that is safest for may be the one that ruins . The exact boundary is two.
A last structural theorem of the same family deserves a statement, because it is the tool behind several packing and covering results.
Theorem 10.26 (Nash-Williams matroid union). Let be matroids on with rank functions . Then is the family of independent sets of a matroid on , whose rank function is
Proof (Sketch — rests on matroid intersection). That is hereditary is clear, and (I3) follows from a shifting argument on the -tuple of pieces. The rank formula is proved by the same reachability construction as matroid intersection, applied to the direct sum together with a partition matroid encoding "each ground element is used once". A full account is Schrijver, §42; the specialisation to copies of gives Nash-Williams' theorem that has edge-disjoint spanning trees iff every partition of into parts is crossed by at least edges.∎
10.4Matchings, Alternating Paths and Berge's Theorem
Greed is now understood, and the second half of the chapter is about what replaces it. A matching is the standard example of a structure whose maximal objects have different sizes, so no rank function and no greedy sweep can exist. What takes their place is a local certificate: a single path whose presence proves the current solution improvable and whose absence proves it optimal.
Definition 10.27 (Matching). Let be a graph. A matching is a set of edges no two of which share an endpoint. A vertex incident with an edge of is covered (or matched); the others are exposed (or free). A matching is maximal if no edge can be added to it, maximum if no matching of has more edges, and perfect if it covers every vertex. The matching number is the size of a maximum matching.
Pitfall. Maximal and maximum are different words with different meanings, and interchanging them is the commonest error in this subject. In the path the single edge is maximal — every other edge meets or — but the matching is twice as large. It is precisely because maximal matchings have different sizes that matchings are not the independent sets of a matroid, by Theorem All bases of a set have the same size.
Definition 10.28 (Alternating and augmenting paths). Let be a matching in . A path is -alternating if its edges are alternately outside and inside . An -alternating path is -augmenting if both of its endpoints are exposed.
An augmenting path has odd length, since its first and last edges are both outside , and it therefore has one more non-matching edge than matching edge. Switching membership along the path — deleting its -edges and inserting its non- -edges — is called augmenting along it.
Lemma 10.30 (Symmetric difference of two matchings). Let and be matchings in . Every connected component of the spanning subgraph is one of: an isolated vertex, a path whose edges alternate between and , or an even cycle whose edges alternate between and .
Proof. Every vertex is incident with at most one edge of and at most one of , so its degree in is at most . A graph of maximum degree at most is a disjoint union of isolated vertices, paths and cycles.
In any such component, two consecutive edges share a vertex, so they cannot both lie in (that would violate the matching condition) nor both in . Hence edges alternate between and along every path and every cycle. A cycle that alternates must have even length, since its edges alternate between two classes around a closed walk.∎
Theorem 10.31 (Berge). A matching in a graph is maximum if and only if contains no -augmenting path.
Proof. () Suppose is an -augmenting path, with edges where the and the . Put
() Suppose is not maximum and let be a matching with . Consider . By Lemma Symmetric difference of two matchings, every component of is an alternating path or an alternating even cycle. An even cycle contributes equally many edges of and of ; a path contributes either equally many, or one more of one kind. Since , at least one component contributes strictly more -edges than -edges, and it must be a path whose first and last edges both lie in .
Then is -alternating. Its endpoints and are exposed by : the -edge of at lies in , and if were covered by some then either , contradicting that has degree in this component of — the path ends there — or , which is impossible because is already covered by the -edge of and is a matching. So is -augmenting.∎
Intuition. Berge's theorem is what makes matchings computable. Optimality is normally a global statement — no matching anywhere is larger — and verifying it by inspection would mean checking exponentially many candidates. The theorem replaces it by a search: look for one alternating path between two exposed vertices. Find one and you improve; fail to find one and you are done. Every matching algorithm in the next section is a way of organising that search.
Example 10.32 (Augmenting on a path graph). In the path with vertices and edges , start from and find a maximum matching, certifying optimality.
Solution. The exposed vertices are , , . Starting at and alternating, ends at the exposed vertex , so is -augmenting. Switching gives
Matchings sit in a small web of parameters, and the relations between them are worth having, because the min–max theorems of the next section are statements about exactly these quantities.
Definition 10.33 (Covers and independence). A vertex cover is a set meeting every edge; is the size of a smallest one. An independent set of vertices is a set with no edge inside it; is the size of a largest one. An edge cover (defined when has no isolated vertex) is a set of edges covering every vertex; is the size of a smallest one.
Proposition 10.34 (Weak duality). For every graph , .
Proof. Let be a maximum matching and a minimum vertex cover. Every edge of must be met by , and no vertex of can meet two edges of because those two edges would then share it. So the map sending each edge of to a covering vertex in is injective, giving .∎
Theorem 10.35 (Gallai's identities). For every graph on vertices, . If moreover has no isolated vertex, .
Proof. For the first identity, is a vertex cover if and only if is independent: an edge inside is exactly an edge missed by . So minimum covers and maximum independent sets are complements of one another, and their sizes add to .
For the second, take a maximum matching , covering vertices. For each of the exposed vertices pick one incident edge — possible since there are no isolated vertices — and add it. The result covers every vertex, so .
Conversely take a minimum edge cover . Its components are stars: a component with a path of three edges would let us delete the middle edge and still cover everything, contradicting minimality. If has components covering vertices, then since each component is a tree. Picking one edge from each component gives a matching of size , so . Combining, .∎
10.5Hall's Theorem and the König Equivalence
In a bipartite graph the augmenting-path picture crystallises into a clean combinatorial criterion, and that criterion is the model for every min–max theorem in combinatorial optimization. Throughout this section is bipartite with parts and , and for we write for some .
Definition 10.36 (Hall's condition and a saturating matching). A matching saturates if every vertex of is covered by it. The family of neighbourhoods satisfies Hall's condition if
Theorem 10.37 (Hall's marriage theorem). A bipartite graph with parts and has a matching saturating if and only if for every .
Proof. () Let saturate and let . The -partners of the vertices of are distinct vertices of , each a neighbour of some vertex of , so .
() Induct on . If the condition produces the required edge directly (or there is nothing to match). Let and assume the theorem for all bipartite graphs with a smaller left part. Call a non-empty set tight if .
Case 1: no proper non-empty subset of is tight, so for every non-empty . Pick any and any neighbour — one exists since — and delete both. In with left part , every non-empty has
Case 2: some non-empty is tight, . Let be the bipartite graph induced on . For we have , so Hall's condition holds in and, since , induction gives a matching saturating ; as , it saturates as well.
Let be induced on . For ,
Intuition. Hall's condition is obviously necessary — boys who between them know only girls cannot all be married — and the content of the theorem is that this is the only obstruction. The proof explains why by splitting on whether the graph is slack everywhere or tight somewhere. If there is slack, any single edge can be committed without regret, because removing one right-vertex cannot break a condition that had room to spare. If some set is tight, that set and its neighbourhood form a closed sub-problem which must be solved on its own terms, and the rest of the graph never needed those vertices anyway.
Corollary 10.38 (The deficiency form). For a bipartite graph with parts and ,
Proof. Write . For the upper bound : let attain the maximum and let be any matching. The edges of meeting end in and are pairwise disjoint, so at most vertices of are covered, leaving at least vertices of exposed; hence .
For the lower bound, form by adding new vertices to , each joined to every vertex of . For any ,
Corollary 10.39 (Regular bipartite graphs have perfect matchings). Every -regular bipartite graph with has a perfect matching, and its edge set decomposes into perfect matchings.
Proof. Counting edges incident with in two ways gives , so . For , the edges leaving all land in , which receives at most edges in total; hence and . Theorem Hall's marriage theorem gives a matching saturating , which is perfect since . Deleting it leaves a -regular bipartite graph, and induction on finishes the decomposition.∎
Example 10.40 (Marrying off a constrained set). Let , with , , . Decide whether a saturating matching exists, and if so construct one.
Solution. Check every subset. Singletons: , , , all at least . Pairs: has size ; has size . The whole set: . Hall's condition holds, so a saturating matching exists.
To build one, follow the proof: is tight (), so solve that sub-problem first. Inside it must take and must take . The rest of the graph is against , giving . So , a perfect matching.
Had been as well, then would have : deficiency , and by Corollary The deficiency form, .□
Hall's theorem is a statement about when a matching of a given size exists. König's theorem is the corresponding statement about how big a matching is, and the two are logically interchangeable.
Theorem 10.41 (König). In a bipartite graph , : the maximum size of a matching equals the minimum size of a vertex cover.
Proof. The inequality is Proposition Weak duality, and holds in every graph. For the reverse, let and let attain it, so . Put
Theorem 10.42 (König implies Hall). Assume König's theorem. Then a bipartite graph satisfying Hall's condition has a matching saturating ; that is, Hall's theorem follows.
Proof. Let satisfy for all , and let be a minimum vertex cover, written with and . Every edge leaving must be covered on the right, so
The two theorems are thus equivalent over the trivial facts, and each has a third equivalent in Dilworth's theorem on chain covers of a poset and a fourth in the integral max-flow min-cut theorem. Section Algorithms, Blossoms and the Min–Max Pattern collects the pattern; chapter Flows and Duality proves that the pattern is LP duality applied to a matrix that happens to be totally unimodular.
Pitfall. König's theorem is bipartite. In the triangle we have but , and in general can be as large as — take any graph and note that the endpoints of a maximum matching always form a vertex cover. The correct non-bipartite replacement is not a patched-up König but the Tutte–Berge formula, which pays for odd components rather than for vertices.
10.6Algorithms, Blossoms and the Min–Max Pattern
Berge's theorem turns "is this matching maximum?" into "does an augmenting path exist?", and everything algorithmic follows from making that search efficient. In the bipartite case the search is a breadth-first scan; in general graphs it needs one genuinely new idea.
Method 10.44 (Augmenting-path algorithm for bipartite matching). Input: bipartite with parts .
- Start with .
- While some is exposed: search for an -augmenting path from by alternately following non-matching edges out of and matching edges out of , marking visited vertices.
- If such a path reaches an exposed vertex of , augment along it; if the search exhausts without reaching one, mark permanently unmatchable and continue.
- Return .
Each successful search adds one edge, so there are at most augmentations, each costing : total .
Correctness is exactly Berge's theorem. The loop exits only when no augmenting path starts at any exposed left vertex, and in a bipartite graph every augmenting path has one endpoint in each part, so that is the same as having no augmenting path at all. Step 3 is safe because a left vertex that cannot be augmented from now can never be augmented from later — a fact that needs the bipartite structure and is the reason the same shortcut is illegal for general graphs.
Theorem 10.45 (Hopcroft–Karp). A maximum matching in a bipartite graph can be computed in time.
Proof (Sketch — the phase construction is quoted). Instead of augmenting along one path at a time, each phase finds a maximal set of vertex-disjoint shortest augmenting paths and augments along all of them at once, in time via one layered breadth-first search plus one depth-first sweep. Two facts drive the bound. First, the length of a shortest augmenting path strictly increases from phase to phase — a consequence of Lemma Symmetric difference of two matchings applied to the current matching and a maximum one. Second, if the current matching satisfies , then contains vertex-disjoint augmenting paths, so the shortest has length at most . Running phases therefore forces the shortest augmenting path past length , after which at most augmentations remain. The counting argument is standard; the phase construction is the part that needs care and is given in Schrijver, §16.∎
Weights change the problem qualitatively: greed is unavailable, since matchings do not form a matroid, and the right generalisation of a vertex cover becomes a weighted cover.
Definition 10.46 (Feasible potential). Let be bipartite with parts , , and edge weights . A feasible potential is a function with
Theorem 10.47 (Egerváry's min–max theorem for the assignment problem). Let with weights . Then
Proof. For weak duality, let be a perfect matching and a feasible potential. Every vertex is covered exactly once by , so
For equality, it suffices to exhibit a feasible and a perfect matching with every edge of tight, since then the inequality above is an equality throughout. Recipe The Hungarian algorithm constructs exactly such a pair and terminates, which supplies the missing direction.∎
Method 10.48 (The Hungarian algorithm). Input: with weights .
- Initialise for and for . This is feasible.
- Find a maximum matching in the equality subgraph using Recipe Augmenting-path algorithm for bipartite matching.
- If is perfect, stop and return : by Theorem Egerváry's min–max theorem for the assignment problem it is of maximum weight, certified by .
- Otherwise let be exposed in , let be the set of vertices reachable from by -alternating paths in , and set Decrease by on and increase it by on . The potential stays feasible, every matching edge stays tight, and at least one new tight edge leaves . Return to step 2.
Each update either enlarges or enables an augmentation, so there are updates and the algorithm runs in .
Example 10.49 (A assignment). Three workers are to be assigned to three jobs with profits
Solution. Initialise , , and ; the total is . The tight edges are , , — the row maxima — and those three edges already form a perfect matching of weight
Sanity check. The six perfect matchings have weights , , , , , . The maximum is , as certified.□
Pitfall. The initial potential is feasible only because it was built from row maxima; starting from is feasible only when all weights are non-positive. And the certificate is the whole point of the method: an assignment found by any heuristic is worth nothing until some feasible of equal total is produced alongside it. The Hungarian algorithm is best understood not as a search for a matching but as a search for the pair.
In non-bipartite graphs the augmenting-path search breaks, and the reason is precise: an alternating walk can return to a vertex it has already used, along an odd cycle.
Definition 10.50 (Blossom). Let be a matching. A blossom is an odd cycle of length containing exactly edges of , reached from an exposed vertex by an -alternating path of even length (its stem). The unique vertex of not covered by is the base.
Theorem 10.51 (Edmonds' blossom contraction lemma). Let be a blossom for with the stem already switched so that the base is exposed, and let be the graph with contracted to a single vertex, carrying the matching . Then has an -augmenting path if and only if has an -augmenting path.
Proof (Sketch — Edmonds' case analysis is quoted). The easy direction lifts a path in to : when the path enters the contracted vertex, re-enter the cycle at the entry point and walk around in whichever of the two directions makes the parity come out right — possible precisely because has odd length, so one way round is even and the other odd. The converse requires showing that an augmenting path in can be rerouted to meet in at most one contiguous stretch; the careful case analysis is Edmonds', and the resulting algorithm — contract a blossom whenever the search finds one, recurse, then lift — runs in , improvable to . Schrijver, §24, has the full argument.∎
Intuition. Why odd cycles and only odd cycles? An even alternating cycle is harmless: it contributes equally many matching and non-matching edges, so it can never be the component that creates an imbalance — which is exactly what Lemma Symmetric difference of two matchings says. An odd cycle carries one unmatched vertex that can sit at either of two places depending on the direction you traverse it, so a naive search that labels each vertex once as "reached by an even path" or "reached by an odd path" labels a blossom vertex inconsistently. Contracting the blossom removes the ambiguity by refusing to distinguish its vertices at all. Bipartite graphs have no odd cycles, which is the one-line reason the bipartite algorithm needs none of this.
The structural counterpart of König for general graphs is Tutte's theorem. Write for the number of connected components of with an odd number of vertices.
Theorem 10.52 (Tutte's 1-factor theorem). A graph has a perfect matching if and only if
Proof. We prove necessity, and state that sufficiency holds. Suppose is a perfect matching and let . Each odd component of has an odd number of vertices, so cannot match all of internally: at least one vertex of is matched by to a vertex outside , and the only vertices outside adjacent to lie in . Distinct odd components send their edges to distinct vertices of , because is a matching. Hence .
Sufficiency is the substantial half. It is proved by taking a maximal counterexample and analysing the set of vertices adjacent to all others; the argument is Lovász's short proof, and it is an induction rather than a construction. It is stated here and not proved.∎
Theorem 10.53 (Tutte–Berge formula). For every graph on vertices,
Proof. The inequality , which is the direction one uses to certify optimality, follows exactly as in Tutte's theorem. Fix and a matching . Every odd component of leaves at least one vertex exposed unless one of its vertices is matched into , and at most components can be served that way, so at least vertices are exposed. Hence for every , which rearranges to the stated bound.
Equality is Berge's refinement of Tutte's theorem and follows from it by adding universal vertices, exactly as Corollary The deficiency form was derived from Hall's theorem. That deduction is routine; Tutte's sufficiency, on which it rests, was stated without proof above.∎
Stand back and the shape of the chapter is a single recurring theorem.
| max (a packing) | = | min (a cover) | where |
|---|---|---|---|
| matching | | vertex cover | bipartite (König) |
| matching | | | any graph (Tutte–Berge) |
| saturating matching exists | | no deficient set | bipartite (Hall) |
| common independent set | | | two matroids (Edmonds) |
| assignment weight | | feasible potential | bipartite, weighted (Egerváry) |
In every row the easy inequality is a counting argument of two lines, and in every row the hard inequality is proved the same way: run an augmenting search, and when it fails, read the optimal dual object off the set of vertices the search could reach. That is not a coincidence and it is not five separate theorems. Each of these max objects is the optimum of an integer program whose linear relaxation has integral vertices, and each min object is the optimum of the dual program; LP duality then supplies the equality, and total unimodularity supplies the integrality. Chapter Flows and Duality makes that statement precise, and the min–max theorems of this chapter become corollaries of one theorem about polyhedra.
Pitfall. The pattern does not extend by wishful thinking. Maximum independent set has no matching min–max partner in general graphs — the corresponding LP has fractional vertices of value and the problem is NP-hard. What distinguishes the rows above is integrality of the relaxation, not the elegance of the statement. When you meet a new packing problem, the question to ask is whether its constraint matrix is totally unimodular, not whether the min–max "ought" to hold.
- Treating every hereditary family as a matroid. Downward closure is cheap; augmentation is not. is hereditary, has maximal sets of two different sizes, and defeats the greedy algorithm on the weighting , .
- Confusing circuits with bases. A circuit is a minimal *dependent* set; a basis is a maximal *independent* set. In the bases have two elements and the circuits have three.
- Assuming a matroid remembers where it came from. , so the same matroid is both graphic and uniform. Nothing in the axioms recovers the graph, and most matroids are not graphic — or even representable over any field, as the Vámos matroid shows.
- Believing greed extends to two matroids. Theorem *Greedy characterises matroids* is an exact characterisation: greed is optimal for all weights on *one* matroid and nowhere else. Matroid intersection is polynomial but needs augmenting paths in an exchange digraph, and three matroids is NP-hard.
- Running greedy without non-negative weights. With negative weights, "maximum-weight basis" and "maximum-weight independent set" differ, since a basis may be forced to include loss-making elements. Decide which you want before you sort.
- **Saying *maximal* when you mean *maximum*.** A maximal matching cannot be extended; a maximum matching is largest. In the maximal matching has half the size of the maximum one.
- **Looking for an augmenting *cycle*.** Only paths augment. By Lemma *Symmetric difference of two matchings*, an alternating cycle is even and contributes equally many edges of each matching, so switching along one changes nothing.
- **Checking Hall's condition only on singletons or only on itself.** The condition quantifies over *all* subsets, and the violating set is typically of intermediate size. With and , every singleton and the whole of pass while fails.
- Using König in a non-bipartite graph. has and . The general statement is the Tutte–Berge formula; the general algorithm needs blossoms.
- **Assuming forces a perfect matching.** Equal sides say nothing: , with has . Hall's condition, not cardinality, is the criterion.
- Reporting an assignment without its potential. An optimal assignment is only known to be optimal when a feasible potential of equal total accompanies it; that pair is what the Hungarian algorithm actually computes.