Introduction

A matching pairs up vertices along edges so that no vertex is used twice: assigning workers to jobs they are qualified for, students to projects, or tasks to processors. The central questions are how large a matching can be, when every vertex can be matched, and how matchings relate to other covering problems (vertex covers, edge covers, independent sets). Bipartite matching is solvable in polynomial time and has exact min-max theorems; these are the results developed in the sections that follow.

Prerequisites

Core concepts

Definitions

Let G=(V,E)G = (V, E) with n=∣V∣n = |V|.

  • A matching M⊆EM \subseteq E is a set of edges, no two sharing an endpoint. A vertex incident to an edge of MM is matched (saturated); otherwise it is unmatched (exposed).
  • MM is maximal if no edge of GG can be added to it (every edge of GG touches a matched vertex).
  • MM is maximum if no matching of GG has more edges. Its size is the matching number ν(G)\nu(G), also written α′(G)\alpha'(G).
  • MM is perfect if every vertex is matched; then ∣M∣=n/2|M| = n/2, so nn must be even.

Every maximum matching is maximal; a maximal matching need not be maximum. In the path a−b−c−da - b - c - d, {bc}\{bc\} is maximal (both other edges touch bb or cc) but {ab,cd}\{ab, cd\} is larger and perfect.

Maximal versus maximum bound: if MM is maximal, then ∣M∣≥ν(G)/2|M| \ge \nu(G)/2. Each edge of a maximum matching has an endpoint matched by MM, and each edge of MM has only two endpoints. So the greedy algorithm (add any edge whose ends are both free) is within a factor 2.

Maximal, maximum and perfect matchings; Hall's condition
Figure 1. Top: one graph with a maximal matching of size 2 and a perfect matching of size 3. Bottom: a bipartite graph in which three left vertices have only two neighbours, so Hall's condition fails and no matching saturates the left side.

Matching numbers of standard graphs

Graphν(G)\nu(G)Perfect matching?
Path PnP_n (nn vertices)⌊n/2⌋\lfloor n/2 \rfloorif and only if nn even
Cycle CnC_n⌊n/2⌋\lfloor n/2 \rfloorif and only if nn even
Complete graph KnK_n⌊n/2⌋\lfloor n/2 \rfloorif and only if nn even
Kr,sK_{r,s}min⁡(r,s)\min(r, s)if and only if r=sr = s
Star K1,sK_{1,s}1only for s=1s = 1
Hypercube QkQ_k, k≥1k \ge 12k−12^{k-1}yes
Petersen graph5yes

Counting perfect matchings. K2kK_{2k} has (2k−1)!!=(2k−1)(2k−3)⋯3⋅1=(2k)!2k k!(2k-1)!! = (2k-1)(2k-3)\cdots 3 \cdot 1 = \dfrac{(2k)!}{2^k\, k!} perfect matchings (match the lowest-numbered free vertex to any of the remaining, repeat). Kk,kK_{k,k} has k!k! (a perfect matching is a bijection between the sides). C2kC_{2k} has 2.

Augmenting paths and Berge's theorem

Given a matching MM, an MM-alternating path alternates between edges not in MM and edges in MM. An MM-augmenting path is an alternating path whose two ends are both unmatched. Swapping the edges along it (taking the symmetric difference M⊕PM \oplus P) gives a matching with one more edge.

Berge's theorem: MM is a maximum matching if and only if there is no MM-augmenting path.

This yields the standard algorithm: start with any matching and repeatedly find an augmenting path. For bipartite graphs, each search is a BFS or DFS, giving O(nm)O(nm) time; the Hopcroft-Karp algorithm improves this to O(mn)O(m\sqrt{n}). Bipartite matching also reduces to maximum flow. General graphs need Edmonds' blossom algorithm, still polynomial.

Hall's marriage theorem

Let GG be bipartite with parts XX and YY. For S⊆XS \subseteq X, let N(S)N(S) be the set of vertices adjacent to some vertex of SS.

G has a matching saturating every vertex of X  ⟺  ∣N(S)∣≥∣S∣ for every S⊆X.G \text{ has a matching saturating every vertex of } X \iff |N(S)| \ge |S| \text{ for every } S \subseteq X .

The condition is clearly necessary (the vertices of SS need distinct partners in N(S)N(S)); Hall's theorem says it is also sufficient. To show that no XX-saturating matching exists, exhibit one set SS with ∣N(S)∣<∣S∣|N(S)| < |S| (a Hall violator).

Corollaries.

  • If ∣X∣=∣Y∣|X| = |Y| and Hall's condition holds, the matching is perfect.
  • Every kk-regular bipartite graph with k≥1k \ge 1 has a perfect matching. (Counting edges: k∣S∣≤k∣N(S)∣k|S| \le k|N(S)|.) Repeating this, its edges split into kk perfect matchings.
  • Deficiency version: ν(G)=∣X∣−max⁡S⊆X(∣S∣−∣N(S)∣)\nu(G) = |X| - \max_{S \subseteq X}(|S| - |N(S)|), where the maximum includes S=∅S = \emptyset.

