Title: Section 2.1 Matching in bipartite graphs in Graph Theory
1Section 2.1 Matching in bipartite graphsin
Graph Theory
- Handout for reading seminar
2Matching
- Task Find independent edges as many as possible.
- Independent edges edges not sharing any vertex.
- Q Are there independent edges containing all
vertices? - Matching M ? E of U given G(V,E) and U ? V
- Every vertex in U is incident with an edge in M.
- A set M ? E of independent edges in graph G.
v1
v2
v3
v4
Vertices in V are matched by M2.
Vertices in U are matched by M1.
G
unmatched
Uv1, v2, v3, v4
3k-factor
- k-factor a k-regular spanning subgraph
- k-regular
- graph any of whose vertex has the same degree k
- spanning subgraph
- one having all vertices of the original graph
- The followings are equivalent.
- A subgraph H ? G(V,E) is a 1-factor of G.
- E(H) (a set of edges in H) is a matching of V.
G
2-regular
M2 (matched)
unmatched
4Notation in this section
- G (V, E) bipartite graph with bipartition A,
B - VA ? B, A ? B ?.
- a, a, represent vertices in A. No edge between
a, a. - b, b, represent vertices in B. No edge between
b, b.
b
ab
a
A
B
A
B
A
B
Examples of matchings
G
5Matching and augmenting paths (1/3)
- How can we find a (large) matching?
- By expanding a small one with augmenting paths.
- Augmenting path
- Starts an unmatched vertex in A, and ends at an
unmatched one in B. - Vertices except 1st and last in the path are
attached to edges in M. - In finding an augmenting path, the followings are
repeated - Move from A to B through an edge in E M.
- Move from B to A through an edge in M.
A
B
A
B
Augmenting path P
Matching M
6Matching and augmenting paths (2/3)
- How can we find a (large) matching?
- By expanding a small one with augmenting paths.
- Suppose M and an augmenting path P are given.
- (E(P) ? M) ?(M ? E(P)) is also a matching.
- Each vertex on P is incident with just one edge
in E(P) ? M. Then E(P) ? M is a matching. - M ? E(P) is obviously a matching.
- These sets do not share any vertex, so the union
is also a matching.
A
B
A
B
A
B
Matching M
Augmenting path P
Matching M
7Matching and augmenting paths (3/3)
- How can we find a matching?
- By expanding a small one with augmenting paths.
- Two new vertices (the first and the last vertices
in the path) are included in the new matching
with one expansion. - Alternating path
- Augmenting one w/o the condition on the end
vertex. - The end is not necessarily an unmatched vertex in
B.
A
B
A
B
A
B
Matching M
Augmenting path P
Matching M
8Exercise 1
- Suppose that M is a matching not maximal.
- M has less edges than some other matching M in
G. - Then G contains an augmenting path w.r.t. M.
- Proof
- A edge e in M M is an augmenting path.
- What happens when M is not maximum but maximal?
(HW)
A
B
A
B
A
B
A
B
G
Matching M
Aug. path w.r.t. M
New matching M
9Vertex cover
- A set U ? E is a vertex cover of E if every edge
of G is incident with a vertex in U.
not a v. cover
v. cover
A
B
A
B
A
B
A
B
v. cover
not a v. cover
G
G
10Theorem 2.1.1 (König 1931) (1/6)
- Let M and U be a maximum matching and a minimum
vertex cover in G(A ? B, E). - Then, M U.
- Its proof consists of three parts.
- Show that M ? U, where U is any vertex
cover. - Construct U from M, where UM.
- If U is a vertex cover, it is the minimum since
M ? U. - Show that U is a (minimum) vertex cover.
11Theorem 2.1.1 (König 1931) (2/6)
- Proof for M ? U (showing M?T?U)
- www.cs.mcgill.ca/kaleigh/teaching/360_tutorials/t
utorial_07.html - All the endpoints of the edges in M are distinct.
-- (1) - By definition of matching.
- A vertex cover T of M requires at least one end
for each edge in M. -- (2) - T then has to have at least M vertices
(M?T). - G contains at least the same edges of M.
- To cover edges in M, U (vc of G) must be at
least T.
T
U
(1)
(2)
G
12Theorem 2.1.1 (König 1931) (3/6)
- Construction of U from M
- We will construct a vertex cover U from M as
follows - Choose one end a or b from each edge ab ? M as
follows - Choose b in B if some alternating path ends in
the vertex. - Choose a in A otherwise.
Alternating paths
Vertex cover
A
B
A
B
A
B
A
B
13Theorem 2.1.1 (König 1931) (4/6)
- Proof that U is a vertex cover
- For any edge ab?E(G), show a?U or b?U (that is,
ab is covered by U) ().
a
b
b
ab ? M for some b
Any matching incident with a or b ?
ab ? M
ab ? M for some a
a
ab ? M and ab ? M for any a and b
a
ab ? E
ab ? M?
b
a
b
ab?M is a matching. This contradicts with
that M is maximum.
ab ? M
By the construction of U, a?U or b?U ().
14Theorem 2.1.1 (König 1931) (5/6)
- Proof that U is a vertex cover
- For any edge ab?E(G), show a?U or b?U (that is,
ab is covered by U) ().
ai
bj
ak
b
P
b
b?U since ab?M. Since b is selected, there
must be an alt. path P ending at b by
definition of U.
a
b
a?U
ab?M for some b
impossible
a?U?
ab ? E
Any matching incident with a or b ?
()
a?U
ab is an alt. path. Since ab?M, b?U by def. of
U. ()
a
b
a
ab ? M for some a
15Theorem 2.1.1 (König 1931) (6/6)
- Proof that U is a vertex cover
- For any edge ab?E(G), show a?U or b?U (that is,
ab is covered by U) ().
b
PPb
(if b?P)
ai
bj
ak
a
b
b
b
P
ai
bj
ak
ai
bj
ak
a
b
b
b
P
(if b?P)
PPbab
b?U since ab?M. b is selected, then there must
be an alt. path P ending at b by definition of
U.
From P, we can create an alt. path P ending
at b.
P is an aug. path ending at b.
A matching larger than M can be obtained with
P.
a?U
M is not maximum. Then, a must be in U.
ab ? E
a?U?
16Conditions for the existence of 1-factor
- Consider a matching containing all vertices in A.
- Necessary condition
- N(S)?S for all S ? A (the marriage condition
MC), where - S any subset of A
- N(S) neighbors of vertices in S
- The condition is in fact a sufficient condition.
Matching of A unavailable
S
N(S) 3 2 2
S 3 2 1
N(S) 3 1 1
S 3 2 1
a, a, a
a, a, a
a, a
a, a
a
a
17Theorem 2.1.2 (Hall 1935) (1/5)
- G contains a matching M of A iff N(S)?S for
all S ? A. - (?)
- a ? A has at least one neighbor, i.e.,
N(a)?a1. - For any a?A, there is an edge ab in M for some
b?B. - Neighbors of a and a in M can be distinct if a ?
a. - We can choose the other ends of a, a in M as the
neighbors. - For any S, at least S distinct neighbors can be
found. - That is, N(S)?S for all S ? A.
18Theorem 2.1.2 (Hall 1935) (2/5)
- G contains a matching iff N(S)?S for all S ?
A. - We follow here the third proof in the textbook.
- (?)
- Consider a spanning subgraph H of G that
- satisfies the marriage condition (MC), and
- is edge-minimal with MC.
- Note dH(a)NH(a)?a1for every a?A by MC.
- We show dH(a) 1 for every a?A.
- Then, E(H) forms a matching of A.
- MC guarantees that no two such edges can share a
vertex in B.
a
dH(a)1
a1,a22, N(a1,a2)1.
dH(a)1
a
19Theorem 2.1.2 (Hall 1935) (3/5)
- G contains a matching iff N(S)?S for all S ?
A. - (?)
- Proof by contradiction on H
- Suppose dH(a) ?2, and the neighbors are b1 and
b2. - Since the edge of H is minimal for MC, H ab1
and H ab2 should violate MC for some A1, A2 ?
A. - Bi NH abi(Ai).
b1
b1
A1
A1 NH (A1)
A2 NH (A2)
b2
b2
a
a
A1gt NH ab1(A1) B1
A2gt NH ab2(A2) B2
A2
B1
B2
20Theorem 2.1.2 (Hall 1935) (4/5)
- G contains a matching iff N(S)?S for all S ?
A. - (?)
- NH(A1?A2 a) ? NH-ab1-ab2(A1?A2)
- ? NH-ab1-ab2(A1 )
?NH-ab1-ab2(A2) - B1 ? B2
- B1 B2 B1
? B2 -
b1
b1
A1
b2
b2
B1?B2
B1? B2
B1
B2
a
a
A2
NH(A1?A2 a)
B1?B2
21Theorem 2.1.2 (Hall 1935) (5/5)
- G contains a matching iff N(S)?S for all S ?
A. - (?)
- NH( A1?A2 a) ?
- ? B1 B2 B1
? B2 - ? A1 1 A2
1 A1 ? A2 - By the definition of Ai and Bi (Ai gt Bi ?
Ai 1 ? Bi) - A1 A2 A1
? A2 2 - A1?A2 2
A1?A2 a 1. - Hence H violates the marriage condition, contrary
to the assumption. - Therefore, dH(a) 1 for every a?A.
22Corollary 2.1.3
- If G is k-regular with k? 1, then G has a
1-factor. - k-factor a k-regular spanning subgraph
- k-regular
- graph any of whose vertex has the same degree k
- spanning subgraph
- one having all vertices of the original graph
- A 1-factor is also called a perfect matching.
2-regular
3-regular
Its 1-factor
Its 1-factor
23Proof of Corollary 2.1.3 (1/2)
- AB.
- Since G is k-regular, dA?v?Ad(v)kA and
dB?v?Bd(v)kB. - Since G is bipartite, each edge connects a vertex
in A to a vertex in B. Then, dA dB, that is,
kAkB. - We will see that N(S)?S for all S ? A.
- By Theorem 2.1.2, G then has a 1-factor (perfect
matching).
dA 34
dB 34
24Proof of Corollary 2.1.3 (2/2)
- We will see that N(S)?S for all S ? A.
- Every set S ? A is joined to N(S) by kS edges.
- These kS edges ( ) are among the kN(S)
edges ( ) of G incident with N(S). - Then, kS ? kN(S) for any S, which satisfies
the condition of Theorem 2.1.2. - Since AB, every vertex is included in the
matching.
kN(S) edges
kS edges
S
N(S)
S
N(N(S))
N(S)
N(S)
N(N(S))
25Stable matching (1/2)
- Suppose a graph G and its preference are given.
- For example, the following matching is unstable.
- Because choosing pair (A, M) as a matching makes
both A and M happier. - A and M might be going to break the current
matching (engagement) for their preference. - A matching is called stable if it has no such
pair.
ranks of preference
?
?
Alice (A)
Kathy (K)
A K M N B L K C L M D M N L
K B A L D B C M A C D N D A
Bill (B)
Lucy (L)
Charles (C)
Mary (M)
David (D)
Nancy (N)
This example was taken from a transcript of a
lecture http//www.misojiro.t.u-tokyo.ac.jp/iwat
a/dmi/dmi03j.pdf
26Stable matching (2/2)
- A stable matching M is defined as follows
- For any e (a, b) in E M, there exists some f ?
M s.t - f ?a e or f ?b e,
- where f ?a e denotes the order of preference for
edges of a. - In the example below, (A, K) ?A (A, M) ?A (A, N).
ranks of preference
?
?
Alice (A)
Kathy (K)
A K M N B L K C L M D M N L
K B A L D B C M A C D N D A
Bill (B)
Lucy (L)
Charles (C)
Mary (M)
David (D)
Nancy (N)
This example was taken from a transcript of a
lecture http//www.misojiro.t.u-tokyo.ac.jp/iwat
a/dmi/dmi03j.pdf
27Theorem 2.1.4 (Gale and Shapley 1962)
- For every set of preferences, G has a stable
matching. - Its proof is based on an algorithm called the
Gale-Shapley algorithm to find a stable matching
for G. - The algorithm finds a male-optimal matching.
- By interchanging a set of males and a set of
females, it is also able to find a female-optimal
matching. - Note that a stable matching is not unique.
- There might be another stable matching having
them happier. - It depends on the definition of happiness.
28Gale-Shapley algorithm
- Algorithm GS(G) G(A,B, E)
- MuA
- while Mu??
- for each a?Mu a is an unengaged man
- Mu proposal(a, b) s.t. b?B is highest-ranked
not yet proposed to for a) - end-for
- end-while
- function proposal(a, b)
- if b is engaged with someone, say, a
- if a ltb a then b is engaged with a MuMu ?
a - a - else b keeps the engagement with a
- else b is engaged with a MuMu - a
- return Mu
29Example of results by the G-S algorithm
?
?
A K M N B L K C L M D M N L
K B A L D B C M A C D N D A
Each of A, B, C, and D proposed to 1st-ranked
female. C failed to find his fiance.
?
?
C proposed to the highest-ranked female not yet
proposed to. M changed her fiance, and D then
lost his fiance.
A K M N B L K C L M D M N L
K B A L D B C M A C D N D A
D proposed to the highest- ranked female not yet
proposed to. Then, each of them has found
her/his fiance.
30Proof for Theorem 2.1.4 (1/2)
- We will see G-S finds a stable matching by
following the transcript. - It terminates in finite steps because the number
of candidates for proposal is monotonically
decreased in the while loop of the G-S algorithm. - The matching the G-S algorithm finds is stable.
- Suppose that there is an unstable pair in the
result of G-S. - The pair (a, b), where (a, b) ?a (a, b), (a,
b) ?b (a, b). - In the matching by G-S, (a, b) and (a, b) are
selected.
a
b
?
?
a b b a b
b a b a a
a
b
31Proof for Theorem 2.1.4 (2/2)
- Suppose that there is an unstable pair in the
result of G-S. - The pair (a, b), where (a, b) ?A (a, b), (a,
b) ?b (a, b). - In the matching by G-S, (a, b) and (a, b) were
selected. - By the construction of G-S, it must be that the
proposed to b by a must be taken place before
the proposal to b by a. - This case can be occurred only when (1) or (2).
- (1) b refused the proposal from a.
- (1) never happens because (a, b) ?b (a, b),
and then b also should refuse the proposal from
a. - (2) b accepted the proposal from a by breaking
the relation with a. - (2) never happens because b should engage with
a, not a when a proposed to b. - From these observations, any matching by G-S is
always stable.
?
?
a b b a b
b a b a a
32Corollary 2.1.5
- Every regular graph G of positive even degree 2k
has a 2-factor. - Proof consists of three steps.
- G contains an Euler tour.
- Every vertex in G is replaced by a pair (v, v-).
- The resulting graph is k-regular bipartite graph.
- By Corollary 2.1.3, a k-regular bipartite graph
has a 1-factor. - Every pair is collapsed into a single vertex.
- The 1-factor graph is turned into a 2-factor
graph.
33Proof of Corollary 2.1.5 (1/3)
- G contains an Euler tour by Theorem 1.8.1.
- Theorem 1.8.1 A connected graph is Eulerian iff
every vertex has even degree. - If G is not a connected graph, we consider each
connected subgraph for the corollary.
Former and latter halves of an Euler tour
4-regular
34Proof of Corollary 2.1.5 (2/3)
- Every vertex in G is replaced by a pair (v, v-).
- Edge (vi, vi1) by (vi, v-i1).
- The resulting graph is a k-regular bipartite
graph.
-
35Proof of Corollary 2.1.5 (3/3)
- Every vertex in G is replaced by a pair (v, v-).
- The resulting graph is a k-regular bipartite
graph. - By Corollary 2.1.3, a k-regular bipartite graph
has a 1-factor. - Every pair is collapsed into a single vertex.
- The 1-factor graph is turned into a 2-factor
graph.
1-factor
k-regular bipartite
2-factor
-
36Any Questions?
37Theorem 2.1.1 (König 1931) (3/6)
- Construction of U from M
- We will construct a vertex cover U from M as
follows - Choose one end a or b from each edge ab ? M as
follows - Choose b in B if some alternating path ends in
the vertex. - Some edge in E M is incident with b.
- Choose a in A otherwise.
A
B
A
B
A
B
38Any Questions?
39Any Questions?
40Any Questions?