graph theory chapter 8 hamiltonian graphs 大葉大學 (da-yeh univ.) 資訊工程系 (dept. csie)...
DESCRIPTION
Copyright 黃鈴玲 Ch An Introduction to Hamiltonian Graphs Definition: A graph of G is called Hamiltonian if G has a spanning cycle. A dodecahedron ( 正 12 面體 ) A hamiltonian cycleTRANSCRIPT
Graph TheoryGraph TheoryChapter 8Chapter 8 Hamiltonian GraphsHamiltonian Graphs
大葉大學大葉大學 (Da-Yeh (Da-Yeh Univ.)Univ.)資訊工程系資訊工程系 (Dept. (Dept. CSIE)CSIE)黃鈴玲黃鈴玲 (Lingling (Lingling Huang)Huang)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-22
OutlineOutline
8.1 An Introduction to 8.1 An Introduction to Hamiltonian GraphsHamiltonian Graphs
8.28.2 Which Graphs are Which Graphs are Hamiltonian?Hamiltonian?
8.3 The Traveling Salesman 8.3 The Traveling Salesman ProblemProblem
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-33
8.1 An Introduction to 8.1 An Introduction to Hamiltonian GraphsHamiltonian GraphsDefinition: A graph of G is called Hamiltonian if G
has a spanning cycle.
A dodecahedron ( 正 12 面體 )
A hamiltonian cycle
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-44
KnightKnight’’s Tour Puzzles Tour Puzzle
Is it possible for a knight to tour the chessboard (nn), that is, visit each squareexactly once and return to its initial square?
4 4 chessboard: 此走法不存在8 8 chessboard: 存在 , see Fig 8-2
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-55
pf: (By induction on n) Base: (n=3) OK Inductive: Assume the (n1)-cube is
hamiltonian. Consider the n-cube:
Ex1: Show that the graph of the n-cube is hamiltonian.
3 - cube
(n 1)-cube (n 1)-cube
xy y’
x’
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-66
Ex2Ex2: Show that the graph : Show that the graph GG below is below is not hamiltonian. not hamiltonian.
hamiltonian cycle hamiltonian cycle 必定包含這些必定包含這些edge.edge.
Hint:Hint: 考慮通過此三點的考慮通過此三點的edgeedge
本身已構成本身已構成 cyclecycle ,,故不可能故不可能 hamiltonian hamiltonian
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-77
Observe:1. Cn (n3) is hamiltonian.hamiltonian.2. Kn (n3) is hamiltonian.hamiltonian.3. A connected graph with cut-vertices is not hamiltonian.hamiltonian.
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-88
G1
G3
Gn
G2
pf:pf: G G is hamiltonian is hamiltonian a hamiltonian cycle a hamiltonian cycle CC
Suppose Suppose kk((GGSS) = ) = nn, where , where GG11, , GG22,,……, , GGnn are components of are components of GGS.S.
Let Let uuii (1 (1 ii nn) be the last vertex of ) be the last vertex of CC that belongs to that belongs to GGii..
Let Let vvii be the vertex be the vertex that immediately that immediately follows follows uuii on on CC..((uuii 的下一點即是的下一點即是 vvii 且且 vvii SS))
Thm 8.1:Thm 8.1: If If GG is hamiltonian, than is hamiltonian, than kk((G G SS) ) | |SS| | for every for every SS VV((GG), ), SS ..
C…
v1
v3
vn
v2
u1
un
u3
u2
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-99
(1) (1) vvii SS, , ii (2) (2) vvjj vvk k ,, if if jj kk ||SS| | nn ∴ ∴ kk((GGSS) ) | |S|.|.
G1
G3
Gn
G2
C
…
v1
v3
vn
v2
u1
un
u3
u2
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1010
pf: pf: 例如例如 KK2,32,3
上與下兩個上與下兩個 part part 點數不一致點數不一致∴∴無法有無法有 hamiltonian cyclehamiltonian cycle
Ex5:Ex5: Show that no bipartite graph Show that no bipartite graph of odd order is hamiltonian.of odd order is hamiltonian.
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1111
HomeworkHomework
Exercise 8.1:Exercise 8.1: 1, 2, 3, 4, 5 1, 2, 3, 4, 5
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1212
OutlineOutline
8.1 An Introduction to 8.1 An Introduction to Hamiltonian Graphs Hamiltonian Graphs
8.28.2 Which Graphs are Which Graphs are Hamiltonian?Hamiltonian?
8.3 The Traveling Salesman 8.3 The Traveling Salesman ProblemProblem
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1313
8.28.2 Which Graphs are Which Graphs are Hamiltonian?Hamiltonian?
Thm 8.2 (Dirac’s Thm)G: order p 3If deg(v) p/2 v V(G), then G is Hamiltonian.
Pf: (1) If p = 3 degdeg((vv) ) 22 vv VV((GG) ) GG CC33
(2) If p 44, , let let PP: : vv1 1 ,v,v2 2 ,…, ,…, vvn n be a longest path in G.
v1 v2 v3 vn-1
vn
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1414
Then every neighbor of v1 and vn is on P.
∵ ∵ deg(v) p/2 ∴ ∴ nn 1+p/2
Claim: vi V(P), 2 i n, s. t., v1~ vi and vi1~ vn .
pf of claim:
If not, vj with vj ~ v1 vj1 ~ vn
∵ ∵ deg(v1) p/2
∴ ∴v1 到 vn1 中至少有 至少有 pp/2/2 個點與個點與 vn 不相連不相連 ∵ ∵ deg(vn) p/2
∴ ∴ 此此 pathpath 至少有 至少有 p/2 ++ p/2 + + 11 個點 個點
v1
v2 v3vi1
vnvn-1vi
(vn)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1515
Let C: v1, v2, …, vi1, vn, vn1, …, vi, v1
C is a cycle of length n.If n<p then u V(GC) ∵ ∵ deg(u) p/2, |V(C)| = n 1+ p/2∴ ∴ vk s.t. u ~ vk (1 k n)∴ ∴ CC∪{∪{uvk}} contains a path longer than
P. n n = = pp C is a Hamiltonian cycle.※ Thm8.2 中 deg(v) p/2 的條件若改為 (p1)/2 則不保證存在 hamiltonian cycle. 例 : Kn, n+1
v1
v2 v3vi1
vnvn-1vi
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1616
※Thm8.2 不能 cover 的例子 : (1) Cn (n 5): hamiltonian p 5, deg(vi) = 2< p/2 i
(2) +(Km U Kn): hamiltonian2K
Fig 8-5: +(K2 U K3) 2K
p = m + n + 2Suppose m < n,deg(v) = m + 1 < p/2 if vV(Km)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1717
Thm8.3 Let G be a graph of order p 3.
Suppose u and v are nonadjacent vertices of G s.t. deg(u) + deg(v) p. Then G is hamiltonian iff G+uv is hamiltonian.
Pf: “”: trivial. “”: Let C be a hamiltonian cycle of G+uv. If uv C G is hamiltonian. If uv C spanning u-v path P (P = C uv)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1818
P :
(P 上使用了所有點 ) Similar as the proof of Thm8.2, G has a
hamiltonian cycle.
u v
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-1919
上述定理提供了判斷圖形是否 hamiltonian 的一種方法 重複將不相連但 degree 和 p 的兩點連一條邊 新圖形是否 hamiltonian 決定了原圖是否 hamiltonian
Fig 8-6
p=7 Not hamiltonian!
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2020
Def:Def: A A closureclosure cc((GG)) of a graph of a graph GG of of
order order pp is a graph obtained from is a graph obtained from GG by recursively joining pairs of by recursively joining pairs of nonadjacent vertices whose nonadjacent vertices whose degree sum is at least degree sum is at least pp until no until no such pairs remain.such pairs remain.
※ cc((GG)) is unique.is unique.
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2121
Thm8.5Thm8.5 GG is hamiltonianis hamiltonian cc((GG)) is hamiltonian.is hamiltonian.
Cor8.5(a) Let G be a graph of order p3. If c(G) KKp p , , then then GG is hamiltonian. is hamiltonian.Fig 8.7
G is hamiltonian.c(G) KK99G
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2222
Cor8.5(b) |V(G)| = p 3. u,v V(G). If deg(u) + deg(v) p u ~ v,
then then GG is hamiltonian.is hamiltonian.Cor8.5(c) |V(G)| = p 3. Let d1, d2, …dp be the degree sequence
of G with d1 d2 … dp. Suppose for every k < p/2,dk k dpk p k. ThenThen GG is hamiltonian.is hamiltonian.
Cor8.5(d) |V(G)| = p, |E(G)| = q. If q , thenthen GG is is
hamiltonian.hamiltonian.2
21
p
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2323
Ex5.Ex5. Show that if a graph of order Show that if a graph of order at least 3 has an isolated vertex or an end-3 has an isolated vertex or an end-vertex, then its closure is not complete.vertex, then its closure is not complete.
pf:(1) If u is an isolated vertex of graph G, then deg(u) = 0, deg(v) p2 for every vertex v u.
In c(G), u ~ v u v c(G) Kp
(2) If u is an end-vertex then deg(u) = 1, deg(v) p2 if u ~ v c(G) Kp
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2424
HomeworkHomework
Exercise 8.2:Exercise 8.2: 1, 3, 4, 8, 9, 11 1, 3, 4, 8, 9, 11
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2525
OutlineOutline
8.1 An Introduction to 8.1 An Introduction to Hamiltonian Graphs Hamiltonian Graphs
8.28.2 Which Graphs are Which Graphs are Hamiltonian?Hamiltonian?
8.3 The Traveling Salesman 8.3 The Traveling Salesman ProblemProblem
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2626
8.3 The Traveling 8.3 The Traveling Salesman ProblemSalesman Problem
GG:: connected weighted graph,connected weighted graph, vvi i VV((GG)): the cities,: the cities, ww((vviivvjj)) of edgeof edge vviivvjj:: the distance to travel the distance to travel directly between directly between vvii andand vvj j .. (Assume that(Assume that GG is complete)is complete)
TSP: Suppose that a salesman is required to make a round trip through a given collection of p(3) cities. What route should he take to minimize the total distance traveled?
※ ※ TSP asks for a Hamiltonian cycle of minimum weight.TSP asks for a Hamiltonian cycle of minimum weight.
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2727
此處提供兩種作法此處提供兩種作法前提前提 : : 需先符合需先符合 triangle inequality (triangle inequality ( 三角不等三角不等
式式 )) ww((vvii,v,vkk) ) ww((vvii,v,vjj) + ) + ww((vvjj,v,vkk))
vi
vj
vk
∵∵NP-complete NP-complete ∴∴改成 改成 find low weight find low weight 的 的 HCHCTSP:TSP: Given a weighted complete graph Given a weighted complete graph G G and a positive constant and a positive constant BB, does there , does there exist a hamiltonian cycle exist a hamiltonian cycle CC in in GG so that so that ww((CC) ) BB??
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2828
Algorithm 8.1 Algorithm 8.1 (a greedy algorithm)(a greedy algorithm)[ To determine a low weight HC in a weighted complete graph G of order p3 satisfying the triangle inequality. ]1. n 1. (n is the cycle length) 2. Select any vertex of G to form Cn.
(Cn 剛開始只有一個點 )3. If n < p, then find a vertex vn not on Cn s.t.
w(unvn) is minimum for some un is on Cn, and go to Step 4. Otherwise, Cn is the desired HC.
4. Let Cn+1 be the (n+1)-cycle obtained by inserting vn immediately before un on Cn.
5. n n +1 and return to Step 3.
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-2929
1. 1. CC11: : vv11
2.2. ∵ ∵ vv22,, ……,, vv66 中,中, ww((vv11vv44)) 最小最小 ∴∴CC22: : vv11vv44vv11
3.3.
∵ ∵ ww((vv33vv44) ) 最小最小 ∴∴CC33: : vv11vv33vv44vv1 1
(( 加在要連的點之前加在要連的點之前 ))
0 4 5 4 5 34 0 5 4 5 75 5 0 1 4 24 4 1 0 3 35 5 4 3 0 33 7 2 3 3 0
M
v1 v2 v3 v4 v5 v6v1
v2 v3 v4 v5 v6
Fig 8-10Fig 8-10
v2 v3 v5 v6
v1
v4 55143733
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3030
v2 v5 v6
v1
v3
v4
3 7 3
3 4 4 4 5 5
7 3
5 5 4 4 5 5
v5 v6
v1
v2
v3
v4
v5 v1
v2
v3
v4
v6
7 5 4 5 4
∵ ∵ ww((vv11vv22)) 最小最小∴∴CC44: : vv11vv33vv44vv22vv11
5.5. 6.6.
CC55:: vv11vv33vv44vv22vv66vv11 CC66: : vv11vv55vv33vv44vv22vv66vv11
4.4.
CC66 的 的 weight weight 總和為總和為 2424, , 而而 min weight min weight 為為 1818..若改選別的點當若改選別的點當 CC11,, 可能 可能 weight weight 總和總和更小更小 ..
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3131
Thm 8.8Thm 8.8 C :: a a HC given by Algorithm 8.1given by Algorithm 8.1 Cm :: min weightmin weight HC w((C)) 2 2 w((Cm))
(Algorithm 8.1(Algorithm 8.1 不保證能找出不保證能找出 min HCmin HC,, 但用 但用 Algorithm 8.1 Algorithm 8.1 找出的找出的 cycle cycle 其其 weightweight 不會大於 不會大於 min HC min HC 的兩倍的兩倍 .).)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3232
Algorithm8.2 Algorithm8.2 (( 利用 利用 min spanning tree)min spanning tree)
1. Find a min spanning tree1. Find a min spanning tree TT of of G.G.2. Conduct a depth-first search of2. Conduct a depth-first search of T. T.
( ( 起點為 起點為 T T 的的 leaf)leaf)3. If3. If vvii11
, , vvii22, …, , …, vviipp
is the order in which the is the order in which the vertices of vertices of TT are visited in step 2, thenare visited in step 2, then output the hamiltonian cycleoutput the hamiltonian cycle vvii11
, , vvii22, …, , …, vviipp
, , vvii11..
[ To determine a low weight HC in a weighted complete graph G of order p3 satisfying the triangle inequality. ]
(Algorithm 8.2 (Algorithm 8.2 找出的找出的 cycle cycle 其 其 weight weight
也不會大於 也不會大於 min HC min HC 的兩倍的兩倍 .).)
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3333
Fig 8-13 ( 原圖同 Fig 8-10)
C: v2,v1,v4,v3,v5,v6,v2
v2
v5
v4
v3
v1
v6
A min spanning tree T(a)
3 3
42
15
3
4
2
6
A depth-first search從 v2 開始
(b)
1 v2
v5
v4
v3
v1
v6
A HC(c)
53
42
1
4
weight weight 總和為總和為 1919
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3434
Exercise 8Exercise 8Use Alg. 8.1 and 8.2 to find a closed walk Use Alg. 8.1 and 8.2 to find a closed walk
whose weight does not exceed twice whose weight does not exceed twice the weight of a shortest closed walk in the weight of a shortest closed walk in the given weighted graph the given weighted graph GG..
Sol:Sol: 先把 先把 G G 變成 變成 completecomplete
Gv2v5
v4 v3
v1
4
1
3
23
5
4
5 73
Gv2v5
v4 v3
v1
1
3
23
5
4
0433140575350323730415240
M
v1 v2 v3 v4 v5v1
v2 v3 v4 v5
Copyright Copyright 黃鈴玲黃鈴玲Ch8-Ch8-3535
HomeworkHomework
Exercise 8.3:Exercise 8.3: 1, 3, 4, 8 1, 3, 4, 8