Chapter 8 Hamiltonian Graphs

Download Report

Transcript Chapter 8 Hamiltonian Graphs

Graph Theory
Chapter 8
Hamiltonian Graphs
大葉大學(Da-Yeh Univ.)
資訊工程系(Dept. CSIE)
黃鈴玲(Lingling Huang)
Outline
8.1 An Introduction to Hamiltonian
Graphs
8.2 Which Graphs are Hamiltonian?
8.3 The Traveling Salesman
Problem
Ch8-2
Copyright  黃鈴玲
8.1 An Introduction to
Hamiltonian Graphs
Definition:
A graph of G is called Hamiltonian if G has
a spanning cycle.

A dodecahedron (正12面體)
A hamiltonian cycle
Ch8-3
Copyright  黃鈴玲
Knight’s Tour Puzzle
Is it possible for a knight to tour the
chessboard (nn), that is, visit each square
exactly once and return to its initial square?
4  4 chessboard:
此走法不存在
8  8 chessboard:
存在, see Fig 8-2
Ch8-4
Copyright  黃鈴玲
Ex1: Show that the graph of the n-cube
is hamiltonian.
pf: (By induction on n)
Base: (n=3) OK
Inductive: Assume the (n-1)-cube is
hamiltonian. Consider the n-cube:
x’
x
y
3 - cube
(n -1)-cube
y’
(n -1)-cube
Ch8-5
Copyright  黃鈴玲
Ex2: Show that the graph G below is
not hamiltonian.
Hint:考慮通過此三點的edge
 hamiltonian cycle
必定包含這些edge.
 本身已構成cycle,
故不可能hamiltonian
Ch8-6
Copyright  黃鈴玲
Observe:
1. Cn (n3) is hamiltonian.
2. Kn (n3) is hamiltonian.
3. A connected graph with cut-vertices is not
hamiltonian.
Ch8-7
Copyright  黃鈴玲
Thm 8.1:
If G is hamiltonian, than k(G - S)  |S|
for every S  V(G), S  .
pf: G is hamiltonian   a hamiltonian cycle C
Suppose k(G-S) = n, where G1, G2,…, Gn
are components of G-S.
Let ui (1  i  n) be the last vertex of C
that belongs to Gi.
un vn
Gn
G1
Let vi be the vertex
…
that immediately
u1
C
v3
follows ui on C.
v1
u3
(ui的下一點即是vi且vi S)
G3
v2 u2
G2
Ch8-8
Copyright  黃鈴玲
 (1) vi S, i
(2) vj  vk , if j  k
 |S| 
n
∴ k(G-S)  |S|.
Gn
un vn
G1
…
u1
C
v3
v1
u3
G3
v2 u2
G2
Ch8-9
Copyright  黃鈴玲
Ex5: Show that no bipartite graph of
odd order is hamiltonian.
pf: 例如K2,3
上與下兩個part 點數不一致
∴無法有 hamiltonian cycle
Ch8-10
Copyright  黃鈴玲
Homework
Exercise 8.1:
1, 2, 3, 4, 5
Ch8-11
Copyright  黃鈴玲
Outline
8.1 An Introduction to Hamiltonian
Graphs
8.2 Which Graphs are Hamiltonian?
8.3 The Traveling Salesman
Problem
Ch8-12
Copyright  黃鈴玲
8.2 Which Graphs are
Hamiltonian?
Thm 8.2 (Dirac’s Thm)
G: order p  3
If deg(v)  p/2 v V(G), then G is Hamiltonian.
Pf: (1) If p = 3  deg(v)  2 v V(G)  G  C3
(2) If p  4,
let P: v1 ,v2 ,…, vn be a longest path in G.
v1
v2
v3
vn
vn-1
Ch8-13
Copyright  黃鈴玲
Then every neighbor of v1 and vn is on P.
∵ deg(v)  p/2
∴ n  1+p/2
Claim:  vi V(P), 2  i  n, s. t., v1~ vi and vi-1~ vn .
pf of claim:
v1
v2
v3
v i- 1
vi
vn-1
vn
If not,  vj with vj ~ v1  vj-1 ~ vn
∵ deg(v1)  p/2
∴v1到vn-1中至少有 p/2 個點與vn不相連
∵ deg(vn)  p/2
∴此path 至少有 p/2 + p/2 + 1 個點 
Ch8-14
(vn)
Copyright  黃鈴玲
Let C: v1, v2, …, vi-1, vn, vn-1, …, vi, v1
C is a cycle of length n.
If n<p then  u  V(G-C)
∵ deg(u)  p/2, |V(C)| = n  1+ p/2
∴  vk s.t. u ~ vk (1  k  n)
∴ C∪{uvk} contains a path longer than P.

