Matching problem


In the mathematical discipline of graph theory a matching or edge independent 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.


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.

We say that a vertex is matched if it is incident to an edge 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.

A maximum matching is a matching that contains the largest possible number of edges. There may be many maximum matchings. The matching number of a graph is the size of a maximum matching. Note that every maximum matching must be maximal, but not every maximal matching must be maximum.

A perfect matching is a matching which covers all vertices of the graph. That is, every vertex of the graph is incident to exactly one edge of the matching. Every perfect matching is maximum and hence maximal. In some literature, the term complete matching is used.

Given a matching M,

  • an alternating path is a 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).

Matchings in bipartite graphs

Matching problems are often concerned with bipartite graphs. Finding a maximum bipartite matching (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 in 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.

In a weighted bipartite graph, each edge has an associated value. A maximum weighted bipartite matching is defined as a perfect 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. It can be solved by using a modified shortest path search in the augmenting path algorithm. If the Bellman-Ford algorithm is used, the running time 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. The remarkable Hungarian algorithm solves the assignment problem and it was one of the starting point of the combinatorial optimization. The original approach of this algorithm need O(V^2E) running time, but it could be improved to O(V^2 log(V) + V E) time with extensive use of priority queues.

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 problem and maximum independent set problem may be solved in polynomial time for bipartite graphs.


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. If a graph has near-perfect matchings that omit each one of its vertices, it is a factor-critical graph.

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

There is a polynomial time algorithm to find a maximum matching in a graph that is not bipartite; it is due to Jack Edmonds, is called the paths, trees, and flowers method, and uses bidirected edges.

A related problem is, given a graph G, to determine the number of perfect matchings in G. This problem is #P Complete (see Permanent). However, a remarkable theorem of Kasteleyn states that the number of perfect matchings in a planar graph can be computed exactly in polynomial time. Also, for bipartite graphs, the problem can be approximately solved in polynomial time. That is, for any ε>0, there is a probabilistic polynomial time algorithm that determines, with high probability, the number of perfect matchings M within an error of at most εM.

Matching problem is a special case of a more general problem called f-Factor problem. A graph G=(V,E) has an f-Factor if and only if, G has a subgraph G', where the degree of each node v in G' is f(v). If f(v)=1 for all vertices, f-Factor problem reduces to matching problem. Hence matching problem is also referred to as 1-Factor problem.

In chemistry, a Kekulé structure of an aromatic compound consists of a perfect matching of its carbon skeleton, showing the locations of double bonds in the chemical structure. These structures are named after Friedrich August Kekulé von Stradonitz, who showed that benzene (in graph theoretical terms, a 6-vertex cycle) can be given such a structure.

In 1971, Haruo Hosoya defined topological index (a graph invariant) as the total number of matchings of a graph plus 1. The Hosoya index is often used in computer chemistry investigations for organic compounds.


  • For a graph G with n vertices having no isolated vertex the matching number + edge covering number = n
  • A graph with n vertices and a perfect matching has a matching number of n/2.

See also


Additional reading

  1. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein (2001). Introduction to Algorithms. second edition, MIT Press and McGraw-Hill. ISBN 0-262-53196-8.
  2. Michael L. Fredman and Robert E. Tarjan (1987). "Fibonacci heaps and their uses in improved network optimization algorithms". Journal of the ACM 34 595–615.
  3. S. J. Cyvin and Ivan Gutman (1988). Kekule Structures in Benzenoid Hydrocarbons. Springer-Verlag.

External links

Search another word or see Matching problemon Dictionary | Thesaurus |Spanish
Copyright © 2015, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature