1 of 40

Graph TheoryChapter 6� Matchings and � Factorizations

大葉大學(Da-Yeh Univ.)�資訊工程系(Dept. CSIE)�黃鈴玲(Lingling Huang)

2 of 40

Outline

6.1 An Introduction to Matchings

6.2 Maximum Matchings in � Bipartite Graphs

6.3 Maximum Matchings in General � Graphs

6.4 Factorizations

Ch6-2

Copyright © 黃鈴玲

3 of 40

6.1 An Introduction to � Matchings

Ch6-3

Focus: � Find 1-regular subgraphs of maximum � size in a graph.

Marriage Problem: Given a collection of men and women, where�each woman knows some of the men, under what�conditions can every woman marry a man she �knows? A variation of this problem is to find the�maximum number of woman, each of whom can�marry a man she knows.

Copyright © 黃鈴玲

4 of 40

Ch6-4

Model the problem: bipartite graph G = (S1S2, E),S1={men}, S2={women}, � abE if a knows b.�(1) Under what conditions does G have a 1-regular� subgraph that contains all the vertices that� represent the women?�(2) What is the maximum size of a 1-regular� subgraph of G?

Copyright © 黃鈴玲

5 of 40

Ch6-5

Optimal Assignment Problem: Given several job openings and applicants for �one or more of these positions. The hiring company�wishes to receive the maximum possible benefit as �a result of its hiring. For example, the experience�of the applicants may be an important factor to �consider during the hiring process. The company �may benefit by employing fewer people with more�experience than a larger number with less�experience.

Copyright © 黃鈴玲

6 of 40

Ch6-6

Model the problem: weighted bipartite graph G = (S1S2, E),S1={applicants}, S2={jobs}, � aS1, bS2, abE if a has applied b,� w(a,b) is the benefit that the company will� gain by hiring applicant a.��⇒ To find a 1-regular subgraph H of G where� the sum of the weights of the edges in H is� a maximum.

Copyright © 黃鈴玲

7 of 40

Definition:

A matching in a graph G is a 1-regular subgraph of G, that is, a subgraph induced by a collection of pairwise nonadjacent edges. �We also refer to a matching as a collection of edges that induces a matching.

A matching of maximum cardinality in a graph G is called a maximum matching of G.

Ch6-7

Copyright © 黃鈴玲

8 of 40

Ch6-8

c

M = { ab, cd, ef }is a maximum matching

M’ = { bc, de } is maximal,

not maximum.

a

b

d

e

f

Maximum (所有matching中最多edge的)� ≥ Maximal (此matching不可再加邊成為� 更大的matching)

Copyright © 黃鈴玲

9 of 40

Definition:�If G is a graph of order p that has a matching of cardinality p/2, then such a matching is called a perfect matching.

Ch6-9

Note:�If a graph of order p has a perfect matching, then p must be even.

反之未必成立�e.g. K1,3 has even order but no perfect matching.

Copyright © 黃鈴玲

10 of 40

Definition:

A matching in a weighted graph G is a set of edges of G, no two of which are adjacent. A maximum weight matching in a weighted graph is a matching in which the sum of the weights of its edges is maximum.

Ch6-10

Note:�A maximum weight matching need not be a maximum matching.

Copyright © 黃鈴玲

11 of 40

Ch6-11

M = { v1v2, v3v5 }is a maximum weight matching (weight sum=4)

M’ = {v1v2, v3v4, v5v6 }is a maximum matching

v1

v2

v3

v5

v6

v4

2

1

3

1

1

Copyright © 黃鈴玲

12 of 40

Definition:

M : a matching of a graph G, �e: an edge, v: a vertex

(1). eM : e is called a matched edge

(2). eM : e is an unmatched edge

(3). v is a matched vertex if v is incident with a� matched edge; v is a single vertex otherwise.

(4). An alternating path of G is a path whose � edges are alternately matched and unmatched.

(5). An augmenting path of G is an alternating � path that begins and ends with single vertices.

Ch6-12

Copyright © 黃鈴玲

13 of 40

An augmenting path P of G :

Ch6-13

P中的邊將∈M的與∉M的性質交換,