v1
vn-1
n=p
vi
v
v
v
2
3
vn
i- 1
 C is a Hamiltonian cycle.
※ Thm8.2 中 deg(v)  p/2 的條件若改為 (p-1)/2
則不保證存在 hamiltonian cycle. 例: Kn, n+1
Ch8-15
Copyright  黃鈴玲
※Thm8.2 不能cover 的例子:
(1) Cn (n  5): hamiltonian
p  5, deg(vi) = 2< p/2  i
(2) K 2 +(Km U Kn): hamiltonian
p=m+n+2
Suppose m < n,
deg(v) = m + 1 < p/2 if vV(Km)
Fig 8-5: K 2+(K2 U K3)
Ch8-16
Copyright  黃鈴玲
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)
Ch8-17
Copyright  黃鈴玲
P:
u
v
(P上使用了所有點)
Similar as the proof of Thm8.2, G has a
hamiltonian cycle.
Ch8-18
Copyright  黃鈴玲
上述定理提供了判斷圖形是否 hamiltonian 的一種方法
 重複將不相連但degree 和  p 的兩點連一條邊
新圖形是否 hamiltonian 決定了原圖是否hamiltonian
Fig 8-6

p=7


Not hamiltonian!
Ch8-19
Copyright  黃鈴玲
Def:
A closure c(G) of a graph G of order p
is a graph obtained from G by
recursively joining pairs of
nonadjacent vertices whose degree
sum is at least p until no such pairs
remain.
※ c(G) is unique.
Ch8-20
Copyright  黃鈴玲
Thm8.5
G is hamiltonian  c(G) is hamiltonian.
Cor8.5(a)
Let G be a graph of order p3.
If c(G)  Kp , then G is hamiltonian.
Fig 8.7
G
c(G)  K9
 G is hamiltonian.
Ch8-21
Copyright  黃鈴玲
Cor8.5(b)
|V(G)| = p  3. u,v  V(G). If deg(u) + deg(v)  p  u ~ v,
then G 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  dp-k  p - k. Then G is hamiltonian.
Cor8.5(d)
|V(G)| = p, |E(G)| = q. If q   p - 1  2 , then G is
 2 
hamiltonian.
Ch8-22
Copyright  黃鈴玲
Ex5. Show that if a graph of order at least 3
has an isolated vertex or an end-vertex,
then its closure is not complete.
pf:
(1) If u is an isolated vertex of graph G, then
deg(u) = 0, deg(v)  p-2 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)  p-2 if u ~ v
 c(G)  Kp
Ch8-23
Copyright  黃鈴玲
Homework
Exercise 8.2:
1, 3, 4, 8, 9, 11
Ch8-24
Copyright  黃鈴玲
Outline
8.1 An Introduction to Hamiltonian
Graphs
8.2 Which Graphs are Hamiltonian?
8.3 The Traveling Salesman
Problem
Ch8-25
Copyright  黃鈴玲
8.3 The Traveling Salesman
Problem
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?
 G: connected weighted graph,
