Chapter 2 MATCHING

Chapter 2
MATCHING
Recall that independent sets are vertices that do not share edges. Similarly, we can
consider edges that do not have common vertices. This kind of set of edges is called
a matching in a graph.
2.1
Matching in bipartite graphs
2.1.1 Hall’s “marriage” theorem and complete matching in bipartite graphs
The marriage theorem, proved in 1935 by Philip Hall, answers the following question,
known as the marriage problem: if there is a finite set of girls, each of whom knows
several boys, under what conditions can all the girls marry the boys in such a way
that each girl marries a boy she knows? A typical “real-life” application might involve
assigning people to jobs so that every person gets a job he is able to do.
Example:
This problem can be represented graphically by taking G to be the bipartite
graph in which the vertex set is divided into two disjoint sets X and Y , corresponding
to the girls and boys (or the workers and jobs), and where each edge joins a girl to a
boy she knows (or a worker to a job he is able to do). A matching M in G is a set
of edges such that no two edges in M are incident with the same vertex. A complete
matching of X into Y is a matching such that there is an edge incident with every
vertex in X. The marriage problem can then be expressed in graph-theoretic terms
in the form: if G = G(X, Y ) is a bipartite graph with parts X and Y , when does
there exist a complete matching from X into Y ?
For a set A ⊆ X, we define the set R(A) to be the vertices in Y that are
adjacent to at least one vertex in A.
Theorem 2.1.1 (Hall, 1935) Let G be a bipartite graph with parts X and Y . There
is a complete matching of X into Y if and only if |A| ≤ |R (A)| for every A ⊆ X.
Proof: (=⇒) If for some A, |A| > |R(A)| then the vertices in A cannot be matched.
(⇐=) Proof by induction on |X|.
Base step: |X| = 1. There is only one vertex x in X. Since |X| ≤ |R(X)|, this
vertex is adjacent to at least one vertex y ∈ Y . {xy} is a complete matching of X
into Y .
18
Matching
Inductive step: Assume that |X| = n and the result is true for all bipartite
graphs with |X| < n.
Case 1: There does not exist A0 ⊂ X such that |A0 | = |R (A0 )| . (In this case,
|A| < |R (A)| for all A ⊂ X.)
Take any vertex x ∈ X. There is at least one vertex y ∈ Y such that x is
adjacent to y. Let G0 = G(X 0 , Y 0 ), that is the graph with vertex set X ∪ Y and edges
in G that have one end in X 0 and one end in Y 0 . In G0 , we have |A| ≤ |R (A)| for
every A ⊆ X 0 . By the inductive hypothesis, there is a complete matching of X 0 into
Y 0 in G0 . Call this matching M 0 . Then M = M 0 ∪ {xy} is a complete matching of X
into Y in G.
Case 2: There exists an A0 ⊂ X such that |A0 | = |R (A0 )| . Let X1 = A0 , X2 = X\A0
and Y1 = R (A0 ) , Y2 = Y \R (A0 ). Let G1 = G(X1 , Y1 ) and G2 = G(X2 , Y2 ). It
is obvious that in G1 , |A| ≤ |R (A)| for all A ⊆ X1 . Therefore there is a complete
matching of X1 into Y1 in G1 . Call this matching M1 . We claim that in G2 , we also have
|A| ≤ |R (A)| for all A ⊆ X2 . Suppose that there is A2 ⊆ X2 such that |A2 | > |R (A2 )|
in G2 . Let B = A0 ∪A2 and C = |R(A2 )| in G2 . Then |B| = |A0 |+|A2 | > |R(A0 )|+|C|.
Since in G, R(B) ⊆ R(A0 ) ∪ C, |R(B)| ≤ |R(A0 ) ∪ C| ≤ |R(A0 )| + |C| < |B| , a
contradiction. Therefore we must have |A| ≤ |R (A)| for all A ⊆ X2 in G2 . By the
inductive hypothesis, there is a complete matching of X2 into Y2 in G2 . Let M2 be
such a matching and M = M1 ∪ M2 . M is a complete matching of X into Y .
¤
Hall’s theorem was phrased using more serious terms of system of distinct representatives (SDRs) of subsets. For a set S, a collection of subsets of S : S1 , S2 , ..., Sn ,
distinct elements s1 ∈ S1 , s2 ∈ S2 , ..., sn ∈ Sn are called a system of distinct representatives of S1 , S2 , ..., Sn . Not every collection of subsets has a SDR. For example, the
subsets {1, 2} , {2, 3} , {1, 3} , {1, 2, 3} do not have a SDR.
Theorem 2.1.2 A collection of subsets of a set S has a SDR if and only if the union
of any k subsets (k = 1, 2, ..., n) contains at least k elements.
We can use a bipartite graph G to represent these subsets. Let every vertex
in X represents one of the subsets, and every vertex in Y represents one element of
S. There is an edge joining one subset Si with an element sj if and only if sj ∈ Si .
We see that there is a SDR if and only if there is a complete matching of X into Y
in G. Also we see that a subset A of X represent a subcollection of the subsets and
R(A) represent the elements in the union of these subsets. Therefore this theorem is
equivalent to the Hall’s theorem.
Corollary 2.1.3 Let G(X, Y ) be a bipartite graph. If there exists a number k such
that for every x ∈ X and every y ∈ Y , deg(x) ≥ k and deg(y) ≤ k, then there is a
complete matching of X into Y .
Proof: We apply Hall’s marriage theorem. Let A be a subset of X. There are at
least k |A| edges with one end in A. The other end of these edges are in R(A). Since
every vertex in R(A) is incident with at most k edges, there are at least |A| vertices
in R(A).
¤
Matching in bipartite graphs
19
2.1.2 Maximal matchings
If there is no complete matching of X into Y in a bipartite graph G, then we may
wish to match as many of the vertices in X with the vertices in Y as possible. We
define a maximal matching of X into Y in a bipartite graph to be one that matches
the largest number of vertices in X with the vertices in Y .
Let A be a subset of X. The deficiency of A, denoted by def (A), is defined
as |A| − |R (A)|. Notice that the deficiency of a set can be a positive number as
well as a negative number. We define the deficiency of a bipartite graph G, denoted
by def (G), as the maximal value of the deficiencies of the subsets of X. Since the
deficiency of the empty set is always zero, the deficiency of a graph is always larger
than or equal to zero. We shall prove a theorem relating the deficiency of a bipartite
graph to the maximal number of vertices in X that can be matched into Y .
Theorem 2.1.4 In a bipartite graph G the maximal number of vertices in X that
can be matched into Y is equal to |X| − def (G).
Proof: It is easy to see that for any matching, there are at least def (G) vertices in
X that are not matched. Therefore the maximal number of vertices in X that can
be matched into Y is at most |X| − def (G). We show that there is a matching that
can match |X| − def (G) vertices in X into Y .
Case 1: def (G) = 0. In this case we have
|A| − |R (A)| ≤ 0
for all A ⊆ X. By Hall’s theorem, there is a complete matching of X into Y .
Case 2: def (G) = d > 0.
We build a graph G0 by adding d new vertices to Y and joining every new
vertex to every vertex in X. We claim that |A| ≤ |R(A)| in G0 for every A ⊆ X.
Suppose that this is not true, i.e., there is a set A0 ⊆ X such that |A0 | > |R (A0 )| in
G0 . This means that
|A0 | − |R (A0 ) in G0 | > 0
in G0 . Since all d new vertices are in R(A0 ),
|R (A0 ) in G| = |R (A0 ) in G0 | − d
So we have
|A0 | − |R (A0 ) in G| = |A0 | − |R (A0 ) in G0 | + d > d.
This means def (A0 ) > d = def (G) which is a contradiction. This proves the claim
is true and G0 has a complete matching of X into Y . This matching will match at
most d vertices in X into the new vertices, therefore it matches at least |X| − def (G)
vertices in X into Y .
¤
20
Matching
2.1.3 Applications
Sperner’s theorem
Let S be a finite set. A collection of subsets of S is said to be “incomparable” if
none of the subsets contains another of the subsets. If we use a vertex to represent
each subset of S and join two vertices if one subset contains the other, we can build
a graph G representing the containment relation among the subsets. A collection of
subsets is incomparable if the vertices representing them form an independent set in
G.
Theorem 2.1.5 (Sperner) Let S be a set of n elements.
¡ n ¢ The maximum number of
subsets in an incomparable collection of subsets is bn/2c
.
¡ n ¢
It is easy to see that we can find a collection of bn/2c
subsets that are incomparable. We consider all subsets of S that contain k element.
¡n¢ Since they have the
same size, no¡one
¢ of them can contain another. There are k such subsets. For what
n
value of k is k greatest? The answer is intuitively obvious from an examination of
Pascal’s triangle, but we can prove it rigorously. We know that
µ ¶
n−k+1
n!
n
n!
=
·
(2.1)
=
k! (n − k)!
k
(k − 1)! (n − k + 1)!
k
µ
¶
n
n−k+1
.
=
k
k−1
¡n¢
¡ n ¢
So if n − k + 1 > k or k − 1 < n−1
,
,
>
; if n − k + 1 < k or k > n+1
k
k−1
2
2
¡n¢ ¡ n ¢
n−1
< k−1 . So if k is less than 2 , we should choose a greater value of k and if k is
k
, we should choose a less value of k. Therefore the maximum occurs
greater than n+1
2
n−1
n+1
at 2 ≤ k ≤ 2 or k = bn/2c and k = dn/2e .
This is the maximum possible value of an incomparable collection if all the
subsets have the same size k. Is it possible to find a larger collection of incomparable
subsets by letting them be of varying sizes? The answer is no. Consider an arbitrary
collection of incomparable subsets S. We show that it can be systematically modified,
without decreasing its size (i.e., the number of subsets in S), until it contains only
subsets of size bn/2c.
Let i be the size of the smallest subset in S, and let j be that of the largest.
There are three cases (of which the first two are not mutually exclusive): (i) i < bn/2c,
(ii) j > bn/2c, or (iii) i = j = bn/2c. Suppose i < bn/2c. We construct a bipartite
graph G(X, Y ) in which X is the set of all possible subsets of size i, Y is the set of
all possible subsets of size i + 1, and a set x of size i is joined by an edge to a set y
of size i + 1 if and only if x is a subset of y. We will show that there is a complete
matching of X into Y in G. Each set x of size i is joined to n − i sets of size i + 1
(one for each element not in x), while each set y of size i + 1 is joined to i + 1 sets of
size i (one for each element in y). Since i < bn/2c, which implies i ≤ (n − 1) /2, we
Matching in bipartite graphs
21
know n − i ≥ (n + 1) /2 ≥ i + 1. So by Corollary 2.1.3, there is a complete matching
of X into Y . Call this matching M. For each set x of size i that is in S, if it is
matched to y by M, we replace x with y. Since x is contained in y (for there is an
edge xy in G(X, Y )) and S is incomparable, y is not in S before. So this operation
will not change the size of S. Since x is not contained in any other subset in S, y
cannot be contained by any other subset in S either. After all the subsets of size i
being replaced, (i + 1) is the smallest size in S. So y cannot contain any other subset.
Therefore, after the operation, S is still incomparable. This can be repeated until
case (i) does not hold. Case (ii) can be handled similarly.
Latin rectangles and Latin squares
An r × n Latin rectangle (r < n) is an r × n matrix that has the numbers 1,2,3,...,
n as entries such that no number appears more than once in the same row or the
same column. We shall show that it is always possible to append n − r rows to an
r × n Latin rectangle to form an n × n Latin square. We define a bipartite graph
with x1 , x2 , ..., xn in X corresponding to the n columns in the r × n Latin rectangle
and with Y = {1, 2, ..., n}. In the bipartite graph, there is an edge joining x, and the
number k if and only if k does not appear in the ith column of the rectangle. There
is a complete matching of X into Y because each x in X is adjacent to exactly n − r
numbers in Y (r of the n numbers have appeared in a column), and each number in
Y is adjacent to exactly n − r x’s in X (each number has not appeared in exactly
n − r columns). The existence of a complete matching means that we can assign the
n numbers to the n columns such that each column will be assigned a number that
has not appeared in the column before. Therefore, the r × n Latin rectangle can be
augmented into an (r + 1) × n Latin rectangle. This argument can be repeated until
an n × n Latin square is formed.
Zero-One matrices
Theorem 2.1.6 (König and Egerváry 1931) In a matrix of zeros and ones, the maximum number of ones, no two in a line (row or column), equals the minimum number
of lines needed to cover all the ones.
To prove this theorem, we need a lemma about bipartite graph. We say that
a set of vertices C in a graph G covers the edges of G if every edge of G has at least
one end in C.
Lemma 2.1.7 Suppose that G is a bipartite graph with a maximal matching of m
edges. The minimum number of vertices in a set that covers all the edges of G is m.
Proof: If there is a matching in G that has m edges then it takes one vertex to cover
each edge in that matching. Therefore we need at least m vertices to cover all the
edges in G. We only need to show that we can cover the all the edges with m vertices.
22
Matching
By Theorem 2.1.4, m = |X| − def (G). There is a set A ⊆ X such that
|A| − |R(A)| = def (A) = def (G) = |X| − m.
Or
m = |X| − |A| + |R (A)|
Let C = (X\A) ∪ R (A). It is easy to see that C is a set covering all the edges in G.
Also we have
|C| = |X| − |A| + |R (A)| = m.
¤
For an m × n matrix A of zeros and ones, we can build a bipartite graph
G(X, Y ) such that X = {x1 , ..., xm } corresponding to the rows of A and Y =
{y1 , ..., yn } corresponding to the columns of A. There is an edge joining xi and
yi if and only if aij = 1. It is easy to see that a set of ones, no two of them in
a line, correspond to a matching in G and a set of lines covering all the ones in A
correspond to a set of vertices in G that covers all the edges. Therefore Theorem
2.1.6 is equivalent to Lemma 2.1.7.
2.2
Augmenting path and an algorithm
Definition 2.2.1 Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path P that begins
and ends at vertices that are not matched by M is an M-augmenting path.
If P is an M-augmenting path, then replacing M ∩ E (P ) by E (P ) − M
produces a new matching M 0 with one more edge than M. Here is another proof of
the Hall’s theorem using aumenting path.
Theorem 2.2.2 Let G be a bipartite graph with parts X and Y . There is a complete
matching of X into Y if and only if |A| ≤ |R (A)| for every A ⊆ X.
Proof : The necessary part is trivial as before. We will prove the sufficient part by
contradiction. Suppose that G (X, Y ) satisfies the condition
For every A ⊆ X, |A| ≤ |R (A)| .
(*)
Let M be a maximum matching in G. Assume that M is not a complete matching
from X to Y . We will derive a contradiction to (∗). Let x0 be a vertex in X that is
not matched by M. Let U be the set of vertices that can be reached by an alternating
path (with at least one edges) from x0 . Let S = U ∩ X and T = U ∩ Y . Note that
an alternating path will reach Y with an edge not in M and reach X with an edge
in M. Therefore we have
1. All vertices in T are matched to all vertices in S;
Augmenting path and an algorithm
23
2. R (S) ⊆ T .
If we choose A = {x0 } ∪ S, then R (A) = T and |A| = |R (A)| + 1, a contradiction to (∗).
¤
The idea in the proof of Theorem 2.2.2 can be used as an algorithm to determine whether a bipartite graph G (X, Y ) has a complete matching from X into
Y:
Repeat while there is at least one unmatched vertex in X. Take
an unmatched vertex x and find all alternating path starting from
x. If one of the path ends at an unmatched vertex, we can increase
the number of edges in the matching by 1. If there is no such
pathes then stop, there is no complete matching from X into Y .
24
Matching
2.3
Matchings in general graphs
Definition 2.3.1 A factor of a graph G is a spanning subgraph of G. A k-factor is
a spanning subgraph such that every vertex has degree k in that subgraph. An odd
component of a graph is a component of odd number of vertices. We denote the
number of odd components of a graph H with q (H).
Theorem 2.3.2 (Tutte [1947]) A graph G has a 1-factor if and only if q (G − S) ≤
|S| for every S ⊆ V (G).
Proof : (Lovasz [1975])
Necessity. The odd components of G − S must have vertices matched to distinct
vertices of S.
Sufficiency. We assume that there is a graph G that satisfies the condition
q (G − S) ≤ |S| for every S ⊆ V (G)
(*)
but G does not have a 1-factor. (In the other words, G is a counter example.) We
will derive a contradiction.
Let G0 = G + e, the graph obtained by adding an edge e to G.
• q (G0 − S) ≤ q (G − S) for every S ⊆ V (G).
• G0 satisfies condition (∗).
• If G0 does not have a 1-factor, then G0 is also a counter example.
We will check every edge e that is not in G. If G + e does not have a 1factor, we will add edge e to G. Eventually, we will end up with a maximal counter
example, i.e., a graph G∗ such that
1. G∗ is a counter example;
2. For any edge e not in G∗ , G∗ + e has a 1-factor.
We will show that G∗ has a 1-factor. This contradiction will prove the sufficiency part of the theorem.
Let the number of vertices in G∗ be n. Since G∗ satisfies condition (∗) , by
letting S = ∅, we know that G∗ has even number of vertices. So n is even. Let S ∗
Matchings in general graphs
25
be the set of all vertices in G∗ that has degree n − 1 (S ∗ might be empty).
G* − S *
S*
Case 1. Each component of G∗ − S ∗ is complete.
In this case, we can match every vertex in the even components of G∗ −S ∗ and
all but one vertex in each of the odd components of G∗ −S ∗ . Since q (G∗ − S ∗ ) ≤ |S ∗ |,
we can match each of the unmatched vertex in the odd components of G∗ − S ∗ with
one vertex in S ∗ . Because n is odd, either q (G∗ − S ∗ ) and |S ∗ | both are odd or they
are both even. Therefore there would be even number of vertices left in S ∗ and we
can match them into pairs. In this case, G∗ has a 1-factor.
G* − S *
S*
Case 2. At least one component of G∗ − S ∗ is not complete.
In this case, we can find vertices a, b, and c in G∗ − S ∗ such that a, c are
adjacent to b but a is not adjacent to c. Since b is not in S ∗ , there is another vertex
d in G∗ − S ∗ such that b is not adjacent to d. By the assumption we made about G∗ ,
G∗ +ac has a 1-factor M1 and G∗ +bd has a 1-factor M2 . The components of M1 ∪M2
are cycles of even length of edges. The edges are the ones in both M1 and M2 . Since
the edges ac and bd are in one of M1 or M2 but not in the other, the components
they are in must be cycles.
26
Matching
Subcase 2.1. ac and bd are not in the same component of M1 ∪ M2 . Say that the
component containing ab is C1 . We choose the edges in M2 in C1 and the edges in
M1 in all the other components. This is a 1-factor of G∗ .
M2 a
M1
b
M1
M2
d
M2 c
Subcase 2.2 ac and bd are in the same component of M1 ∪ M2 . Let this component
be C. C is of the form {c, a, x, ..., y, b, d, ..., c} or {c, a, x, ..., d, b, y, ..., c}, where ax is
an edge in M2 and yb is an edges in M1 .
Subsubcase 2.1.1 C = {c, a, x, ..., y, b, d, ..., c}
x
a
M2
M1
b
M1
M2
y
d
c
M2
In this case bc together with the M1 edges from d to c in C and M2 edges from a to
b in C and in the other components form a 1-factor of G∗ .
Subsubcase 2.1.2 C = {c, a, x, ..., d, b, y, ..., c}
x
a
M2
M1
M2
b
M1
d
y
c
M2
In this case ab together with the M1 edges from x to d in C and M2 edges from y to
c in C and in the other components form a 1-factor of G∗ .
¤
Matchings in general graphs
27
Definition 2.3.3 In a general graph G, we define the deficiency of a vertex set S to
be
d (S) = q (G − S) − |S|
and the deficiency of G is
d (G) = max d (S) .
S⊆V (G)
Corollary 2.3.4 [Berge 1958] The largest number of vertices that can be matched by
a matching in G is n − d (G) where n is the number of vertics in G.
Definition 2.3.5 A graph G is k-regular if every vertex in G has degree k. An edge
e in a graph is a cut-edge if G − e has more components than G.
Corollary 2.3.6 [Petersen 1891] Every 3-regular graph with no cut-edge has a 1factor.