graph theory chapter 7 eulerian graphs 大葉大學 (da-yeh univ.) 資訊工程系 (dept. csie)...

24
Graph Theory Graph Theory Chapter 7 Chapter 7 Eulerian Graphs Eulerian Graphs 大大大大 大大大大 (Da-Yeh Univ.) (Da-Yeh Univ.) 大大大大大 大大大大大 (Dept. CSIE) (Dept. CSIE) 大大大 大大大 (Lingling Huang) (Lingling Huang)

Upload: julius-jennings

Post on 01-Jan-2016

263 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Graph TheoryGraph Theory

Chapter 7Chapter 7 Eulerian Graphs Eulerian Graphs

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

Page 2: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-22

OutlineOutline

7.1 An Introduction to Eulerian 7.1 An Introduction to Eulerian GraphsGraphs

7.2 Characterizing Eulerian 7.2 Characterizing Eulerian Graphs AgainGraphs Again

7.3 The Chinese Postman 7.3 The Chinese Postman ProblemProblem

Page 3: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-33

7.1 An Introduction to 7.1 An Introduction to Eulerian GraphsEulerian Graphs 1736, Euler solved the 1736, Euler solved the Königsberg Königsberg

Bridge Problem (Bridge Problem ( 七橋問題七橋問題 ))

Q: Q: 是否存在一 是否存在一 種走法,可以走種走法,可以走過每座橋一次,過每座橋一次,並回到起點?並回到起點?

Page 4: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-44

Königsberg Bridge ProblemKönigsberg Bridge Problem

Ans: 因為每次經過一個點,都需要從一條邊進入該點,再用另一條邊離開,所以經過每個點一次要使用掉一對邊。

每個點上連接的邊數必須是偶數才行

此種走法不存在

A

B

C

D

Q: Q: 是否存在一種走法,可以走過每條邊一次,並是否存在一種走法,可以走過每條邊一次,並回到起點?回到起點?

陸地為點

橋為邊

Page 5: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-55

Definition: (1) An eulerian circuit of a connected multigraph is a circuit ( 點可重複、邊不可重複 ) of G that contains all the edges of G.(2) A (multi)graph with an eulerian circuit is called an eulerian (multi)graph.(3) An eulerian trail of a connected multigraph G is an open trail ( 起點終點不同的 trail) of G that contains all the edges of G.

Page 6: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-66

u9 u8

u2

u3

u4

u5 u6

u7

u1

G1

v5 v4

v3

v2

v1

v6

G2

eulerian circuit:

eulerian trail:

Page 7: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-77

Theorem 7.1:Theorem 7.1:A connected multigraph G is A connected multigraph G is eulerian if and only if the degree of eulerian if and only if the degree of each vertex is even.each vertex is even.

Pf: ()G is eulerian eulerian circuit C

C 通過每一點時需用一條邊進入,用另一條邊離開 the degree of each vertex is eventhe degree of each vertex is even

()

Suppose every vertex of G is even.(Now we construct an eulerian circuit.)

Page 8: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-88

Choose any vertex Choose any vertex vv and begin a trail and begin a trail TT (( 邊不可重複邊不可重複 ) at ) at vv as far as possible. as far as possible.

If If ww is the last vertex of is the last vertex of T T, then any edge , then any edge incident with incident with ww must belong to must belong to TT..

Claim:Claim: ww==vvPf. If Pf. If wwvv, then each time , then each time ww is is

encountered on T before the last time, encountered on T before the last time, one edge is used to enter one edge is used to enter ww and another and another edge is used to exit from edge is used to exit from ww. .

Since Since ww has even degree. There must be has even degree. There must be at least one edge incident with at least one edge incident with ww that that does not belong to does not belong to TT, a contradiction. , a contradiction.

If If EE((TT) ) EE((GG), ), 在在 GGTT 中重複此法找出一個個的中重複此法找出一個個的circuitcircuit ,連接起來即可得,連接起來即可得 eulerian circuit.eulerian circuit.

