World Library  
Flag as Inappropriate
Email this Article

Matching (graph theory)

Article Id: WHEBN0000581797
Reproduction Date:

Title: Matching (graph theory)  
Author: World Heritage Encyclopedia
Language: English
Subject: Matching, Independent set (graph theory), Skew-symmetric graph, Combinatorial optimization, Linear programming
Collection: Combinatorial Optimization, Matching, Polynomial-Time Problems
Publisher: World Heritage Encyclopedia

Matching (graph theory)

In the mathematical discipline of graph theory, a matching or independent edge set in a graph is a set of edges without common vertices. It may also be an entire graph consisting of edges without common vertices. Bipartite matching is a special case of a network flow problem.


  • Definition 1
  • Properties 2
  • Matching polynomials 3
  • Algorithms and computational complexity 4
    • In unweighted bipartite graphs 4.1
    • In weighted bipartite graphs 4.2
    • In general graphs 4.3
    • Maximal matchings 4.4
    • Counting problems 4.5
    • Finding all maximally-matchable edges 4.6
  • Characterizations and notes 5
  • Applications 6
    • Matching in general graphs 6.1
    • Matching in bipartite graphs 6.2
  • See also 7
  • References 8
  • Further reading 9
  • External links 10


Given a graph G = (V,E), a matching M in G is a set of pairwise non-adjacent edges; that is, no two edges share a common vertex.

A vertex is matched (or saturated) if it is an endpoint of one of the edges in the matching. Otherwise the vertex is unmatched.

A maximal matching is a matching M of a graph G with the property that if any edge not in M is added to M, it is no longer a matching, that is, M is maximal if it is not a proper subset of any other matching in graph G. In other words, a matching M of a graph G is maximal if every edge in G has a non-empty intersection with at least one edge in M. The following figure shows examples of maximal matchings (red) in three graphs.

A maximum matching (also known as maximum-cardinality matching[1]) is a matching that contains the largest possible number of edges. There may be many maximum matchings. The matching number \nu(G) of a graph G is the size of a maximum matching. Note that every maximum matching is maximal, but not every maximal matching is a maximum matching. The following figure shows examples of maximum matchings in the same three graphs.

A perfect matching (a.k.a. 1-factor) is a matching which matches all vertices of the graph. That is, every vertex of the graph is incident to exactly one edge of the matching. Figure (b) above is an example of a perfect matching. Every perfect matching is maximum and hence maximal. In some literature, the term complete matching is used. In the above figure, only part (b) shows a perfect matching. A perfect matching is also a minimum-size edge cover. Thus, ν(G) ≤ ρ(G) , that is, the size of a maximum matching is no larger than the size of a minimum edge cover.

A near-perfect matching is one in which exactly one vertex is unmatched. This can only occur when the graph has an odd number of vertices, and such a matching must be maximum. In the above figure, part (c) shows a near-perfect matching. If, for every vertex in a graph, there is a near-perfect matching that omits only that vertex, the graph is also called factor-critical.

Given a matching M,

  • an alternating path is a that begins with an unmatched vertex and is a [2]path in which the edges belong alternatively to the matching and not to the matching.
  • an augmenting path is an alternating path that starts from and ends on free (unmatched) vertices.