Covers and independent sets

ConceptDefinitionNumber
Independent setvertices, no two adjacentα(G)\alpha(G) = maximum size
Vertex coververtices touching every edgeβ(G)\beta(G) (also τ(G)\tau(G)) = minimum size
Matchingedges, no two sharing a vertexν(G)\nu(G) = maximum size
Edge coveredges touching every vertexρ(G)\rho(G) = minimum size (needs no isolated vertices)

Relations (for any graph GG on nn vertices):

  • SS is independent if and only if V−SV - S is a vertex cover, so α(G)+β(G)=n\alpha(G) + \beta(G) = n.
  • Gallai: if GG has no isolated vertices, ν(G)+ρ(G)=n\nu(G) + \rho(G) = n.
  • ν(G)≤β(G)\nu(G) \le \beta(G) always (each matching edge needs its own cover vertex), and β(G)≤2ν(G)\beta(G) \le 2\nu(G) (the ends of a maximal matching cover all edges).
  • Konig's theorem: if GG is bipartite, ν(G)=β(G)\nu(G) = \beta(G). This fails for odd cycles: ν(C5)=2\nu(C_5) = 2 but β(C5)=3\beta(C_5) = 3.
  • For bipartite GG without isolated vertices, combining the above, α(G)=ρ(G)\alpha(G) = \rho(G).

Finding α\alpha or β\beta is NP-hard for general graphs, but polynomial for bipartite graphs by Konig's theorem.

Worked examples

Example 1: Hall violator

Bipartite graph with X={x1,x2,x3,x4}X = \{x_1, x_2, x_3, x_4\}, Y={y1,y2,y3,y4}Y = \{y_1, y_2, y_3, y_4\} and edges x1y1,x1y2,x2y1,x3y1,x3y2,x4y3,x4y4x_1y_1, x_1y_2, x_2y_1, x_3y_1, x_3y_2, x_4y_3, x_4y_4. For S={x1,x2,x3}S = \{x_1, x_2, x_3\}, N(S)={y1,y2}N(S) = \{y_1, y_2\}, so ∣N(S)∣=2<3|N(S)| = 2 < 3. No perfect matching exists. Deficiency 3−2=13 - 2 = 1 is the largest, so ν=4−1=3\nu = 4 - 1 = 3 (for example x1y2,x2y1,x4y3x_1y_2, x_2y_1, x_4y_3).

Example 2: counting perfect matchings

K6K_6: 5⋅3⋅1=155 \cdot 3 \cdot 1 = 15 perfect matchings. K4,4K_{4,4}: 4!=244! = 24. K3,4K_{3,4}: none (sides unequal), but 4⋅3⋅2=244 \cdot 3 \cdot 2 = 24 matchings saturate the side of size 3.

Example 3: covers in a non-bipartite graph

For C7C_7: ν=3\nu = 3, β=4\beta = 4, α=3\alpha = 3, ρ=4\rho = 4. Checks: α+β=7\alpha + \beta = 7, ν+ρ=7\nu + \rho = 7, and ν<β\nu < \beta as for every odd cycle, whose maximum matching has ⌊n/2⌋\lfloor n/2\rfloor edges and minimum vertex cover has ⌈n/2⌉\lceil n/2\rceil vertices.

Example 4: augmenting path

In the path a−b−c−d−e−fa - b - c - d - e - f with M={bc,de}M = \{bc, de\}, the vertices aa and ff are unmatched, and a−b−c−d−e−fa - b - c - d - e - f alternates (non-MM, MM, non-MM, MM, non-MM). Swapping gives {ab,cd,ef}\{ab, cd, ef\}, a perfect matching.

Example 5: building a maximum matching by successive augmenting paths

Take the bipartite graph with parts X={u1,u2,u3}X = \{u_1, u_2, u_3\} and Y={v1,v2,v3}Y = \{v_1, v_2, v_3\} and edges u1v1u_1v_1, u1v2u_1v_2, u2v1u_2v_1, u2v3u_2v_3, u3v2u_3v_2, u3v3u_3v_3.

Start with M0={u1v1}M_0 = \{u_1v_1\}. The free vertices in XX are u2,u3u_2, u_3; in YY they are v2,v3v_2, v_3.

  1. From free u2u_2, the edge u2v1u_2v_1 reaches the matched vertex v1v_1. Crossing the matching edge v1u1v_1u_1 and then the free edge u1v2u_1v_2 reaches free v2v_2. So u2−v1−u1−v2u_2 - v_1 - u_1 - v_2 is an M0M_0-augmenting path. Symmetric difference gives M1={u2v1,u1v2}M_1 = \{u_2v_1, u_1v_2\}.
  2. From free u3u_3, the edge u3v3u_3v_3 reaches free v3v_3, a length-1 augmenting path. Symmetric difference gives M2={u2v1,u1v2,u3v3}M_2 = \{u_2v_1, u_1v_2, u_3v_3\}.