Page 9: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-99

v1v2

Figure 7.4 (Algorithm 7.1, Eulerian circuit)

v3v5

v4

v6

Step 1:

T1: v1, v2, v3, v4, v5, v1

Step 2:

T2: v3, v5, v6, v3

Step 3:

C = T1 T2

C: v1, v2, v3, v5, v6, v3, v4, v5, v1

T2

Page 10: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1010

Theorem 7.2:Theorem 7.2:Let Let GG be a nontrivial connected be a nontrivial connected

multigraph. Then multigraph. Then GG contains an contains an eulerian eulerian trailtrail if and only if if and only if GG has has exactly two odd vertices. exactly two odd vertices.

Furthermore, the trail begins at one Furthermore, the trail begins at one of the odd vertices and of the odd vertices and terminates at the other.terminates at the other.

Page 11: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1111

HomeworkHomework

Exercise 7.1:Exercise 7.1: 1, 2 1, 2

Page 12: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1212

OutlineOutline

7.1 An Introduction to Eulerian 7.1 An Introduction to Eulerian GraphsGraphs

7.2 Characterizing Eulerian 7.2 Characterizing Eulerian Graphs AgainGraphs Again

7.3 The Chinese Postman 7.3 The Chinese Postman ProblemProblem

Page 13: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1313

7.2 Characterizing 7.2 Characterizing Eulerian Graphs AgainEulerian Graphs Again

Theorem 7.3:Theorem 7.3:A connected graph A connected graph GG is eulerian if and is eulerian if and

only if every edge of only if every edge of GG lies on an odd lies on an odd number of cycles of number of cycles of GG..

Page 14: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1414

Example (Figure 7.5)

C1: u, v, x, uz

x a

u v

y

w b

Consider the edge Consider the edge uvuv,,it belongs to it belongs to fivefive cycles: cycles:

C2: u, v, y, x, u

C3: u, v, y, z, x, u

C4: u, v, w, y, z, x, u

C5: u, v, w, y, x, u

Page 15: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1515

HomeworkHomework

Exercise 7.2: 4(Exercise 7.2: 4(aa))

Ex4(a). Show that each edge of Kn belongs to at least 2n2 1 cycles.

C4:

Example: Example: KK55

C3: 31

3

1

25

32

3

2

25

C5: 13

3

3

25

122

2

3

2

2

2

1

2 2

n

n

nnnn

Page 16: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1616

OutlineOutline

7.1 An Introduction to Eulerian 7.1 An Introduction to Eulerian GraphsGraphs

7.2 Characterizing Eulerian 7.2 Characterizing Eulerian Graphs AgainGraphs Again

7.3 The Chinese Postman 7.3 The Chinese Postman ProblemProblem

Page 17: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1717

7.3 The Chinese 7.3 The Chinese Postman ProblemPostman Problem

Chinese Postman Problem:Chinese Postman Problem:

Suppose that a letter carrier must deliver mail Suppose that a letter carrier must deliver mail to every house in a small town. The carrier to every house in a small town. The carrier would like to cover the route in the most would like to cover the route in the most efficient way and then return to the post office. efficient way and then return to the post office.

Definition:Definition:For a connected graph For a connected graph GG, an , an eulerian walkeulerian walk

is ais ashortestshortest closed walk covering all the closed walk covering all the

edges of edges of GG.. finding an eulerian walkfinding an eulerian walk

Page 18: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1818

An alternative way to solve the Chinese PostmanAn alternative way to solve the Chinese PostmanProblem:Problem:

For a given connected graph For a given connected graph GG, determine an , determine an eulerian multigrapheulerian multigraph H H of of minimum sizeminimum size that that contains contains GG as its underlying graph. as its underlying graph.

