A matching in a graph is a set of edges of an undirected graph with no shared endpoints: each vertex has capacity for at most one selected edge. It describes simultaneous compatible pairs, such as jobs assigned to distinct available workers, or tasks each occupying two resources that cannot be shared. The empty set is a valid matching in a graph.[ref]
Graph Theory by Reinhard Diestel. Matching, Covering and Packing, opening paragraph, printed p. 1: independent edges and matchings
For a finite simple graph , write when is selected and otherwise. The vertex capacity constraint is exactlyThese are constraints on a discrete selection, not a requirement that every vertex be used. A matching in a graph with matching saturation of all vertices is a perfect matching; an unmatched vertex in a matching uses none of its capacity.
The objective must be specified separately. A maximum cardinality matching selects as many edges as possible; a maximum-weight matching selects the greatest total benefit; a minimum-weight perfect matching minimizes cost while requiring every vertex to be paired. A maximal matching only says that no additional edge fits alongside the current choices. The four-vertex path graph below separates these notions: choosing the middle edge blocks both outer edges, yet replacing it by those two edges pairs more vertices.
This model is useful because conflicts are local at vertices, while the quality of a selection can depend on coordinated changes along a whole augmenting path in a matching. A greedy matching gives a quick feasible selection; Berge's theorem explains when searching for such changes has reached a maximum cardinality matching. Repeating the pairing problem over time leads instead to proper edge colouring, where each time slot is a matching in a graph.
For the degree-constrained linear programming relaxation of a matching in a graph, retain precisely the edges with fractional coordinates. In a bipartite graph, an even graph cycle in this subgraph permits alternating positive and negative perturbations preserving all vertex sums. If the subgraph is a forest, use a graph path between two tree leaves: its endpoints have positive slack and its internal sums remain unchanged. Either perturbation expresses the original feasible point as the midpoint of two distinct feasible points. Hence a fractional feasible point cannot be an extreme point, proving integrality of all extreme points of the bipartite degree relaxation.
A matching in a graph on a rooted tree has the sibling-support condition if every unmatched non-root vertex has its parent matched to one of its siblings in a rooted tree. This is the properness condition used here. The root has no parent, so either exempt an unmatched root or require it to be matched in a nontrivial instance; the unmatched-vertex bound for a proper tree matching holds under either convention. Properness is stronger than being maximal: on the path rooted at , selecting only gives a maximal matching in a graph, but unmatched has parent matched upward rather than to a sibling of .
For a proper matching in a rooted tree, the number of unmatched vertices in a matching does not exceed the number of leaves of a rooted tree. From each unmatched vertex, build a downward path: at an internal current node that is unmatched or matched upward, every child must be matched downward to one of its own children, or properness would fail. Follow a child and its matching partner, then repeat. The path terminates at a leaf and contains no other unmatched vertex. Two such downward paths cannot meet, since then one unmatched starting point would lie on the other's path. Their distinct endpoints give the required injection. No maximum-size assumption is needed.
For a bipartite graph with bipartition and nonnegative integer bounds , a bipartite b-matching is an edge subset whose degree of a vertex is at most at each . Taking gives a matching in a graph. To maximize , build a flow network with arcs of flow network edge capacity for , arcs of flow network edge capacity one for , and arcs of flow network edge capacity for . The integral max-flow theorem gives an integral optimum. Select precisely the middle arcs with flow one. Flow conservation identifies their endpoint degrees with the outside arc flows, and the flow value is . Conversely, every such edge subset supplies a feasible flow of that value. This proves the reduction and its optimality.
If a finite graph has no isolated vertex, its minimum edge cover cardinality and matching number sum to its number of vertices.
Proof. Start with a maximum cardinality matching . Its unmatched vertices in a matching form an independent set, since an edge between two of them could be added. Add one incident edge for each such vertex. They are distinct, giving an edge cover of size .
Conversely, in any inclusion-minimal edge cover , every edge has an endpoint of vertex degree one in ; otherwise it could be removed. Thus each component is a star graph: two vertices of vertex degree at least two in one component would produce a graph path containing an edge with both endpoints of vertex degree at least two. If there are components, . Selecting one edge from each star graph gives a matching in a graph of size , so and . A minimum-cardinality edge cover is inclusion-minimal, completing the proof. The constructive first half also gives a polynomial-time algorithm once a maximum cardinality matching is available.
A finite bipartite graph of positive maximum degree has a matching in a graph covering every vertex of vertex degree . To cover the vertices of maximum degree in one side , apply Hall's marriage theorem to that subset: for each subset of it, double counting gives , where is its graph neighbourhood. Construct the corresponding matching in a graph for the other side, then use the union of two matchings to cover both specified subsets simultaneously.
In the spanning subgraph formed by the union of two matchings in a graph , every vertex has vertex degree at most two. A common edge is an isolated two-vertex connected component of a graph. Every other nontrivial connected component of a graph is a graph path or an even graph cycle, with the edges alternating between the two matchings in a graph.
Suppose the original graph is a bipartite graph with vertex sets , covers a specified subset , and covers a specified subset . Their union contains a matching in a graph covering . On an even graph cycle, either alternating choice covers every vertex. On an odd-length graph path, the larger alternating choice covers every vertex. On an even-length graph path, both endpoints lie in the same side: choose if they lie in , or if they lie in . Every required endpoint is covered by that choice, and every internal vertex meets both choices. Select each common edge as well; isolated vertices are not in . Different connected components of a graph do not interfere.
A vertex is an unmatched vertex in a matching if no edge of is incident to it. It is also called free or exposed, always relative to the specified matching in a graph: changing can change which vertices are free. The endpoints of an augmenting path in a matching must be distinct unmatched vertices in a matching before the change.
A matching in a graph saturates a specified vertex set when every vertex of is incident to one selected edge. Exactly one selected edge meets each such vertex, since matching edges have disjoint endpoints. Vertices outside may remain unmatched. A perfect matching saturates the entire vertex set; Hall's marriage theorem tests matching saturation of a specified side in a finite bipartite graph.
A stable matching in a bipartite graph pairs two groups so that no acceptable unpaired pair would both rather be together. Give a finite bipartite graph a strict preference ordering at each vertex over its neighbours of a vertex. An edge means that both endpoints regard the pair as acceptable; every acceptable partner ranks above being unmatched. Lists may be incomplete, and and may have unequal cardinalities. A matching in a graph is stable when it has no blocking pair in stable matching.
Write for the partner of a vertex , or if is an unmatched vertex in a matching. An unused edge is a blocking pair in stable matching precisely whenwhere denotes the strict preference at and ranks below every neighbour of a vertex. Both inequalities matter: wanting a different partner alone cannot upset a stable matching. A stable matching need not be a perfect matching; the Gale-Shapley algorithm still finds one with incomplete lists and unequal sides.
Here is an original example on the complete bipartite graph , with and . Read each row from best to worst:There are two stable matchings,For , the only unpaired partners preferred by left vertices are wanting and wanting . But prefers its partner to , and prefers its partner to . Hence neither is a blocking pair in stable matching. For , the left vertices want with , with or , and with or . In every case the right vertex prefers its current partner: has , has , and has .
By contrast, is a perfect matching with a blocking pair in stable matching : prefers to , while prefers to . The abandoned partners need not agree to the change; stability tests the incentives of the two endpoints of the unused edge.
There are permutations of right partners. The following table lists every blocking pair in stable matching for each perfect matching; the middle column gives the partners of in that order:This exhausts the stable matchings: any nonperfect matching in a graph here leaves an unmatched vertex on each side, and those two form a blocking pair in stable matching because every cross-pair is acceptable. Notice that every left vertex prefers and every right vertex prefers . Stability can accommodate opposing interests without selecting a single universally preferred outcome.
A stable matching addresses the possibility of mutually beneficial departures. Its definition contains no numerical total social benefit or maximum-weight matching objective. For example, assigning benefit to each edge of and zero to every other edge makes the unique maximum-weight matching, yet still blocks it under the displayed preference relations. Such external benefits need not represent participants' rankings.
If the endpoints of an edge rank one another last and one stable matching in a bipartite graph contains that edge, every stable matching contains it. In the symmetric difference of two stable matchings, preference comparisons propagate along alternating paths: if a vertex prefers its new partner, that partner must prefer its old partner to avoid blocking the old matching. An alternating path cannot end unmatched on the preferred side, so the component is an alternating cycle, on which the two parts prefer opposite matchings. A mutual-worst edge absent from the new matching would make both its endpoints prefer the new matching, contradicting this propagation.
The Gale-Shapley algorithm constructs a stable matching by letting one side propose and the other hold its best offer so far. The word "deferred" is essential: a held proposal is tentative and can be replaced. David Gale and Lloyd Shapley presented this construction in their 1962 paper, College Admissions and the Stability of Marriage, §3, printed pp. 12–13; §4 extends it to college quotas and unacceptable pairs.
For the one-partner bipartite graph model, designate as proposers and as receivers:
- Start with the empty matching in a graph. Each proposer keeps a pointer to its first untried acceptable partner.
- Choose an unmatched vertex in a matching whose list is not exhausted. It proposes to its highest-ranked untried neighbour of a vertex and advances its pointer permanently.
- If holds nobody, it holds . Otherwise compares with its currently held proposer, keeps the one it prefers, and rejects the other. A displaced proposer becomes unmatched and may propose again later.
- Stop when every unmatched proposer has exhausted its list. The held pairs are the output matching in a graph.
Held proposers wait; only unmatched proposers act. A receiver can replace its held partner, whereas a proposer never tries the same edge twice. Isolated vertices simply remain unmatched. These rules also describe incomplete acceptable lists and unequal sides without adding fictitious acceptable partners.
For the preference lists under stable matching, choose available proposers in queue data structure order, initially , adding rejected proposers at the end. The proposals are , , , , . At the fourth proposal, replaces its held by because . This frees to try , producing .
Five proposals in the Gale-Shapley algorithm: Y replaces a tentative partner before the final stable matching
. Details. Reverse the proposing side. Starting in the order , the proposals are , , , . Now rejects because it already holds . The result is . Thus the choice of proposing side can change the output even with strict preferences and complete lists.
Why does the procedure work? Each edge receives at most one proposal, so at most proposals occur. At all times, the held edges form a matching in a graph, and each receiver holds its favourite proposer among all proposals received. A receiver's held partner can only improve according to its strict preference. If a proposer prefers to its final partner, or ends unmatched while is acceptable, it must already have proposed to . A rejection means then held someone better, and its final partner is at least as good. Such an edge cannot be a blocking pair in stable matching. This covers every possible blocking pair in stable matching, proving stability at termination.
With a queue data structure of unmatched proposers, a next-choice pointer for each list, and constant-time receiver-rank lookups, each proposal takes constant work. Using Big O notation, the time complexity is including initialization, provided list construction and rank preprocessing also take . Edge-indexed ranks with cross-referenced list entries, or expected constant-time hash lookups, allow sparse storage proportional to . Repeatedly scanning a receiver's preference list to compare offers would lose this bound. For complete lists with vertices per side, and the bound is . Initializing full rank tables itself costs time and space, even when only a sparse set of pairs is acceptable.
The Gale-Shapley algorithm does more than establish existence: with strict preferences, its output is a proposer-optimal stable matching.[ref]
College Admissions and the Stability of Marriage by David Gale and Lloyd Shapley. §5, printed p. 14, Theorem 2: applicant optimality and the rejection induction
It is also a receiver-pessimal stable matching, as proved below. Both qualifications compare partners across stable matchings.For fixed strict preferences, a proposer-optimal stable matching gives each proposer its best partner obtainable in any stable matching, with unmatched ranked last. The Gale-Shapley algorithm achieves all these individual optima simultaneously. In the worked example, gives partners ranked , respectively; the alternative gives them ranks .
Suppose a first rejection of a pair belonging to some stable matching occurs when rejects for . Every partner prefers to has already rejected it, so none can be its partner in . If , then prefers to , while prefers to : a blocking pair in stable matching, a contradiction. Hence no rejected pair is stable, and each proposer receives its best stable partner. Under strict preferences this also makes the outcome independent of proposal order.
For fixed strict preferences, the same output of the Gale-Shapley algorithm gives each receiver its worst partner obtainable in any stable matching, treating unmatched as last. "Worst" is restricted to stable possibilities: a receiver might still receive its favourite acceptable partner if every stable matching assigns it that partner. Reversing the proposing side gives receivers their best stable partners instead.
For a short proof, let be a proposer-optimal stable matching and any other stable matching. If a receiver preferred to , then proposer optimality would make prefer to , since the partners differ and preferences are strict. The pair would block . Therefore no receiver prefers its partner in to its partner in . In the worked example, right-side ranks in are for , whereas gives them . Neither outcome is universally best for both sides.
An acceptable unused edge whose endpoints both prefer each other to their partners in a matching in a graph, treating every acceptable partner as preferable to being unmatched. A stable matching has no such edge. In the worked example, blocks even though already has its first choice.
In a graph with vertices, a near-perfect matching in a graph has edges and exactly two unmatched vertices.
The coefficient counts matchings in a graph with edges. For a bipartite graph with vertices on each side, counts perfect matchings and equals the permanent of a matrix of its bipartite adjacency matrix. Positive activity makes the normalizing constant of the weighted matching Markov chain.
For , expand the expectation under the weighted matching Markov chain stationary weights to obtain the displayed identity. If the largest matching in a graph has edges and , the observable lies in . Its sample mean has controlled error by the Hoeffding inequality. A product of ratios, each estimated to relative accuracy , approximates the full ratio to relative accuracy .
An alternating path in a matching is a graph path whose successive edges alternate between membership in and membership outside . Here graph paths have no repeated vertices. Alternation alone does not make a graph path an augmenting path in a matching: its endpoints must both be unmatched vertices in a matching. For example, relative to in the six-vertex path graph, alternates but has matched endpoints; toggling just those three edges loses one selected edge.
An augmenting path in a matching is a nonempty alternating path in a matching with distinct endpoints that are both unmatched vertices in a matching. Its first and last edges lie outside . Thus it has unselected edges and selected edges, for some . Taking the symmetric differenceremoves the selected edges on and inserts its unselected edges. Each internal vertex exchanges one selected edge for another; each endpoint gains its first selected edge. All choices away from stay in place, so is a matching in a graph with .[ref]
Graph Theory by Reinhard Diestel. Matching, Covering and Packing, §2.1, printed p. 2: alternating paths, augmenting paths and symmetric difference
For an explicit repair, let the path graph have vertices in that order and start withThe endpoints and are initially unmatched vertices in a matching. Along the edges are outside, inside, outside, inside, outside . Remove and , then add together:This raises the cardinality from two to three and gives a perfect matching. Six vertices allow at most three disjoint pairs, so it is also a maximum cardinality matching. The initial is already a maximal matching: every unused edge touches a matched vertex. Augmentation succeeds because it can replace earlier choices instead of only adding to them.
The augmenting path in a matching on P₆ replaces two selected edges by three using symmetric difference
. Details. One unused edge joining two unmatched vertices in a matching is the shortest possible augmenting path in a matching. Longer augmenting paths in a matching reassign several partners, explaining why a stalled greedy matching need not be optimal. For edge benefits , the change in total benefit iswhich need not be positive even though the cardinality increases. A maximum-weight matching therefore needs a different optimality test. In an assignment equality graph an augmenting path in a matching moves toward a perfect matching while preserving zero reduced costs on matched edges; this is the setting used by the Hungarian algorithm.
For a finite simple graph and a matching in a graph , is a maximum cardinality matching if and only if has no augmenting path in a matching relative to . The graph need not be a bipartite graph, and the assertion concerns cardinality, not edge benefits.[ref]
Two theorems in graph theory by Claude Berge. Claude Berge, Two theorems in graph theory, printed p. 842: finite unoriented graph and Problem 3; printed p. 843, Theorem 1: maximum matching and absence of an alternating chain between neutral points
The criterion turns a global comparison with every competing matching in a graph into a search for one repair. Starting from any matching in a graph, repeatedly find and toggle an augmenting path in a matching. Each step adds one selected edge, so finiteness gives termination after at most steps; absence of any further augmenting path in a matching certifies maximum cardinality. This is an optimality criterion, not by itself a bound on the work needed to find each graph path.
For a short proof outline, an augmenting path in a matching immediately contradicts maximum cardinality. Conversely, if another matching in a graph has , consider the subgraph whose set of edges is . Its vertices have degree of a vertex at most two; its nontrivial connected components are graph paths and even cycles in a graph, alternating between the two matchings in a graph. A cycle in a graph contributes equal numbers from each. Hence some graph path contributes one more edge from than from and starts and ends with edges from . Its endpoints are unmatched vertices in a matching relative to , yielding the required augmenting path in a matching.
The two sides have vertices each. Given a nonperfect matching in a graph, choose unmatched vertices on opposite sides. An unmatched neighbour of either supplies a one-edge augmenting path in a matching. Otherwise their neighbours are matched; the matched left vertices corresponding to and the set have total size greater than , so they intersect. This supplies the alternating path in a graph with in the matching in a graph. Repeated augmentation produces a perfect matching.
Choose such an augmentation deterministically. Its reverse is specified by at most four vertices, giving at most preimages for a matching in a graph of the next size. Thus the matching generating function coefficients satisfy .
A perfect matching is a matching in a graph that covers every vertex exactly once. Its edges have no shared endpoints, and every vertex is an endpoint of one selected edge. It is useful when a collection must be divided into disjoint pairs with no element left over.
In a bipartite graph with equally many vertices on its two sides, a perfect matching can assign every person one allowed job and every job one person. The example under permanent of a matrix has three people and three jobs, with exactly three valid assignments. The blue edges below show those three perfect matchings; a crossing in the drawing is not an extra vertex.
Every selected edge covers two vertices, so a graph with an odd integer number of vertices has no perfect matching. An even integer number is necessary but does not guarantee existence: an isolated vertex cannot be covered. A perfect matching also need not be unique. For example, the complete bipartite graph has two perfect matchings, corresponding to the two ways of assigning two people to two jobs.
Counting all perfect matchings is a different question from finding one. For a zero-one biadjacency matrix of a balanced bipartite graph, the count is its permanent of a matrix. The nonzero determinant criterion for a perfect matching supplies an existence test, but cancellation means that a zero determinant does not rule one out.
A finite graph has a perfect matching if and only if the displayed inequalities hold, where counts the connected components of a graph with an odd integer number of vertices. The theorem is associated with William Thomas Tutte.[ref]
Necessity has a direct counting proof: each such component of must send at least one edge of a perfect matching to , and different components must use different vertices of . The sufficiency direction is the substantive content of the theorem. The criterion is useful because vertex degree and parity estimates can prove existence without constructing the perfect matching, as in the perfect matching theorem for a cubic graph with at most two bridges.
A vertex on one side of a balanced bipartite graph is flexible if every incident edge lies in a perfect matching. The strict Hall marriage theorem inequalities for nonempty proper subsets imply flexibility of every vertex: after forcing an edge, removal of its ends loses at most one neighbour from each remaining set. If a perfect matching exists without the strict condition, choose a minimal nonempty tight set. Its induced balanced graph has the strict condition internally, and each internal matching extends using the original matching outside that set. Thus at least one flexible vertex always exists.
A minimum-weight perfect matching pairs every vertex exactly once while minimizing total edge weight. General weighted perfect matching has polynomial-time algorithms. In the Christofides algorithm, it corrects precisely the odd-degree vertices of a minimum spanning tree. Alternating edges of a cyclic order on an even number of vertices give two perfect matchings; the cheaper one costs at most half that cycle's cost.
A one-factorization partitions every edge of a graph into perfect matchings. Each matching uses every vertex exactly once. A total of synthemes is precisely a one-factorization of the complete graph on six points.
A maximal matching is a matching in a graph to which no extra edge can be added while retaining all current selected edges. Equivalently, no edge joins two unmatched vertices in a matching; those vertices form an independent set. Every maximum cardinality matching is a maximal matching, but the converse fails.
Take the path graph with vertices and edges . A greedy algorithm that first selects the middle edge produces . Both remaining edges touch a matched vertex, so this size-one matching in a graph is maximal. Yet has two edges. No matching in a graph on four vertices has more than two edges, so is a maximum cardinality matching. The two remaining free vertices of , namely and , are not adjacent; that does not prevent a longer augmenting path in a matching from joining them.
Choosing the middle edge of P₄ gives a maximal matching of size one; the outer edges give a maximum cardinality matching of size two
. Details. Maximality is useful as a quick stopping rule and a modest guarantee. For any maximal matching and maximum cardinality matching in a finite simple graph, every edge of touches an endpoint of an edge of . Assign it to one such edge of . Since has disjoint endpoints, each edge of receives at most two assignments, proving . The P₄ example reaches equality. Thus maximality guarantees at least half the largest cardinality, but says nothing comparable about arbitrary edge benefits. Its selected endpoints also form a vertex cover, as explained under vertex cover.
A greedy matching starts with the empty matching in a graph, scans all edges in some order, and selects an edge exactly when both endpoints are unmatched vertices in a matching. For a finite graph, a complete scan returns a maximal matching: a rejected edge had a matched endpoint, which stays matched thereafter. Stopping before all edges have been considered need not give maximality. Changing the order can change the result; on P₄, middle-first gives one pair, whereas outer-first gives two. A greedy algorithm of this form never revisits its choices, while an augmenting path in a matching does.
For a finite graph , the matching number isIt is the cardinality of a maximum cardinality matching. The vertex capacity constraint gives . The worked path graph examples have and . A perfect matching reaches ; the empty graph has matching number zero.
A maximum cardinality matching is a matching in a graph with as many edges as any matching in a graph of the same graph. It has cardinality , the matching number, and need not be unique or be a perfect matching. For example, any single edge of a triangle in a graph is a maximum cardinality matching, but leaves one vertex unmatched. Berge's theorem characterizes these optima by the absence of an augmenting path in a matching.
Assign each edge a real benefit . A maximum-weight matching maximizes over all matchings in a graph ; the empty matching in a graph is allowed. Setting every recovers a maximum cardinality matching, but otherwise the objectives can disagree.
On the same path graph , give the middle edge benefit and each outer edge benefit . The matching in a graph has total benefit , while the two-edge matching in a graph has total benefit . Thus the smaller choice is the unique maximum-weight matching. If instead the requirement is to find a maximum cardinality matching and then maximize benefit among those, the outer edges must be chosen. Requiring a perfect matching before optimizing cost is another distinct problem, covered by minimum-weight perfect matching. With negative benefits a maximum-weight matching can even be empty, so it need not be a maximal matching.
For a finite graph without an isolated vertex and with nonnegative edge weights, put and let attain this minimum. Define savings and baseline . A maximum-weight matching with weights , allowing arbitrary cardinality, gives a minimum-weight edge coverIt replaces separate cheapest coverage of two endpoints by a shared edge when doing so saves enough weight. Savings can be negative even though original costs are nonnegative; such edges need not be selected.
Proof. The construction covers all vertices. Duplicate selected edges are counted once, so nonnegative weights give . Take an optimal edge cover and delete redundant edges to make it inclusion-minimal without increasing cost. Its components are star graphs, by the argument for the edge cover and matching identity. Select one edge from each component to obtain a matching in a graph . A component with center , selected leaf and other leaves contributes to , at most its total edge weight since . Thus . Maximizing giveswhich proves both the construction and the displayed identity, including zero-weight cases. One call to a general-graph maximum-weight matching polynomial-time algorithm suffices, together with linear-time preprocessing. Choosing a maximum cardinality matching under these modified weights would impose an unnecessary constraint and can spoil the reduction.[ref]
Maximum-weight matching documentation by NetworkX. max_weight_matching, maxcardinality=False, and Notes on polynomial running time
For nonnegative weights on a finite graph, scan edges in nonincreasing weight order, selecting each when it shares no endpoint with an already selected edge. This greedy matching is a factor-two approximation algorithm for maximum-weight matching.
Proof. Charge each optimal edge to itself if selected, and otherwise to an earlier selected edge that blocked it. The receiving edge weighs at least as much. Each selected edge receives at most two charges, since its two endpoints each meet at most one optimal edge. Summing proves the bound. Sorting takes time, followed by a scan that records which vertices are used.
The factor is sharp even for strictly positive weights. On a four-vertex path graph with consecutive weights , where , the greedy matching weighs and the optimal matching in a graph weighs two. Their ratio tends to two as . For infinitely many sizes, use disjoint copies with , . This example isolates the obstruction: a locally attractive edge can block two compatible edges.
For a finite bipartite graph with disjoint left and right vertex sets, Hall's marriage theorem characterizes when distinct allowed partners can be chosen for every left vertex. A matching in a graph with matching saturation of exists if and only if every subset satisfiesThe graph neighbourhood counts distinct right vertices, rather than edges or repeated choices. This is the Hall condition. Its failure supplies a concrete Hall obstruction. Necessity follows because the chosen partners of are distinct members of ; sufficiency is the surprising assertion that these collective counts rule out every obstacle.[ref]
The right side may be larger: matching saturation of leaves right vertices unmatched. Only when does a matching in a graph saturating automatically become a perfect matching. For a specified subset , apply the same criterion only to , using the induced subgraph on . The remaining left vertices need not be matched. The empty set gives ; if is empty, the empty matching in a graph suffices.
Consider a scheduling model with three unit-duration jobs and four available slots on one machine. Each job needs exactly one slot, each slot accepts at most one job, and the allowed slots areThe bipartite graph below admits , a matching in a graph saturating all jobs while leaving slot unused. It is not a perfect matching of the seven-vertex graph. A greedy choice initially blocks , but the augmenting path in a matching replaces by ; subsequent assignment of succeeds. A bad partial choice is not an impossibility certificate.
There are eight subsets of . Listing each graph neighbourhood makes the all-subset requirement explicit:
There are exactly two matchings in a graph saturating : and . Job forces slot , then job forces slot , leaving two choices for .
The Hall condition requires enough distinct neighbours for every subset of the specified left vertex set in a finite bipartite graph. Checking the whole left set establishes only one inequality. Checking singleton sets establishes only that each left vertex has positive degree of a vertex. Overlapping lists can pass both tests and still fail to admit matching saturation of the left side.
A Hall obstruction is a left subset with fewer distinct neighbours than vertices. At most members of can be matched, so at least must remain unmatched. The pigeonhole principle proves failure without enumerating every proposed assignment.
For a stronger counterexample than an isolated vertex, take and withEvery vertex has positive degree of a vertex, the sides have equal cardinality, and . Every two-vertex left subset also passes the Hall condition. Nevertheless has only , so rules out matching saturation of .
All sixteen left subsets can be checked by writing and if , otherwise . ThenOnly violates the Hall condition. Every matching in a graph uses at most two edges incident to and at most one incident to , so the matching number is three. There are exactly twelve size-three matchings in a graph: choose two of in three ways, assign them to in two ways, and choose or for . Thus the obstruction identifies the bottleneck: adding availability only for cannot help; allowing to use slot permits , a perfect matching.
In a unit-capacity assignment problem, left vertices represent demands and right vertices represent individually usable resources; an edge records compatibility. All constraints must be encoded by those allowed pairs and by using each resource at most once. Hall's marriage theorem decides feasibility. Costs belong to an additional mathematical optimization problem; precedence between jobs or requirements for consecutive slots need additional modelling.
The authored Notes on the design of a conference scheduler by David R. MacIver (Implementation, 7 August 2022) illustrates a Hall obstruction with four talks confined to three slots. With one talk per slot, that subset has size four and a graph neighbourhood of size three. An unused slot outside its graph neighbourhood does not remove the bottleneck. In the three-job example above, the same scheduling model instead has two complete assignments.
The allocation exercise in Graph Theory by Reinhard Diestel (Matching, Covering and Packing, printed p. 20, Exercise 9) asks for disjoint subsets of prescribed nonnegative integer sizes . Replace demand by left vertices with allowed resource set . Hall's marriage theorem gives exactly the conditionFor a numerical instance, let , , and . The separate demands and their combined demand fit, and works. Raising to two leaves both individual tests valid but demands four distinct resources from a set union of size three. This is the same collective obstruction with repeated demand vertices.
A system of distinct representatives for a finite indexed family of finite sets chooses one element per index, with all choices distinct. Form a bipartite graph with left vertex set , right vertex set , and edges whenever . Matching saturation of is precisely a system of distinct representatives. Hence Hall's marriage theorem says that such choices exist exactly when for every subset . Repeated equal sets still have separate indices and separate demands.
For sufficiency, take a matching in a graph of maximum size and suppose a left vertex is unmatched. Follow unused edges from left to right and matching edges back to the left. An unmatched reachable right vertex yields an augmenting path in a matching, contradicting maximal size. Otherwise let be the reachable left and right sets. Every member of is matched to a distinct member of , and every member of is reached this way. Since , we obtain , contradicting the Hall condition. Finiteness ensures that a maximum-size matching in a graph exists.
The alternative Hall induction through a tight set uses mathematical induction: a proper nonempty subset with splits off a balanced induced subgraph; without such a tight set, deleting one chosen edge's endpoints preserves the Hall condition on the smaller left side.
In the equal-part random bipartite graph with fixed edge probability , rule out empty rectangles of side and vertices with at least nonneighbors. A union bound gives the displayed asymptotic estimate. Small vertex sets satisfy Hall's condition by the degree bound; intermediate sets do so because their omitted-neighbor rectangle would contain a forbidden square; large sets meet every vertex in the other part. Thus Hall's marriage theorem gives a perfect matching asymptotically almost surely. This does not mean probability one at any finite size.
Two maximum-cardinality -separated subsets of a compact metric space have a bijection that moves each point by less than . Join to when their distance is below . If had fewer than neighbours, replacing these neighbours in by would create a larger separated set. The Hall marriage theorem therefore supplies a perfect matching. This allows empirical averages on a compact isometry group to be made approximately invariant without assuming a prior Haar measure construction.
In a finite bipartite graph, suppose every left vertex has positive degree and each edge joins vertices with from left to right. Then , so a matching covers the left side.
For finitely many Lebesgue measurable sets and nonnegative demands , pairwise disjoint measurable subsets with exist exactly when for every index subset . Necessity is additivity and monotonicity of Lebesgue measure. For sufficiency, partition the set union into membership cells , send flow from a source through demand vertices to cells with , then to a sink. Source capacities are , cell capacities are , and intermediate capacities are . Every cut of a flow network has capacity at least by the assumed inequalities. The max-flow min-cut theorem provides the allocations, and divisibility of Lebesgue measure turns each cell allocation into disjoint pieces. If , all can simply be empty.
For Hall's theorem, either every proper nonempty set has one excess neighbour and one deletes an arbitrary edge's endpoints, or a tight set with splits the problem into the induced graph on and its complement.
In a -regular bipartite graph, edge counting gives equal vertex-class sizes and . Hall's theorem therefore supplies a perfect matching.
If a -regular graph on vertices has a maximum matching of size , its unmatched vertices are independent. Counting their incident edges gives , and hence .
The disjoint union of triangles is -regular on vertices and has matching number , attaining the regular-graph lower bound .
Articles by others on the same topic
In graph theory, a **matching** is a set of edges in a graph such that no two edges share a common vertex. In other words, it is a way of pairing the vertices of a graph such that each vertex is included in at most one edge of the matching. Here's a more detailed explanation: 1. **Vertices and Edges**: A graph consists of a set of vertices (nodes) and a set of edges (connections between pairs of vertices).






