Mathematical Foundations of Computer Science Lecture Outline
Mathematical Foundations of Computer Science Lecture Outline
Lecture Outline
November 6, 2018
Matchings
A matching in a graph is a set of edges with no shared end-points. The vertices incident
on the edges of a matching M are called M-saturated, the others are called M-unsaturated.
A perfect matching in a graph is a matching that saturates every vertex in the graph.
(a) (b)
Figure 1: (a) a graph G with the bold edges representing a maximal matching, (b) the bold
edges represent a maximum matching in G that is also perfect.
For graphs G and H, the symmetric difference G⊕H is a subgraph of G∪H whose edges are
the edges of G ∪ H that appear in either G or H, but not both. We also use the notation for
set of edges; in particular, if M and M 0 are matchings then M ⊕ M 0 = (M \ M 0 ) ∪ (M 0 \ M ).
2 Lecture Outline November 6, 2018
Solution. We will prove the necessary condition by proving its contrapositive, i.e., we will
prove that if G contains an M -augmenting path then M is not a maximum matching. Sup-
pose that G contains a M -augmenting path v0 v1 v2 . . . v2m+1 (Note that an M -augmenting
path must be of odd length). Define M 0 ⊆ E by
We will prove the converse by proving the contraposition. Assume that M is not a maximum
matching. Let M 0 be a maximum matching in G. Then |M 0 | > |M |. Set H = G[M ⊕ M 0 ].
Figure 2 illustrates this operation. Observe that every vertex in H has either degree one
or degree two in H, since it can be incident with at most one edge of M and one edge of
M 0 . Thus each component of H is either an even cycle with edges alternating in M and
M 0 or else a path with edges alternating in M and M 0 . Since |M 0 | > |M |, H contains more
edges of M 0 than of M , and H must contain a component which is a path, P , that starts
and ends with edges in M 0 . Since the start vertex and end vertex of P are M 0 -saturated
in H they must be M -unsaturated in G. Thus, P is an M -augmenting path in G. This
completes the proof.
Figure 2: (a) a graph G with a matching M represented by the bold edges, (b) the dashed
edges represent a matching M 0 in G, (c) G[M ⊕ M 0 ]
vertex in U to a vertex in V .
Now consider the following scenario. There is a set of girls and a set of boys. Each
girl likes some boys and dislikes others. What conditions would guarantee that each girl
is paired-up with a boy that she likes and that no two girls are paired-up with the same boy.
We can model this situation using a bipartite graph, (X, Y, E), where each vertex in X
represents a girl, each vertex in Y represents a boy and and edge (g, b) ∈ E means that girl
g likes boy b. We are interested in the conditions that would guarantee a matching that
saturates every vertex in X.
Hall’s theorem gives the necessary and sufficient conditions for the existence of such match-
ings in bipartite graphs.
Example. [Hall’s Theorem] Let G = (X, Y, E) be a bipartite graph. For any set S of
vertices, let NG (S) be the set of vertices adjacent to vertices in S. Prove that G contains a
matching that saturates every vertex in X iff |NG (S)| ≥ |S|, ∀S ⊆ X. The condition “For
all S ⊆ X, |N (S)| ≥ |S|” is called Hall’s condition.
We will now prove the sufficiency of Hall’s conditon, i.e., if |NG (S)| ≥ |S|, ∀S ⊆ X then G
contains a matching that saturates every vertex in X. We prove this by induction on the
size of X.
Base Case: |X| = 1. If the only vertex in X is connected to at least one vertex in Y then
clearly a matching exists.
Induction Hypothesis: Assume that Hall’s condition is sufficient when |X| = j, for all j
such that 1 ≤ j ≤ k.
Induction Step: We want to prove that the sufficiency of Hall’s condition when |X| = k + 1.
Let G = (X, Y, E) be a graph with k + 1 vertices in X such that ∀S ⊆ X, |NG (S)| ≥ |S|.
We consider the following two cases.
Case I: For every non-empty proper subset W ⊂ X, |NG (W )| > |W |. In this case, we
pair-up an arbitrary vertex x ∈ X with one of its neighbors, say y ∈ Y . Now consider the
subgraph G0 = (X 0 , Y 0 , E 0 ), where X 0 = X \ {x}, Y 0 = Y \ {y}, and E 0 = E \ {(x, y)}).
After the removal of y, the neighborhood of any subset, S 0 ⊆ X 0 in G0 is at most one less
than its neighborhood in G. But since |NG (S 0 )| > |S 0 |, after removal of y, it must be that
|NG0 (S 0 )| ≥ |S 0 |. Thus, Hall’s condition holds for G0 . By induction hypothesis, G0 contains
a matching M 0 that saturates every vertex in X 0 . Hence, M 0 ∪ {(x, y)} is a matching that
saturates every vertex in X.
Case II: For some non-empty proper subset W ⊂ X, |N (W )| = |W |. For all S 0 ⊆ W ,
we have NG (S 0 ) ⊆ NG (W ). Hence, Hall’s condition holds for the subgraph induced by
4 Lecture Outline November 6, 2018