Now every vertex is matched, so M2M_2 is perfect and therefore maximum: ν=3\nu = 3. By Berge's theorem there is no further augmenting path. An independent check: the three edges of M2M_2 form a matching, and a vertex cover of size 3 (for example {u1,u2,u3}\{u_1, u_2, u_3\}, or {v1,v2,v3}\{v_1, v_2, v_3\}) proves β≤3\beta \le 3; with ν≤β\nu \le \beta always, both equal 3 (Konig).

The same M1M_1 also admits a longer augmenting path u3−v2−u1−v1−u2−v3u_3 - v_2 - u_1 - v_1 - u_2 - v_3, whose symmetric difference yields the different perfect matching {u1v1,u3v2,u2v3}\{u_1v_1, u_3v_2, u_2v_3\}. Either route reaches size ν\nu.

Example 6: Hall's condition and Konig's theorem on one graph

Reuse the bipartite graph of Example 1: parts X={x1,x2,x3,x4}X = \{x_1, x_2, x_3, x_4\}, Y={y1,y2,y3,y4}Y = \{y_1, y_2, y_3, y_4\}, edges x1y1x_1y_1, x1y2x_1y_2, x2y1x_2y_1, x3y1x_3y_1, x3y2x_3y_2, x4y3x_4y_3, x4y4x_4y_4.

  • Hall violator. For S={x1,x2,x3}S = \{x_1, x_2, x_3\}, N(S)={y1,y2}N(S) = \{y_1, y_2\}, so ∣N(S)∣=2<3=∣S∣|N(S)| = 2 < 3 = |S|. No matching saturates XX. The deficiency formula gives ν=∣X∣−max⁡(∣S∣−∣N(S)∣)=4−1=3\nu = |X| - \max(|S| - |N(S)|) = 4 - 1 = 3.
  • Explicit maximum matching. M={x1y2,x2y1,x4y3}M = \{x_1y_2, x_2y_1, x_4y_3\} has size 3. (The leftover unmatched pair is x3x_3 and y4y_4; no edge joins them, and every neighbour of x3x_3 is already matched.)
  • Konig certificate. The set C={y1,y2,x4}C = \{y_1, y_2, x_4\} is a vertex cover of size 3: every listed edge touches y1y_1, y2y_2 or x4x_4. So β≤3\beta \le 3. Combined with ∣M∣=3|M| = 3 and ν≤β\nu \le \beta, one gets ν=β=3\nu = \beta = 3. Konig's equality holds even though Hall's condition for an XX-saturating matching fails: the theorem equates matching number with cover number; it does not force a perfect matching.

Important properties and observations

  • A graph with an odd number of vertices has no perfect matching.
  • Removing a vertex set SS that leaves more than ∣S∣|S| components with an odd number of vertices rules out a perfect matching (Tutte's condition, the general-graph analogue of Hall).
  • A tree has at most one perfect matching.
  • The size of any matching is at most the size of any vertex cover (weak duality); for bipartite graphs the two optima meet (strong duality, Konig).
  • Every maximal matching has size between ν/2\nu/2 and ν\nu.

Standard confusions.

  • Maximal versus maximum. Maximal means no edge can be added; maximum means largest possible size. Every maximum matching is maximal, but not conversely (the path a−b−c−da - b - c - d with {bc}\{bc\} is the standard counterexample).
  • Perfect versus complete. A perfect matching saturates every vertex of GG. A matching that saturates every vertex of one part XX (but not necessarily of YY) is an XX-saturating matching, sometimes called a complete matching of XX into YY. Perfect requires ∣X∣=∣Y∣|X| = |Y| as well.
  • Even order. A perfect matching needs an even number of vertices, because matched vertices come in pairs. An odd-order graph never has a perfect matching, no matter how dense its edges are. Completeness of the graph (KnK_n) does not remove this obstruction when nn is odd: ν(Kn)=⌊n/2⌋\nu(K_n) = \lfloor n/2 \rfloor.

GATE examination perspective

  • Compute ν\nu. For special graphs use the table; for small graphs find a matching and a vertex cover of the same size (in bipartite graphs) to prove optimality.
  • Hall's condition. Look for a set of left vertices with too few neighbours.
  • Counting perfect matchings. (2k−1)!!(2k-1)!! for K2kK_{2k}, k!k! for Kk,kK_{k,k}, 2 for an even cycle.
  • Covers. α+β=n\alpha+\beta=n; ν+ρ=n\nu+\rho=n without isolated vertices. The equality ν=β\nu=\beta is guaranteed for bipartite graphs; some non-bipartite graphs also satisfy it, but not all.
  • Trap: maximal is not maximum.
  • Trap: applying Konig's theorem to a non-bipartite graph.
  • Augmenting-path construction. From any matching, search for an augmenting path; each success increases the size by one until Berge's condition holds.
  • Konig certificate. In a bipartite graph, a matching and a vertex cover of equal size prove both are optimal.

Summary

Sources

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Section 10.2 (Graph Terminology and Special Types of Graphs).
  2. D. B. West, Introduction to Graph Theory, 2nd ed., Prentice Hall, 2001: Section 3.1 (Matchings and Covers).

Next steps