Graph Theory Chapter 6 Matchings and Factorizations 大葉大學 (Da-Yeh Univ.) 資訊工程系...

40
Graph Theory Graph Theory Chapter 6 Chapter 6 Matchings and Matchings and Factorizations Factorizations 大大大大 大大大大 (Da-Yeh Univ.) (Da-Yeh Univ.) 大大大大大 大大大大大 (Dept. CSIE) (Dept. CSIE) 大大大 大大大 (Lingling Huang) (Lingling Huang)

Transcript of Graph Theory Chapter 6 Matchings and Factorizations 大葉大學 (Da-Yeh Univ.) 資訊工程系...

Graph TheoryGraph Theory

Chapter 6Chapter 6 Matchings and Matchings and Factorizations Factorizations

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-22

OutlineOutline

6.1 An Introduction to Matchings6.1 An Introduction to Matchings

6.2 Maximum Matchings in 6.2 Maximum Matchings in Bipartite Graphs Bipartite Graphs

6.3 Maximum Matchings in 6.3 Maximum Matchings in General General Graphs Graphs

6.4 Factorizations6.4 Factorizations

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-33

6.1 An Introduction to 6.1 An Introduction to Matchings Matchings

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

Marriage Problem: Given a collection of men and women, whereeach woman knows some of the men, under whatconditions can every woman marry a man she knows? A variation of this problem is to find themaximum number of woman, each of whom canmarry a man she knows.

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-44

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 Copyright 黃鈴玲黃鈴玲Ch6-Ch6-55

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-66

Model the problem: weighted bipartite graph G = (S1S2, E), S1={applicants}, S2={jobs}, a S1, b S2, 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 Copyright 黃鈴玲黃鈴玲Ch6-Ch6-77

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.

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-88

cM = { ab, cd, ef }is a maximum matchingM’ = { bc, de } is maximal, not maximum.

ab

d

e

f

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-99

Definition:Definition:If If GG is a graph of order is a graph of order pp that has a that has a matching of cardinality matching of cardinality pp/2, then such a /2, then such a matching is called a matching is called a perfect matchingperfect matching..

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

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1010

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.

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1111

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

21 3 1

1

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1212

Definition:Definition:

MM : a matching of a graph : a matching of a graph GG, , ee: an edge, : an edge, vv: a vertex : a vertex

(1). (1). eeMM : : ee is called a is called a matched edgematched edge

(2). (2). ee MM : : ee is an is an unmatched edgeunmatched edge

(3). (3). vv is a is a matched vertexmatched vertex if if vv is incident with ais incident with a matched edge; matched edge; vv is a is a single vertexsingle vertex otherwise. otherwise.

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

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1313

An augmenting path An augmenting path PP of of GG : :

PP 中的邊將中的邊將 MM 的與的與 MM 的性質交換,的性質交換,MM 中的邊數會加一。中的邊數會加一。

MM MM MM MM MM MM

Singlevertex

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1414

Thm 6.1 :Thm 6.1 :

MM11, , MM22 : matchings of : matchings of GG

EE=(=(MM11MM22)∪()∪(MM22MM11), ), HH is the is the spanning spanning subgraphsubgraph of of GG with with EE((HH)=)=EE, then every, then every component of component of HH is one of the following is one of the following

type: type:

(a) (a) KK11

(b) (b) CC22nn for some for some nn (c) a path (alternating path)(c) a path (alternating path)

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1515

G :

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

H 裡沒有 degree 3 的點

M1

M2

Example:

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1616

Thm 6.2Thm 6.2

A matching A matching MM in a graph in a graph GG is a maximum is a maximum

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

Pf:Pf:) trivial) trivial) by Thm 6.1) by Thm 6.1

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1717

HomeworkHomework

Exercise 6.1:Exercise 6.1: 1 1

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1818

OutlineOutline

6.1 An Introduction to Matchings6.1 An Introduction to Matchings

6.2 Maximum Matchings in 6.2 Maximum Matchings in Bipartite Graphs Bipartite Graphs

6.3 Maximum Matchings in 6.3 Maximum Matchings in General General Graphs Graphs

6.4 Factorizations6.4 Factorizations

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-1919

6.2 Maximum 6.2 Maximum Matchings in Bipartite Matchings in Bipartite GraphsGraphs

Algorithm 6.1 Algorithm 6.1 (A maximum matching (A maximum matching algorithm for bipartite graphs)algorithm for bipartite graphs)[To determine a maximum matching in a bipartite graph [To determine a maximum matching in a bipartite graph GG with with VV((GG)={)={vv11, , vv22, …, , …, vvpp}} and an and an initial matchinginitial matching MM11.].]

1. 1. ii 1, 1, MM MM11

2. If 2. If ii < < pp, then continue; , then continue; otherwise, stop, otherwise, stop, MM is a maximum matching now. is a maximum matching now.

3. If 3. If vvii is matched, then is matched, then ii ii +1 and return to Step 2; +1 and return to Step 2;otherwise, otherwise, vv vvii and and QQ is initialized to contain is initialized to contain vv only.only.

4. 4.1 For 4. 4.1 For j j = 1, 2, …, = 1, 2, …, pp and and j j ii,, let Tree( let Tree(vvjj)=)=FF. . ( ( 表示表示 vvjj 不在不在 alternating treealternating tree 中中 )) Also, Tree(Also, Tree(vvii)=)=TT. .

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2020

4.2 If 4.2 If QQ== , then , then ii ii +1 and return to step 2; +1 and return to step 2; otherwise, delete a vertex otherwise, delete a vertex xx from from QQ and continue. and continue.