vi  V(G): the cities,
w(vivj) of edge vivj: the distance to travel
directly between vi and vj .
(Assume that G is complete)
※ TSP asks for a Hamiltonian cycle of minimum weight.
Ch8-26
Copyright  黃鈴玲
∵NP-complete
∴改成 find low weight 的 HC
TSP: Given a weighted complete graph G and a
positive constant B, does there exist a
hamiltonian cycle C in G so that w(C)  B?
此處提供兩種作法
前提: 需先符合triangle inequality (三角不等式)
w(vi,vk)  w(vi,vj) + w(vj,vk)
vi
vj
vk
Ch8-27
Copyright  黃鈴玲
Algorithm 8.1 (a greedy algorithm)
[ To determine a low weight HC in a weighted complete
graph G of order p3 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.
Ch8-28
Copyright  黃鈴玲
Fig 8-10
v1
v2
v3
M 
v4
v5
v6
v1 v2 v3 v4 v5 v6
0
3

3

2
7


3
3
0
3
4
5
5
3
3
0
1
4
4
2
4
1
0
5
5
7
5
4
5
0
4
3
5

4

5
4

0

1. C1: v1
2. ∵ v2, …, v6中,w(v1v4)最小
∴C2: v1v4v1
v2 v3 v5 v6
3.
v1 3
v4 4
3
1
7
5
3
5
∵ w(v3v4) 最小
∴C3: v1v3v4v1
(加在要連的點之前)
Ch8-29
Copyright  黃鈴玲
4.
v2 v5 v6
v1 3 7 3
v3 3 4 4
v4 4 5 5
5.
v5 v6
v1
v2
v3
v4
7
3
5
5
4
4
5
5
C5: v1v3v4v2v6v1
∵ w(v1v2) 最小
∴C4: v1v3v4v2v1
6.
v5
v1
v2
v3
v4
v6
7
5
4
5
4
C6: v1v5v3v4v2v6v1
C6的 weight 總和為24, 而min weight 為18.
若改選別的點當C1,可能 weight 總和更小.
Ch8-30
Copyright  黃鈴玲
Thm 8.8
C : a HC given by Algorithm 8.1
Cm : min weight HC
 w(C)  2  w(Cm)
(Algorithm 8.1不保證能找出min HC,
但用 Algorithm 8.1 找出的cycle 其weight
不會大於 min HC 的兩倍.)
Ch8-31
Copyright  黃鈴玲
Algorithm8.2 (利用 min spanning tree)
[ To determine a low weight HC in a weighted complete
graph G of order p3 satisfying the triangle inequality. ]
1. Find a min spanning tree T of G.
2. Conduct a depth-first search of T.
(起點為 T 的leaf)
3. If vi1, vi2, …, vip is the order in which the
vertices of T are visited in step 2, then
output the hamiltonian cycle
vi1, vi2, …, vip, vi1.
(Algorithm 8.2 找出的cycle 其 weight
也不會大於 min HC 的兩倍.)
Ch8-32
Copyright  黃鈴玲
Fig 8-13 (原圖同Fig 8-10)
v1
3
v1
3
v2
v6
v5
2
6
1
v6
4
4
v5
2
4
v3
5
1
v4
A min spanning tree T
(a)
3
A depth-first search
從v2開始
(b)
C: v2,v1,v4,v3,v5,v6,v2
3
5
v2
2
4
1
v3
v4
A HC
(c)
weight 總和為19
Ch8-33
Copyright  黃鈴玲
Exercise 8
Use Alg. 8.1 and 8.2 to find a closed walk
whose weight does not exceed twice the
weight of a shortest closed walk in the given
weighted graph G.
v1
G
Sol:
1
2
3
v2
先把 G 變成 complete
v5
v1 v2 v3 v4 v5
v1
G
4
1
3
v5
4
3
v4
2
5
v2
7
5
3
v3
v1  0
v2  4

M  v3  2
v4 5
v5 1
4 2 5 1
0 3 7 3
3 0 5 3

7 5 0 4
3 3 4 0
3
4
v4
5
v3
Ch8-34
Copyright  黃鈴玲
Homework
Exercise 8.3:
1, 3, 4, 8
Ch8-35
Copyright  黃鈴玲