e. g., e. g., 將圖形將圖形 GG 中的每個中的每個 edgeedge 都複製一份都複製一份 每點每點 degreedegree 都會是偶數都會是偶數 新圖有新圖有 eulerian circuiteulerian circuit 存在存在 the length of an eulerian walk of the length of an eulerian walk of GG

is at least is at least qq but no more than but no more than 22qq..

Page 19: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-1919

Definition:Definition:

A A pair partitionpair partition of of VV00((GG) ) is a partition of is a partition of VV00((GG) ) into into

nn two-element subsets. For a pair partition two-element subsets. For a pair partition , ,

given by given by ={{={{uu1111, , uu1212}, {}, {uu2121, , uu2222}, }, ……, {, {uunn11, , uunn22}}.}}.

Let us defineLet us define

and let and let mm((GG)) = min { = min { dd(() | ) | is a pair partition }.is a pair partition }.

If If GG is not eulerian, then is not eulerian, then GG contains an even contains an even

number of odd vertices. number of odd vertices.

Let Let VV00((GG) = {) = {uu11, , uu22, …, , …, uu22nn}, }, n n 1, 1,

be the set of odd vertices of be the set of odd vertices of GG..

n

iii uudd

121 ),()(

Page 20: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-2020

If If GG is eulerian, then is eulerian, then mm((G G ) ) = = 00..

Theorem 7.4If G is a connected graph of size q, then an eulerian walk of G has length q + m(G).

mm((G G )) 代表的是 eulerian walk 中重複走的邊數

※ How to find an eulerian walk of G?(1) Find a pair partition with d() = m(G).(2) If ={{u11, u12}, {u21, u22}, …, {un1, un2}},

determine shortest ui1- ui2 paths Qi.(3) duplicate the edges of G that are on Qi.(4) An eulerian circuit in the new graph provides

an eulerian walk of G.

Page 21: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-2121

※ How to find a pair partition How to find a pair partition of of VV00((GG)) for which for which mm((GG)=)=dd(()?)?

(1) Construct a complete weighted graph (1) Construct a complete weighted graph FF KK22nn of order of order 22nn, where , where VV((FF) = ) = VV00((GG),),

the weight of an edge in the weight of an edge in FF is defined as is defined as the distance between the corresponding the distance between the corresponding vertices in vertices in GG..

(2) Determine a perfect matching of (2) Determine a perfect matching of FF whose whose weight is as small as possible. weight is as small as possible. (Let (Let mm be the maximum weight of be the maximum weight of FF.. 將將 FF 中每邊的中每邊的 weight weight ww 改為改為 mm+1+1ww,, find a maximum matching find a maximum matching 即可即可 ))

Page 22: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-2222

Example (Fig 7.6, solving the Example (Fig 7.6, solving the Chinese Postman Problem)Chinese Postman Problem)

u1

u2

v1

u3

v2

v3

v4

u4 (1) Find odd vertices

(2) Graph F: u1 u2

u4 u3

1

34

3

23

(3) Graph F’:

u1 u2

u4 u3

21

2

32

4

Max matching

(4) add Qi:

u2

v1

u3

v2

v3

v4

u4u1

Page 23: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-2323

(5) Eulerian walk:

u2

v1

u3

v2

v3

v4

u4u1

u1,e12, u2, e10, v3, e3, v4, e1, u4, e2, v4, e4, v3, e7, v2, e8, u3, e5, v3, e6, u3, e9, v1, e11, u2, e13, u1

e13

e12

e6e5

e11

e9

e8e7

e3

e4

e2

e1

e10

Page 24: Graph Theory Chapter 7 Eulerian Graphs 大葉大學 (Da-Yeh Univ.) 資訊工程系 (Dept. CSIE) 黃鈴玲 (Lingling Huang)

Copyright Copyright 黃鈴玲黃鈴玲Ch7-Ch7-2424

HomeworkHomework

Exercise 7.3:Exercise 7.3: 1, 3 1, 3

Ex1. Prove that the length of an eulerian walk for a tree of size q is 2q.