4.3 4.3 4.3.1 Suppose that 4.3.1 Suppose that NN((xx)={)={yy11, , yy22, …, , …, yykk}.}. Let Let jj 1. 1. 4.3.2 If 4.3.2 If j j kk, then , then y y yyjj; otherwise, return to Step ; otherwise, return to Step 4.2.4.2.

4.3.3 If Tree(4.3.3 If Tree(yy)=)=TT, then , then jj j + j + 1 and return to1 and return to Step 4.3.2; otherwise, continue. Step 4.3.2; otherwise, continue. 4.3.44.3.4 If If yy is incident with a matched edge is incident with a matched edge yzyz, then , then Tree( Tree(yy))TT, Tree(, Tree(zz))TT, Parent(, Parent(yy))xx, Parent(, Parent(zz))yy and add and add zz to Q, to Q, jj j + j + 1, and return to Step 1, and return to Step 4.3.2. 4.3.2. Otherwise, Otherwise, yy is a single vertex ( is a single vertex ( 找到了找到了 !!) ) and we continue. and we continue. 4.3.5 Use array Parent to determine the alternating 4.3.5 Use array Parent to determine the alternating vv--xx path path P’P’ in the tree. Let in the tree. Let P P P’P’U{U{xyxy} be the } be the augmenting path. augmenting path.

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2121

Example (Fig Example (Fig 6.6)6.6)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

x3x5

y6

y1

x1

y4

x4

y3

x6

y5

x3 x5 x4 x1 x6

Augmenting path

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2222

Example (Fig 6.6)Example (Fig 6.6)

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.

MM = { = { xx22yy66, , xx55yy44, , xx11yy11, , xx44yy33, , xx33yy22, , xx66yy55 } } is maximum. is maximum.

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2323

HomeworkHomework

Exercise 6.2:Exercise 6.2: 3 3

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2424

OutlineOutline

6.1 An Introduction to Matchings6.1 An Introduction to Matchings

6.2 Maximum Matchings in 6.2 Maximum Matchings in Bipartite Graphs Bipartite Graphs

6.3 Maximum Matchings in 6.3 Maximum Matchings in General General Graphs Graphs

6.4 Factorizations6.4 Factorizations

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2525

6.3 Maximum 6.3 Maximum Matchings in General Matchings in General GraphsGraphs For general graphs, the task of For general graphs, the task of

finding augmenting paths is finding augmenting paths is complicated by the presence of complicated by the presence of odd cycles that have a maximum odd cycles that have a maximum number of matched edges.number of matched edges.

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2626

w

v

c

a

b

u

z

y

d

v

w

Initial matching M1

Example (Fig Example (Fig 6.9)6.9)

x

a

c

d

d

c

b

u

y

x

w

v

v

w

x

y

zAugmenting path

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2727

2

4

56

11

8

3

7

9

Initial matching M1

Example (Fig Example (Fig 6.10)6.10)

10

4

2

5

3

1

6

8

7

9

9

7

10Augmenting path

1

8

6

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2828

HomeworkHomework

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-2929

OutlineOutline

6.1 An Introduction to Matchings6.1 An Introduction to Matchings

6.2 Maximum Matchings in 6.2 Maximum Matchings in Bipartite Graphs Bipartite Graphs

6.3 Maximum Matchings in 6.3 Maximum Matchings in General General Graphs Graphs

6.4 Factorizations6.4 Factorizations

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3030

6.4 Factorizations6.4 Factorizations

Definition.Definition. A A factor factor of a graph of a graph GG is a is a spanning subgraph of spanning subgraph of GG. (It is possible that . (It is possible that a factor has no edges.) Suppose that a factor has no edges.) Suppose that GG11, , GG22, , ……, , GGnn are pairwise edge-disjoint spanning are pairwise edge-disjoint spanning

subgraphs of subgraphs of GG such that U such that Unnii=1=1EE((GGii) = ) = EE((GG). ).

Then Then GG is is factorablefactorable or or factored factored into the into the subgraphs or subgraphs or factorsfactors GG11, , GG22, , ……, , GGnn, and we , and we write write GG = = GG11 GG22 …… GGnn. This expression . This expression is also called a is also called a factorization factorization of of GG into the into the factors factors GG11, , GG22, , ……, , GGnn..

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3131

Definition.Definition. An An rr-regular factor of a -regular factor of a graph graph GG is an is an rr-factor-factor of of GG. .

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

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

In this case, In this case, GG is is kk-regular for some -regular for some kk that is that is a multiple of a multiple of rr..

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3232

H1

HH2

H3

A 1-factorization of K3,3

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3333

H

A 2-factorization of K5

H1

H2

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3434

A 1-factorable cubic (3-regular)graph

G

H2 H3H1

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3535

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

Proof. (by induction on Proof. (by induction on rr))

Theorem 6.11Theorem 6.11 For every positive For every positive integer integer nn, the graph , the graph KK22nn is 1- is 1-factorable. factorable.

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3636

A 1-factorization of K6

H1 H2

H3H4

H5

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3737

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

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

Theorem 6.12Theorem 6.12 For every positive For every positive integer integer nn, the graph , the graph KK22n+n+11 is can be is can be factored into factored into nnHamiltonian cycles. Hamiltonian cycles.

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3838

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 Copyright 黃鈴玲黃鈴玲Ch6-Ch6-3939

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

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

Copyright Copyright 黃鈴玲黃鈴玲Ch6-Ch6-4040

HomeworkHomework

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

C4K2 :

Ex 3. Show that CnK2 is 1-factoriable for every n 4.