M中的邊數會加一。

∉M

∈M

∉M

∈M

∈M

∉M

Single�vertex

Copyright © 黃鈴玲

14 of 40

Thm 6.1 :

M1, M2 : matchings of G

E=(M1M2)∪(M2M1), H is the spanning

subgraph of G with E(H)=E, then every

component of H is one of the following � type:

(a) K1

(b) C2n for some n

(c) a path (alternating path)

Ch6-14

Copyright © 黃鈴玲

15 of 40

Ch6-15

G :

H : ( V(H)=V(G) )

H裡沒有degree ≥ 3的點

M1M2

Example:

Copyright © 黃鈴玲

16 of 40

Thm 6.2

A matching M in a graph G is a maximum

matching if and only if there is no augmenting path, with respect to M, in G.

Ch6-16

Pf:

⇒) trivial

⇐) by Thm 6.1

Copyright © 黃鈴玲

17 of 40

Homework

Exercise 6.1:� 1

Ch6-17

Copyright © 黃鈴玲

18 of 40

Outline

6.1 An Introduction to Matchings

6.2 Maximum Matchings in � Bipartite Graphs

6.3 Maximum Matchings in General � Graphs

6.4 Factorizations

Ch6-18

Copyright © 黃鈴玲

19 of 40

6.2 Maximum Matchings in Bipartite Graphs

Algorithm 6.1 (A maximum matching algorithm for bipartite graphs)[To determine a maximum matching in a bipartite graph G with V(G)={v1, v2, …, vp} and an initial matching M1.]

1. i ←1, MM1

2. If i < p, then continue; �otherwise, stop, M is a maximum matching now.

3. If vi is matched, then ii +1 and return to Step 2;�otherwise, vvi and Q is initialized to contain v only.

4. 4.1 For j = 1, 2, …, p and j i, let Tree(vj)=F. � (表示vj不在alternating tree中)Also, Tree(vi)=T.

Ch6-19

Copyright © 黃鈴玲

20 of 40

4.2 If Q=∅ , then ii +1 and return to step 2; � otherwise, delete a vertex x from Q and continue.

4.3 � 4.3.1 Suppose that N(x)={y1, y2, …, yk}. Let j ← 1.� 4.3.2 If j k, then y yj; otherwise, return to Step 4.2.

4.3.3 If Tree(y)=T, then jj + 1 and return to� Step 4.3.2; otherwise, continue.� 4.3.4 If y is incident with a matched edge yz, then � Tree(y)←T, Tree(z)←T, Parent(y)←x, Parent(z)←y � and add z to Q, jj + 1, and return to Step 4.3.2. � Otherwise, y is a single vertex (找到了!) � and we continue.� 4.3.5 Use array Parent to determine the alternating � v-x path P’ in the tree. Let P P’U{xy} be the � augmenting path.

5. Augment M along P to obtain a new matching M’. �Let M M’, ii +1 , and return to step 2.

Ch6-20

Copyright © 黃鈴玲

21 of 40

Example (Fig 6.6)

Ch6-21

x1

x2

x3

x4

x5

x6

y1

y2

y3

y4

y5

y6

Initial matching M1

i=1, x1 is matched.

i=2, v=x2

Q :

x2

x2

y2

x3

x5

y6

y1

x1

y4

x4

y3

x6

y5

x3

x5

x4

x1

x6

Augmenting path

Copyright © 黃鈴玲

22 of 40

Example (Fig 6.6)

Ch6-22

x1

x2

x3

x4

x5

x6

y1

y2

y3

y4

y5

y6

New matching M

i=3, x3 is matched.

i=4, x4 is matched.

i=12, y6 is matched.

M = { x2y6, x5y4, x1y1, x4y3, x3y2, x6y5 } is maximum.

Copyright © 黃鈴玲

23 of 40

Homework

Exercise 6.2:� 3

Ch6-23

Copyright © 黃鈴玲

24 of 40

Outline

6.1 An Introduction to Matchings

6.2 Maximum Matchings in � Bipartite Graphs

6.3 Maximum Matchings in General � Graphs

6.4 Factorizations

Ch6-24

Copyright © 黃鈴玲