One can prove that a matching is maximum if and only if it does not have any augmenting path. (This result is sometimes called Berge's lemma.)


In any graph without isolated vertices, the sum of the matching number and the edge covering number equals the number of vertices.[3] If there is a perfect matching, then both the matching number and the edge cover number are |V| / 2.

If A and B are two maximal matchings, then |A| ≤ 2|B| and |B| ≤ 2|A|. To see this, observe that each edge in B \ A can be adjacent to at most two edges in A \ B because A is a matching; moreover each edge in A \ B is adjacent to an edge in B \ A by maximality of B, hence

|A \setminus B| \le 2|B \setminus A|.

Further we get that

|A| = |A \cap B| + |A \setminus B| \le 2|B \cap A| + 2|B \setminus A| = 2|B|.

In particular, this shows that any maximal matching is a 2-approximation of a maximum matching and also a 2-approximation of a minimum maximal matching. This inequality is tight: for example, if G is a path with 3 edges and 4 nodes, the size of a minimum maximal matching is 1 and the size of a maximum matching is 2.

Matching polynomials

A generating function of the number of k-edge matchings in a graph is called a matching polynomial. Let G be a graph and mk be the number of k-edge matchings. One matching polynomial of G is

\sum_{k\geq0} m_k x^k.

Another definition gives the matching polynomial as

\sum_{k\geq0} (-1)^k m_k x^{n-2k},

where n is the number of vertices in the graph. Each type has its uses; for more information see the article on matching polynomials.

Algorithms and computational complexity

In unweighted bipartite graphs

Matching problems are often concerned with bipartite graphs. Finding a maximum bipartite matching[4] (often called a maximum cardinality bipartite matching) in a bipartite graph G=(V=(X,Y),E) is perhaps the simplest problem.

The augmenting path algorithm finds it by finding an augmenting path from each x ∈ X to \ Y and adding it to the matching if it exists. As each path can be found in \ O(E) time, the running time is \ O(V E). This solution is equivalent to adding a super source s with edges to all vertices in \ X, and a super sink \ t with edges from all vertices in \ Y, and finding a maximal flow from \ s to \ t. All edges with flow from \ X to \ Y then constitute a maximum matching.

An improvement over this is the Hopcroft–Karp algorithm, which runs in O(\sqrt{V}E) time. Another approach is based on the fast matrix multiplication algorithm and gives O(V^{2.376}) complexity,[5] which is better in theory for sufficiently dense graphs, but in practice the algorithm is slower.[6] Finally, for sparse graphs, \tilde{O}(E^{10/7}) is possible with Madry's algorithm based on electric flows. [7]

In addition, the algorithm of Chandran and Hochbaum[6] runs in time that depends on the size of the maximum matching k, which for |X|<|Y| is O\left(\min\{|X|k,E\}+ \sqrt{k} \min \{k^2,E\}\right). Using boolean operations on words of size \lambda the complexity is further improved to O\left(\min \left\{|X|k, \frac{|X||Y|}{\lambda}, E\right\} + k^2 + \frac{k^{2.5}}{\lambda}\right).

In weighted bipartite graphs

In a weighted bipartite graph, each edge has an associated value. A maximum weighted bipartite matching[4] is defined as a matching where the sum of the values of the edges in the matching have a maximal value. If the graph is not complete bipartite, missing edges are inserted with value zero. Finding such a matching is known as the assignment problem. The Hungarian algorithm solves the assignment problem and it was one of the beginnings of combinatorial optimization algorithms. It uses a modified shortest path search in the augmenting path algorithm. If the Bellman–Ford algorithm is used for this step, the running time of the Hungarian algorithm becomes O(V^2 E), or the edge cost can be shifted with a potential to achieve O(V^2 \log{V} + V E) running time with the Dijkstra algorithm and Fibonacci heap.[8]

In general graphs

There is a O(V^{2}E) time algorithm to find a maximum matching or a maximum weight matching in a graph that is not bipartite; it is due to Jack Edmonds, is called the paths, trees, and flowers method or simply Edmonds' algorithm, and uses bidirected edges. A generalization of the same technique can also be used to find maximum independent sets in claw-free graphs. Edmonds' algorithm has subsequently been improved to run in time O(VE) time, matching the time for bipartite maximum matching.[9]

Another (randomized) algorithm by Mucha and Sankowski,[5] based on the fast matrix multiplication algorithm, gives O(V^{2.376}) complexity.

Maximal matchings

A maximal matching can be found with a simple greedy algorithm. A maximum matching is also a maximal matching, and hence it is possible to find a largest maximal matching in polynomial time. However, no polynomial-time algorithm is known for finding a minimum maximal matching, that is, a maximal matching that contains the smallest possible number of edges.

Note that a maximal matching with k edges is an edge dominating set with k edges. Conversely, if we are given a minimum edge dominating set with k edges, we can construct a maximal matching with k edges in polynomial time. Therefore the problem of finding a minimum maximal matching is essentially equal to the problem of finding a minimum edge dominating set.[10] Both of these two optimisation problems are known to be NP-hard; the decision versions of these problems are classical examples of NP-complete problems.[11] Both problems can be approximated within factor 2 in polynomial time: simply find an arbitrary maximal matching M.[12]

Counting problems

The number of matchings in a graph is known as the Hosoya index of the graph. It is #P-complete to compute this quantity. It remains #P-complete in the special case of counting the number of perfect matchings in a given bipartite graph, because computing the permanent of an arbitrary 0–1 matrix (another #P-complete problem) is the same as computing the number of perfect matchings in the bipartite graph having the given matrix as its biadjacency matrix. However, there exists a fully polynomial time randomized approximation scheme for counting the number of bipartite matchings.[13] A remarkable theorem of Kasteleyn states that the number of perfect matchings in a planar graph can be computed exactly in polynomial time via the FKT algorithm.

The number of perfect matchings in a complete graph Kn (with n even) is given by the double factorial (n − 1)!!.[14] The numbers of matchings in complete graphs, without constraining the matchings to be perfect, are given by the telephone numbers.[15]

Finding all maximally-matchable edges

One of the basic problems in matching theory is to find in a given graph all edges that may be extended to a maximum matching in the graph. (Such edges are called maximally-matchable edges, or allowed edges.) The best deterministic algorithm for solving this problem in general graphs runs in time O(VE) .[16] There exists a randomized algorithm that solves this problem in time \tilde{O}(V^{2.376}) .[17] In the case of bipartite graphs, it is possible to find a single maximum matching and then use it in order to find all maximally-matchable edges in linear time;[18] the resulting overall runtime is O(V^{1/2}E) for general bipartite graphs and O((V/\log V)^{1/2}E) for dense bipartite graphs with E=\Theta(V^2). In cases where one of the maximum matchings is known upfront,[19] the overall runtime of the algorithm is O(V+E).

Characterizations and notes

König's theorem states that, in bipartite graphs, the maximum matching is equal in size to the minimum vertex cover. Via this result, the minimum vertex cover, maximum independent set, and maximum vertex biclique problems may be solved in polynomial time for bipartite graphs.

Hall's marriage theorem provides a characterization of bipartite graphs which have a perfect matching and the Tutte theorem provides a characterization for arbitrary graphs.

A perfect matching is a spanning 1-regular subgraph, a.k.a. a 1-factor. In general, a spanning k-regular subgraph is a k-factor.


Matching in general graphs

Matching in bipartite graphs

  • Graduation problem is about choosing minimum set of classes from given requirements for graduation.
  • Hitchcock Transport Problem involves bipartite matching as sub-problem.
  • Subtree isomorphism problem involves bipartite matching as sub-problem.

See also

  • Dulmage–Mendelsohn decomposition, a partition of the vertices of a bipartite graph into subsets such that each edge belongs to a perfect matching if and only if its endpoints belong to the same subset
  • Edge coloring, a partition of the edges of a graph into matchings
  • Matching preclusion, the minimum number of edges to delete to prevent a perfect matching from existing
  • Rainbow matching, a matching in an edge-colored bipartite graph with no repeated colors
  • Skew-symmetric graph, a type of graph that can be used to model alternating path searches for matchings
  • Stable matching, a matching in which no two elements prefer each other to their matched partners
  • Vertex independent set, a set of vertices (rather than edges) no two of which are adjacent to each other
  • Stable marriage problem (also known as stable matching problem)


  1. ^ Alan Gibbons, Algorithmic Graph Theory, Cambridge University Press, 1985, Chapter 5.
  2. ^
  3. ^ Gallai, Tibor (1959), "Über extreme Punkt- und Kantenmengen", Ann. Univ. Sci. Budapest. Eötvös Sect. Math. 2: 133–138 .
  4. ^ a b West, Douglas Brent (1999), Introduction to Graph Theory (2nd ed.), Prentice Hall, Chapter 3,  
  5. ^ a b Mucha, M.; Sankowski, P. (2004), "Maximum Matchings via Gaussian Elimination" (PDF),  
  6. ^ a b Chandran, Bala G.;  .
  7. ^ Madry, A (2013), "Navigating Central Path with Electrical Flows: From Flows to Matchings, and Back", Foundations of Computer Science (FOCS), 2013 IEEE 54th Annual Symposium on, pp. 253–262,  
  8. ^ Fredman, Michael L.; Tarjan, Robert Endre (1987), "Fibonacci heaps and their uses in improved network optimization algorithms",  
  9. ^  .
  10. ^ Yannakakis, Mihalis; Gavril, Fanica (1980), "Edge dominating sets in graphs", SIAM Journal on Applied Mathematics 38 (3): 364–372,  .
  11. ^  . Edge dominating set (decision version) is discussed under the dominating set problem, which is the problem GT2 in Appendix A1.1. Minimum maximal matching (decision version) is the problem GT10 in Appendix A1.1.
  12. ^ Ausiello, Giorgio; Crescenzi, Pierluigi; Gambosi, Giorgio; Kann, Viggo; Marchetti-Spaccamela, Alberto; Protasi, Marco (2003), Complexity and Approximation: Combinatorial Optimization Problems and Their Approximability Properties, Springer . Minimum edge dominating set (optimisation version) is the problem GT3 in Appendix B (page 370). Minimum maximal matching (optimisation version) is the problem GT10 in Appendix B (page 374). See also Minimum Edge Dominating Set and Minimum Maximal Matching in the web compendium.
  13. ^ Bezáková, Ivona; Štefankovič, Daniel;  
  14. ^ Callan, David (2009), A combinatorial survey of identities for the double factorial,  .
  15. ^ Tichy, Robert F.; Wagner, Stephan (2005), "Extremal problems for topological indices in combinatorial chemistry" (PDF),  .
  16. ^ de Carvalho, Marcelo H.; Cheriyan, Joseph (2005), "An O(VE) algorithm for ear decompositions of matching-covered graphs", Proc. ACM/SIAM Symposium on Discrete Algorithms (SODA), pp. 415–423 .
  17. ^ Rabin, Michael O.; Vazirani, Vijay V. (1989), "Maximum matchings in general graphs through randomization", J. of Algorithms 10: 557–567,  .
  18. ^ Tassa, Tamir (2012), "Finding all maximally-matchable edges in a bipartite graph",  .
  19. ^ Gionis, Aris; Mazza, Arnon; Tassa, Tamir (2008), "k-Anonymization revisited",  .
  20. ^ See, e.g.,  .

Further reading

  5. S. J. Cyvin and Ivan Gutman (1988), Kekule Structures in Benzenoid Hydrocarbons, Springer-Verlag 

External links

  • A graph library with Hopcroft–Karp and Push–Relabel-based maximum cardinality matching implementation
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.