25 of 40

6.3 Maximum Matchings in General Graphs

  • For general graphs, the task of finding augmenting paths is complicated by the presence of odd cycles that have a maximum number of matched edges.

Ch6-25

⇒ 將Alg 6.1 修改為tree中允許點重複,�但每點不可同時是自己的祖先

Copyright © 黃鈴玲

26 of 40

Example (Fig 6.9)

Ch6-26

w

v

c

a

b

u

z

y

d

v

w

Initial matching M1

x

a

c

d

d

c

b

u

y

x

w

v

v

w

x

y

z

Augmenting path

Copyright © 黃鈴玲

27 of 40

Example (Fig 6.10)

Ch6-27

2

4

5

6

11

8

3

7

9

Initial matching M1

10

4

2

5

3

1

6

8

7

9

9

7

10

Augmenting path

1

8

6

Copyright © 黃鈴玲

28 of 40

Homework

Exercise 6.3:� 3 (先任給一個matching)

Ch6-28

Copyright © 黃鈴玲

29 of 40

Outline

6.1 An Introduction to Matchings

6.2 Maximum Matchings in � Bipartite Graphs

6.3 Maximum Matchings in General � Graphs

6.4 Factorizations

Ch6-29

Copyright © 黃鈴玲

30 of 40

6.4 Factorizations

Definition. A factor of a graph G is a spanning subgraph of G. (It is possible that a factor has no edges.) Suppose that G1, G2, , Gn are pairwise edge-disjoint spanning subgraphs of G such that Uni=1E(Gi) = E(G). Then G is factorable or factored into the subgraphs or factors G1, G2, , Gn, and we write G = G1G2Gn. This expression is also called a factorization of G into the factors G1, G2, , Gn.

Ch6-30

Copyright © 黃鈴玲

31 of 40

Definition. An r-regular factor of a graph G is an r-factor of G.

Ch6-31

Thus, a graph has a 1-factor if and only if it contains a perfect matching.

Definition. If there is a factorization of a graph G into r-factors, then G is said to be r-factorable.

In this case, G is k-regular for some k that is a multiple of r.

Copyright © 黃鈴玲

32 of 40

Ch6-32

H1

H

H2

H3

A 1-factorization of K3,3

Copyright © 黃鈴玲

33 of 40

Ch6-33

H

A 2-factorization of K5

H1

H2

Copyright © 黃鈴玲

34 of 40

Ch6-34

A 1-factorable cubic (3-regular)graph

G

H2

H3

H1

Copyright © 黃鈴玲

35 of 40

Theorem 6.10 Every regular bipartite multigraph of degree r ≥ 1 is 1-factorable.

Ch6-35

Proof. (by induction on r)

Theorem 6.11 For every positive integer n, the graph K2n is 1-factorable.

Proof. (參考下頁K6的分解方法)

Copyright © 黃鈴玲

36 of 40

Ch6-36

A 1-factorization of K6

H1

H2

H3

H4

H5

中心點 v 每次先連一點 x,再將剩下的點配對,�產生的邊需垂直於 vx

Copyright © 黃鈴玲

37 of 40

Ch6-37

Definition A spanning cycle in a graph G is called a Hamiltonian cycle.

Proof. (參考下頁K7的分解方法)

Theorem 6.12 For every positive integer n, the graph K2n+1 is can be factored into n�Hamiltonian cycles.

Copyright © 黃鈴玲

38 of 40

Ch6-38

3 Hamiltonian cycles of K7

F1

v0

v1

v2

v3

v4

v5

v6

F2

v0

v1

v2

v3

v4

v5

v6

F3

v0

v1

v2

v3

v4

v5

v6

Copyright © 黃鈴玲

39 of 40

Ch6-39

Petersen Graph �(在圖論的一些性質中常扮演反例的角色)

Petersen graph is not 1-factorable.�(證明略過)

Copyright © 黃鈴玲

40 of 40

Homework

Exercise 6.4:� 3, 4 (參考Fig 6.14)

Ch6-40

C4×K2 :

Ex 3. Show that Cn×K2 is 1-factoriable for every n ≥ 4.

Copyright © 黃鈴玲