Toán rời rạc | Tài liệu, cơ sở ngành CNTT

807 73 1
Toán rời rạc | Tài liệu, cơ sở ngành CNTT

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Tìm một cách sắp thứ tự các đỉnh để thuật toán tham lam tô màu đồ thị sau dùng ít màu nhất có thể. 17 / 44.[r]

(1)

Phương pháp chứng minh

Trần Vĩnh Đức

HUST

Ngày tháng năm 2018

(2)

Bài tập

▶ GS Mc Brain vợ bà April tới bữa tiệc có đơi vợ chồng khác

▶ Có vài cặp bắt tay khơng bắt tay với vợ chồng

▶ GS hỏi người khác xem họ bắt tay người ông nhận số khác

▶ Hỏi có người bắt tay April?

(3)

Tài liệu tham khảo

▶ Eric Lehman, F Thomson Leighton & Albert R Meyer,

Mathematics for Computer Science, 2013 (Miễn phí)

K Rosen, Toán học rời rạc ứng dụng tin học (Bản dịch Tiếng Việt)

(4)

Định nghĩa

Chứng minh toán học mộtmệnh đề dãysuy luận logic dẫn đến mệnh đề từ tậptiên đề

(5)

Nội dung

Mệnh đề, tiên đề, suy luận logic

Phương pháp chứng minh

(6)

Định nghĩa

Mệnh đề khẳng định hoặc sai

▶ Mệnh đề + = 3

▶ Mệnh đề + = 7

(7)

Khẳng định mệnh đề

▶ “Đưa bánh!” ▶ “Bây giờ”

(8)

Mệnh đề

Với số nguyên dương n, giá trị

p(n) ::= n2+ n + 41

là số nguyên tố

p(0) = 41

p(1) = 43

p(2) = 47

p(3) = 53

· · ·

p(39) = 1601

nhưng

p(40) = 402+ 40 + 41 = 41× 41 7

(9)

Mệnh đề (Giả thuyết Euler, 1769)

Phương trình

a4+ b4+ c4= d4

khơng có nghiệm a, b, c, d số nguyên dương.

Năm 1988, Noam Eikies chứng minh sai với phản ví dụ

a = 95800, b = 217519, c = 414560, d = 422481

(10)

Mệnh đề

Phương trình

313(x3+ y3) = z3 khơng có nghiệm ngun dương

Mệnh đề sai phản ví dụ nhỏ có nhiều 1000 chữ số

(11)

Mệnh đề (Định lý bốn màu)

Mọi đồ tô bốn màu cho hai vùng kề có màu khác

Hình:Bản đồ tơ màu

(12)

Mệnh đề (Định lý bốn màu)

Mọi đồ tơ bốn màu cho hai vùng kề có màu khác

Appel & Hakel phân loại đồ dùng máy tính để kiểm tra xem chúng có tơ màu Họ hoàn tất chứng minh năm 1976 Tuy nhiên

▶ Chứng minh dài để kiểm tra mà khơng dùng máy tính

▶ Khơng đảm bảo chương trình máy tính chạy ▶ Khơng đủ nhiệt tình để kiểm tra hết hàng nghìn trường hợp

đã chứng minh

(13)

Mệnh đề (Định lý cuối Fermat)

Phương trình

xn+ yn= zn khơng có nghiệm nguyên với n≥ 3.

▶ Bài toán viết sách Fermat đọc năm 1630

▶ Andrew Wiles chứng minh năm 1994

(14)

Mệnh đề (Giả thuyết Goldbach)

Mọi số nguyên chẵn lớn tổng hai số nguyên tố

▶ Được giả thuyết năm 1742

▶ Đã khẳng định với số không lớn 1016.

▶ 3 hay 7 ?

(15)

Định nghĩa

Vị từ mệnh đề mà giá trị chân lý phụ thuộc vào nhiều biến

p(n) :: = “n số bình phương hồn hảo” p(4) = “4 số bình phương hồn hảo” p(4) = 3

p(5) = 7

(16)

Phương pháp tiên đề

▶ Thủ tục chuẩn để thiết lập giá trị chân lý toán học phát triển khoảng từ 300 BC Euclid

▶ Bắt đầu từ “giả sử” để xây dựng hình học Euclid Ví dụ:

Qua điểm nằm ngồi đường thẳng ta vẽ được một đường thẳng song song với đường thẳng đã cho.

▶ Các mệnh đề thừa nhận gọi tiên đề

▶ Bắt đầu từ tiên đề này, Euclid thiết lập giá trị chân lý mệnh đề khác cách đưa “chứng minh”

▶ Chứng minh dãy lập luận logic từ tập tiên đề dẫn đến mệnh đề cần chứng minh

(17)

Một số thuật ngữ cho mệnh đề

Mệnh đề quan trọng gọi định lý.

Bổ đề mệnh đề chuẩn bị có ích để chứng minh mệnh

đề khác

Hệ mệnh đề mà chứng minh cần vài bước

từ định lý

(18)

Hệ tiên đề chúng ta

▶ Về bản, toán học đại dựa hệ tiên đề ZFC (Zermelo-Fraekel with Choice) với vài quy tắc suy luận logic

▶ Tuy nhiên, chúng q tối giản Ví dụ, chứng minh hình thức ZFC cho + = cần nhiều 20, 000 bước lập luận!

▶ Trong môn học này, ta thừa nhận kiện tốn “phổ thơng” tiên đề

(19)

Suy luận logic

▶ Luật Modus Ponens:

P, P⇒ Q Q

(Một chứng minh P chứng minh P suy Q là một chứng minh Q)

▶ Luật

P⇒ Q, Q ⇒ R P⇒ R

▶ Luật

¬P ⇒ ¬Q Q⇒ P

(20)

Không phải luật

¬P ⇒ ¬Q

P⇒ Q 7

Ví dụ

▶ Nếu số nguyên tố, “tôi bay” 3

▶ Nếu số ngun tố,thì “tơi biết bay” 7

(21)

Nội dung

Mệnh đề, tiên đề, suy luận logic

Phương pháp chứng minh

(22)

Chứng minh mệnh đề “Nếu thì”

Để chứng minh mệnh đềP⇒ Q:

1. Viết, “Giả sử P”.

2. Chỉ lập luận logic Q đúng.

(23)

Định lý

Nếu 0≤ x ≤ −x3+ 4x + > 0.

Chứng minh

Giả sử 0≤ x ≤ Vậy số

x, +x, 2− x lớn Vậy

x(2− x)(2 + x) ≥ 0

Thêm vào tích ta

x(2− x)(2 + x) + > 0

Khai triển tích ta được−x3+ 4x + > 0.

(24)

Chứng minh phản đảo

Phản đảo mệnh đề P⇒ Q mệnh đề ¬Q ⇒ ¬P. ▶ Ta chứng minh sau:

1. Viết “Ta chứng minh mệnh đề phản đảo:”

và đưa mệnh đề phản đảo

2. Làm phương pháp chứng minh “Nếu thì”

(25)

Định lý

Nếu r số vô tỷ, vậy√r số vô tỷ. Chứng minh

▶ Ta chứng minh mệnh đề phản đảo: Nếu√r số hữu tỉ, r

là số hữu tỉ

▶ Giả sử √r số hữu tỉ Có nghĩa có hai số nguyên p, q cho √r = p/q.

▶ Bình phương hai vế ta

p2

q2 = r

Vì p2, q2 đều số nguyên nên r số hữu tỉ.

(26)

Chứng minh mệnh đề “Nếu nếu”

Có hai cách chứng minh:

1. Chứng minh

P⇔ Q tương đương với hai chứng minh

{

P⇒ Q Q⇒ P

2. Xây dựng dãy “nếu nếu”

(27)

Chứng minh cách chia trường hợp

Định lý

Mọi nhóm gồm người có người đơi quen nhau, đôi lạ

Chứng minh

Xét x người Có hai trường hợp tương tự nhau:

1 Trong người khác x, có người quen x.

2 Trong người khác x, có người lạ x. Tại sao?

(28)

Chứng minh cách chia trường hợp

Định lý

Mọi nhóm gồm người có người đôi quen nhau, đôi lạ

Chứng minh trường hợp

Trong người khác x, có người quen x. Có hai trường hợp con:

1 Khơng có cặp số người quen 3

2 Có cặp người quen Vậy cặp với x tạo thành người quen đôi một. 3

(29)

Chứng minh phản chứng

Để chứng minh mệnh đề P phản chứng:

1. Viết “Ta chứng minh dùng phản chứng”

2. Viết “Giả sử P sai.”

3. Dẫn kiện biết sai (một phản chứng)

4. Viết “Điều mâu thuẫn Vậy P phải đúng.”

(30)

Định lý

2 số vô tỉ

Chứng minh

▶ Ta chứng minh dùng phản chứng ▶ Giả sử 2 số hữu tỉ

▶ Vậy ta viết√2 = p/q dạng phân số tối giản. ▶ Ta có

2 = p

q ⇒ = p2

q2 ⇒ 2q 2= p2

Vậy p chia hết cho Tại sao? Nên p2 chia hết cho 4. ▶ Vậy q2 chia hết cho Nên q chia hết cho 2.

Vậy p/q không tối giản. 7

(31)

Nội dung

Mệnh đề, tiên đề, suy luận logic

Phương pháp chứng minh

(32)

Nguyên lý thứ tự tốt (STTT)

Mọi tập số nguyênkhông âmkhác rỗng có phần tử nhỏ

▶ Tập rỗng khơng có phần tử nhỏ

▶ Khơng với tập số âm Ví dụ tập

{· · · , −3, −2, −1}

▶ Không với tập số hữu tỉ Ví dụ tập {

1 1,

1 2,

1 3, · · ·

}

(33)

Định lý

Mọi số hữu tỉ m/n viết dạng x/y cho x, y khơng có ước chung ngun tố

Chứng minh

Giả sử ngược lại có m, n khơng viết trên.Xét C tập tử sốcủa phân số Vậy C̸= ∅ vì

m∈ C.

Theo nguyên lý STTT, có số nhỏ m0 ∈ C.

Theo định nghĩa tập C, có số n0 để m0/n0 không viết dạng

(34)

Chứng minh (tiếp)

Có nghĩa m0, n0 có ước chung nguyên tố p > Vậy

m0/p

n0/p =

m0

n0

Vì m0/n0 khơng thể viết dạng Vậy mn00/p/p không viết dạng

▶ Vậy ta có

m0

p ∈ C và m0

p < m0 7

(35)

Chứng minh dùng STTT

Để chứng minh P(n) với số nguyên không âm n, ta làm sau

Định nghĩa tập phản ví dụ P :

C ::={n ∈ N | ¬P(n) }

Giả sử phản chứng C̸= ∅.

Bởi nguyên lý STTT có phần tử nhỏ c∈ C.

Đưa phản chứng: thường cách P(c) hoặc chỉ phần tử d∈ C d < c.

Kết luận C rỗng, có nghĩa khơng có phản ví dụ.

(36)

Định lý

Mọi số nguyên dương lớn phân tích thành tích số nguyên tố

Chứng minh STTT

Giả sử tập phản ví dụ định lý C̸= ∅.

Có phần tử n nhỏ thuộc C Vậy n không nguyên tố Có nghĩa

n = a· b với a, b > 1

Hơn a, b phải phân tích thành tích số nguyên tố. Tại sao?

a = p1· · · pk b = q1· · · qm

Vậy n = p1· · · pk· q1· · · qm 7

(37)

Định lý

Mọi số nguyên dương thú vị

Chứng minh

Xét S tập số nguyên dương không thú vị ▶ Nếu S khácrỗng, S chứa phần tử nhỏ n.

▶ Nhưng phần tử nhỏ tập phải tính chất thú vị

Vậy n không thuộc S. 7

(38)

Quy nạp

Trần Vĩnh Đức

HUST

Ngày 24 tháng năm 2018

(39)

Tài liệu tham khảo

▶ Eric Lehman, F Thomson Leighton & Albert R Meyer,

Mathematics for Computer Science, 2013 (Miễn phí)

Kenneth H Rosen, Tốn học rời rạc ứng dụng tin học (Bản dịch Tiếng Việt)

(40)

Nội dung

Nguyên lý quy nạp

(41)

Nguyên lý quy nạp

Xét vị từ P(n) trên N Nếu

P(0) đúng, và

với n∈ N, (P(n) ⇒ P(n + 1)) đúng,

thì P(n) với n∈ N.

8887 868584837879828180

77 76 75 74 73 72 71 70 6968676665

64636255615660575958

54 53 52 51 50 49 48 47 464544

434241403938

373635 34 33 32 31 30 29 28 27 26 25 24 23 2221 20191817

1615141312 11 109 8 7 6 5 4 3 2 1

(42)

Ví dụ

Định lý

Với n∈ N,

1 + +· · · + n = n(n + 1)

Đặt P(n) mệnh đề

n

i=1

i = n(n + 1)

2

(43)

Chứng minh

▶ Bước sở: P(0) đúng.

▶ Bước quy nạp: Ta chứng minh: với n≥ 0, mệnh đề

P(n)⇒ P(n + 1)

đúng

Thật vậy, giả sử P(n) đúng, với n số nguyên Vì

1 + +· · · + n + (n + 1) = (1 + + · · · + n) + (n + 1) = n(n + 1)

2 + (n + 1)

= (n + 1)(n + 2) nên P(n + 1) đúng.

Theo quy nạp ta có P(n) với số n∈ N.

(44)

Ví dụ

Chứng minh

1 2+

1 4+

1

8 +· · · + 2n < 1 với n≥ 1.

(45)

Ví dụ

Định lý

Với n∈ N, ta có n3− n chia hết cho 3. Đặt P(n) mệnh đề

”n3− n chia hết cho 3.”

(46)

Chứng minh

▶ Bước sở: P(0) 03− = chia hết cho 3.

▶ Bước quy nạp: Ta chứng minh rằng, với n∈ N, mệnh

đề

P(n)⇒ P(n + 1)

đúng

Thật vậy, giả sử P(n) đúng, với n số nguyên Vì

(n + 1)3− (n + 1) = n3+ 3n2+ 3n + 1− n − 1 = n3+ 3n2+ 2n

= n3− n + 3n2+ 3n = (n3− n) + 3(n2+ n) chia hết P(n + 1) đúng.

Theo quy nạp ta có P(n) với số n∈ N.

(47)

Ví dụ chứng minh sai

Định lý (Sai)

Mọi ngựa màu Đặt P(n) mệnh đề

”Trong tập gồm n ngựa, ngựa đều cùng màu.”

(48)

Đặt P(n) mệnh đề

”Trong tập gồm n ngựa, ngựa đều cùng màu.”

Chứng minh Sai

▶ Bước sở: P(1) có ngựa.

▶ Bước quy nạp: Giả sử P(n) để chứng minh P(n + 1)

đúng

Xét tập gồm n + ngựa{h1, h2,· · · , hn+1}

Các h1, h2, , hn có màu (giả thiết quy nạp)

Các h2, h3, , hn+1 có màu (giả thiết quy nạp) Vậy

màu(h1) = màu(h2, , hn) = màu(hn+1).

Vậy ngựa {h1, h2,· · · , hn+1} màu Có nghĩa

rằng P(n + 1) đúng.

Theo quy nạp ta có P(n) với số n∈ N.

(49)

Bài tập

1 Chứng minh

n

i=1

i2 = n(n + 1)(2n + 1)

2 Chứng minh 2n > n2 với n≥ 5.

3 Chứng minh với n≥ 1,

F(n− 1)F(n + 1) − F(n2) = (−1)n

với F(i) số Fibonacci thứ i.

(50)

Ví dụ lát gạch

Induction I 31

2.6 Courtyard Tiling

Induction served purely as a proof technique in the preceding examples But induction sometimes can serve as a more general reasoning tool

MIT recently constructed a new computer science building As the project went further and further over budget, there were some radical fundraising ideas One plan was to

install a big courtyard with dimensions 2n⇥ 2n:

2n 2n

One of the central squares would be occupied by a statue of a wealthy potential donor Let’s call him “Bill” (In the special case n = 0, the whole courtyard consists of a single central square; otherwise, there are four central squares.) A complication was that the building’s unconventional architect, Frank Gehry, insisted that only special L-shaped tiles be used:

A courtyard meeting these constraints exsists, at least for n = 2:

B

For larger values of n, is there a way to tile a 2n⇥ 2ncourtyard with L-shaped tiles and a

statue in the center? Let’s try to prove that this is so

Theorem 15. For all n 0there exists a tiling of a 2n⇥ 2n courtyard with Bill in a central square

Hình:Sân

Induction I 31

2.6 Courtyard Tiling

Induction served purely as a proof technique in the preceding examples But induction sometimes can serve as a more general reasoning tool.

MIT recently constructed a new computer science building As the project went further and further over budget, there were some radical fundraising ideas One plan was to install a big courtyard with dimensions 2n ⇥ 2n:

2n 2n

One of the central squares would be occupied by a statue of a wealthy potential donor. Let’s call him “Bill” (In the special case n = 0, the whole courtyard consists of a single central square; otherwise, there are four central squares.) A complication was that the building’s unconventional architect, Frank Gehry, insisted that only special L-shaped tiles be used:

A courtyard meeting these constraints exsists, at least for n = 2:

B

For larger values of n, is there a way to tile a 2n ⇥ 2n courtyard with L-shaped tiles and a

statue in the center? Let’s try to prove that this is so.

Theorem 15. For all n 0 there exists a tiling of a 2n ⇥ 2n courtyard with Bill in a central square.

Hình:Gạch

Induction I 31

2.6 Courtyard Tiling

Induction served purely as a proof technique in the preceding examples But induction sometimes can serve as a more general reasoning tool

MIT recently constructed a new computer science building As the project went further and further over budget, there were some radical fundraising ideas One plan was to install a big courtyard with dimensions 2n⇥ 2n:

2n

2n

One of the central squares would be occupied by a statue of a wealthy potential donor Let’s call him “Bill” (In the special case n = 0, the whole courtyard consists of a single central square; otherwise, there are four central squares.) A complication was that the building’s unconventional architect, Frank Gehry, insisted that only special L-shaped tiles be used:

A courtyard meeting these constraints exsists, at least for n = 2:

B

For larger values of n, is there a way to tile a 2n⇥ 2ncourtyard with L-shaped tiles and a

statue in the center? Let’s try to prove that this is so

Theorem 15. For all n 0there exists a tiling of a 2n⇥ 2ncourtyard with Bill in a central

square

Hình:Lát gạch đặt tượng Bill

(51)

Định lý

Với n, ln có cách lát gạch sân 2n× 2n chỉ để lại ô

trốngở (để đặt tượng Bill)

(52)

Chứng minh thử

Xét P(n) mệnh đề

”Có cách lát gạch sân 2n× 2n để lại ô giữa.”

▶ Bước sở: P(0) có dành cho Bill.

▶ Bước quy nạp: !

(53)

Chứng minh

Xét P(n) mệnh đề

”Với vị trí đặt tượng Bill sân 2n× 2n, ta đều có cách lát gạch kín sân.”

▶ Bước sở: P(0) có

một ô dành cho Bill

▶ Bước quy nạp: Giả sử P(n) đúng,

ta chứng minh P(n + 1) đúng.

32 Induction I

Proof (doomed attempt) The proof is by induction Let P (n) be the proposition that there exists a tiling of a 2n⇥ 2ncourtyard with Bill in the center.

Base case: P (0) is true because Bill fills the whole courtyard

Inductive step: Assume that there is a tiling of a 2n⇥ 2ncourtyard with Bill in the center

for some n We must prove that there is a way to tile a 2n+1⇥ 2n+1courtyard with Bill

in the center

Now we’re in trouble! The ability to tile a smaller courtyard with Bill in the center does not help tile a larger courtyard with Bill in the center We can not bridge the gap between P (n)and P (n + 1) The usual recipe for finding an inductive proof will not work!

When this happens, your first fallback should be to look for a stronger induction hy-pothesis; that is, one which implies your previous hypothesis For example, we could make P (n) the proposition that for every location of Bill in a 2n⇥ 2ncourtyard, there exists

a tiling of the remainder

This advice may sound bizzare: “If you can’t prove something, try to prove something more grand!” But for induction arguments, this makes sense In the inductive step, where you have to prove P (n) ) P (n + 1), you’re in better shape because you can assume P (n), which is now a more general, more useful statement Let’s see how this plays out in the case of courtyard tiling

Proof (successful attempt) The proof is by induction Let P (n) be the proposition that for every location of Bill in a 2n⇥ 2ncourtyard, there exists a tiling of the remainder.

Base case: P (0) is true because Bill fills the whole courtyard

Inductive step: Asume that P (n) is true for some n 0; that is, for every location of Bill in a 2n⇥ 2ncourtyard, there exists a tiling of the remainder Divide the 2n+1⇥ 2n+1courtyard

into four quadrants, each 2n⇥ 2n One quadrant contains Bill (B in the diagram below).

Place a temporary Bill (X in the diagram) in each of the three central squares lying outside this quadrant:

X X X

B

2n 2n

2n

2n

Theo quy nạp ta có P(n) với số n∈ N.

(54)

15-Puzzle“mcs-ftl” — 2010/9/8 — 0:40 — page 59 — #65

3.3 Invariants 59

25 26 24 22 21 : 23 (a) 25 26 24 22 21 : 23 (b)

Figure 3.5 The 15-puzzle in its starting configuration (a) and after the 12-block is moved into the hole below (b)

26 25 24 22 21 : 23

Figure 3.6 The desired final configuration for the 15-puzzle Can it be achieved by only moving one block at a time into an adjacent hole?

get all 15 blocks into their natural order A picture of the 15-puzzle is shown in Figure3.5along with the configuration after the 12-block is moved into the hole below The desired final configuration is shown in Figure3.6

The 15-puzzle became very popular in North America and Europe and is still sold in game and puzzle shops today Prizes were offered for its solution, but it is doubtful that they were ever awarded, since it is impossible to get from the configuration in Figure3.5(a) to the configuration in Figure3.6by only moving one block at a time into an adjacent hole The proof of this fact is a little tricky so we have left it for you to figure out on your own! Instead, we will prove that the analogous task for the much easier 8-puzzle cannot be performed Both proofs, of course, make use of the Invariant Method

“mcs-ftl” — 2010/9/8 — 0:40 — page 59 — #65

3.3 Invariants 59

25 26 24 22 21 : 23 (a) 25 26 24 22 21 : 23 (b)

Figure 3.5 The 15-puzzle in its starting configuration (a) and after the 12-block is moved into the hole below (b)

26 25 24 22 21 : 23

Figure 3.6 The desired final configuration for the 15-puzzle Can it be achieved by only moving one block at a time into an adjacent hole?

get all 15 blocks into their natural order A picture of the 15-puzzle is shown in Figure3.5along with the configuration after the 12-block is moved into the hole below The desired final configuration is shown in Figure3.6

The 15-puzzle became very popular in North America and Europe and is still sold in game and puzzle shops today Prizes were offered for its solution, but it is doubtful that they were ever awarded, since it is impossible to get from the configuration in Figure3.5(a) to the configuration in Figure3.6by only moving one block at a time into an adjacent hole The proof of this fact is a little tricky so we have left it for you to figure out on your own! Instead, we will prove that the analogous task for the much easier 8-puzzle cannot be performed Both proofs, of course, make use of the Invariant Method

Chuyển hợp lệ: di chuyển số sang trống cạnh

(55)

15-Puzzle

Có thể chuyển từ

“mcs-ftl” — 2010/9/8 — 0:40 — page 59 — #65

3.3 Invariants 59

25 26 24 22 21 : 23 (a) 25 26 24 22 21 : 23 (b)

Figure 3.5 The 15-puzzle in its starting configuration (a) and after the 12-block is moved into the hole below (b)

26 25 24 22 21 : 23

Figure 3.6 The desired final configuration for the 15-puzzle Can it be achieved by only moving one block at a time into an adjacent hole?

get all 15 blocks into their natural order A picture of the 15-puzzle is shown in Figure3.5along with the configuration after the 12-block is moved into the hole below The desired final configuration is shown in Figure3.6

The 15-puzzle became very popular in North America and Europe and is still sold in game and puzzle shops today Prizes were offered for its solution, but it is doubtful that they were ever awarded, since it is impossible to get from the configuration in Figure3.5(a) to the configuration in Figure3.6by only moving one block at a time into an adjacent hole The proof of this fact is a little tricky so we have left it for you to figure out on your own! Instead, we will prove that the analogous task for the much easier 8-puzzle cannot be performed Both proofs, of course, make use of the Invariant Method

sang

“mcs-ftl” — 2010/9/8 — 0:40 — page 59 — #65

3.3 Invariants 59

25 26 24 22 21 : 23 (a) 25 26 24 22 21 : 23 (b)

Figure 3.5 The 15-puzzle in its starting configuration (a) and after the 12-block is moved into the hole below (b)

26 25 24 22 21 : 23

Figure 3.6 The desired final configuration for the 15-puzzle Can it be achieved by only moving one block at a time into an adjacent hole?

get all 15 blocks into their natural order A picture of the 15-puzzle is shown in Figure3.5along with the configuration after the 12-block is moved into the hole below The desired final configuration is shown in Figure3.6

The 15-puzzle became very popular in North America and Europe and is still sold in game and puzzle shops today Prizes were offered for its solution, but it is doubtful that they were ever awarded, since it is impossible to get from the configuration in Figure3.5(a) to the configuration in Figure3.6by only moving one block at a time into an adjacent hole The proof of this fact is a little tricky so we have left it for you to figure out on your own! Instead, we will prove that the analogous task for the much easier 8-puzzle cannot be performed Both proofs, of course, make use of the Invariant Method

không?

(56)

8-Puzzle“mcs-ftl” — 2010/9/8 — 0:40 — page 60 — #66

Chapter Induction 60 G H F E D C B A (a) G H F E D C B A (b) G E H F D C B A (c)

Figure 3.7 The 8-Puzzle in its initial configuration (a) and after one (b) and two (c) possible moves

3.3.4 The 8-Puzzle

In the 8-Puzzle, there are lettered tiles (A–H) and a blank square arranged in a 3⇥ grid Any lettered tile adjacent to the blank square can be slid into the blank For example, a sequence of two moves is illustrated in Figure3.7

In the initial configuration shown in Figure3.7(a), the G and H tiles are out of order We can find a way of swapping G and H so that they are in the right order, but then other letters may be out of order Can you find a sequence of moves that puts these two letters in correct order, but returns every other tile to its original position? Some experimentation suggests that the answer is probably “no,” and we will prove that is so by finding an invariant, namely, a property of the puzzle that is always maintained, no matter how you move the tiles around If we can then show that putting all the tiles in the correct order would violate the invariant, then we can conclude that the puzzle cannot be solved

Theorem 3.3.3 No sequence of legal moves transforms the configuration in Fig-ure3.7(a) into the configuration in Figure3.8

We’ll build up a sequence of observations, stated as lemmas Once we achieve a critical mass, we’ll assemble these observations into a complete proof of Theo-rem3.3.3

Define a row move as a move in which a tile slides horizontally and a column move as one in which the tile slides vertically Assume that tiles are read top-to-bottom and left-to-right like English text, that is, the natural order, defined as follows: So when we say that two tiles are “out of order”, we mean that the larger letter precedes the smaller letter in this natural order

Our difficulty is that one pair of tiles (the G and H) is out of order initially An immediate observation is that row moves alone are of little value in addressing this

(57)

8-Puzzle

Bài tập

Liệu tìm dãy chuyển hợp lệ để chuyển từ “mcs-ftl” — 2010/9/8 — 0:40 — page 60 — #66

Chapter Induction 60 G H F E D C B A (a) G H F E D C B A (b) G E H F D C B A (c)

Figure 3.7 The 8-Puzzle in its initial configuration (a) and after one (b) and two (c) possible moves

3.3.4 The 8-Puzzle

In the 8-Puzzle, there are lettered tiles (A–H) and a blank square arranged in a 3⇥ grid Any lettered tile adjacent to the blank square can be slid into the blank For example, a sequence of two moves is illustrated in Figure3.7

In the initial configuration shown in Figure3.7(a), the G and H tiles are out of order We can find a way of swapping G and H so that they are in the right order, but then other letters may be out of order Can you find a sequence of moves that puts these two letters in correct order, but returns every other tile to its original position? Some experimentation suggests that the answer is probably “no,” and we will prove that is so by finding an invariant, namely, a property of the puzzle that is always maintained, no matter how you move the tiles around If we can then show that putting all the tiles in the correct order would violate the invariant, then we can conclude that the puzzle cannot be solved

Theorem 3.3.3 No sequence of legal moves transforms the configuration in Fig-ure3.7(a) into the configuration in Figure3.8

We’ll build up a sequence of observations, stated as lemmas Once we achieve a critical mass, we’ll assemble these observations into a complete proof of Theo-rem3.3.3

Define a row move as a move in which a tile slides horizontally and a column move as one in which the tile slides vertically Assume that tiles are read top-to-bottom and left-to-right like English text, that is, the natural order, defined as follows: So when we say that two tiles are “out of order”, we mean that the larger letter precedes the smaller letter in this natural order

Our difficulty is that one pair of tiles (the G and H) is out of order initially An immediate observation is that row moves alone are of little value in addressing this

sang

“mcs-ftl” — 2010/9/8 — 0:40 — page 61 — #67

3.3 Invariants 61

H G F E D C B A

Figure 3.8 The desired final configuration of the 8-puzzle

9 : problem:

Lemma 3.3.4 A row move does not change the order of the tiles

Proof A row move moves a tile from cell i to cell i C or vice versa This tile does not change its order with respect to any other tile Since no other tile moves, there is no change in the order of any of the other pairs of tiles ⌅ Let’s turn to column moves This is the more interesting case, since here the order can change For example, the column move in Figure3.9changes the relative order of the pairs G; H / and G; E/

Lemma 3.3.5 A column move changes the relative order of exactly two pairs of tiles

Proof Sliding a tile down moves it after the next two tiles in the order Sliding a tile up moves it before the previous two tiles in the order Either way, the relative order changes between the moved tile and each of the two tiles it crosses The relative order between any other pair of tiles does not change ⌅ These observations suggest that there are limitations on how tiles can be swapped Some such limitation may lead to the invariant we need In order to reason about swaps more precisely, let’s define a term referring to a pair of items that are out of order:

(58)

Định lý

Không tồn dãy chuyển cho toán

(59)

Chuyển hàng

Thứ tự tự nhiên chữ ô:

“mcs-ftl” — 2010/9/8 — 0:40 — page 61 — #67

3.3 Invariants 61

H G F E D C B A

Figure 3.8 The desired final configuration of the 8-puzzle

9 : problem:

Lemma 3.3.4 A row move does not change the order of the tiles

Proof A row move moves a tile from cell i to cell i C or vice versa This tile does not change its order with respect to any other tile Since no other tile moves, there is no change in the order of any of the other pairs of tiles ⌅ Let’s turn to column moves This is the more interesting case, since here the order can change For example, the column move in Figure3.9changes the relative order of the pairs G; H / and G; E/

Lemma 3.3.5 A column move changes the relative order of exactly two pairs of tiles

Proof Sliding a tile down moves it after the next two tiles in the order Sliding a tile up moves it before the previous two tiles in the order Either way, the relative order changes between the moved tile and each of the two tiles it crosses The

relative order between any other pair of tiles does not change ⌅

These observations suggest that there are limitations on how tiles can be swapped Some such limitation may lead to the invariant we need In order to reason about swaps more precisely, let’s define a term referring to a pair of items that are out of order:

Bổ đề

Mỗi lần chuyển hàng không làm thay đổi thứ tự chữ

(60)

Chuyển cột

Bổ đề

Mỗi lần chuyển theo cột làm thay đổi thứ tự hai cặp chữ

“mcs-ftl” — 2010/9/8 — 0:40 — page 62 — #68

Chapter Induction 62 E H G F D C B A (a) E H G F D C B A (b)

Figure 3.9 An example of a column move in which the G-tile is moved into the adjacent hole above In this case, G changes order with E and H

Definition 3.3.6 A pair of letters L1and L2is an inversion if L1precedes L2in

the alphabet, but L1appears after L2in the puzzle order

For example, in the puzzle below, there are three inversions: D; F /, E; F /, E; G/ H E G D F C B A

There is exactly one inversion G; H / in the start state:

G H F E D C B A

(61)

Cặp ngược

Định nghĩa

Cặp chữ L1 và L2 gọi ngược L1 đứng trước L2 bảng chữ L1 lại đứng sau L2 ô chữ

“mcs-ftl” — 2010/9/8 — 0:40 — page 63 — #69

3.3 Invariants 63

There are no inversions in the end state:

H G F E D C B A

Let’s work out the effects of row and column moves in terms of inversions Lemma 3.3.7 During a move, the number of inversions can only increase by 2, decrease by 2, or remain the same

Proof By Lemma3.3.4, a row move does not change the order of the tiles, and so a row move does not change the number of inversions

By Lemma3.3.5, a column move changes the relative order of exactly pairs of tiles There are three cases: If both pairs were originally in order, then the number of inversions after the move goes up by If both pairs were originally inverted, then the number of inversions after the move goes down by If one pair was originally inverted and the other was originally in order, then the number of inversions stays the same (since changing the former pair makes the number of inversions smaller by 1, and changing the latter pair makes the number of inversions

larger by 1) ⌅

We are almost there If the number of inversions only changes by 2, then what about the parity of the number of inversions? (The “parity” of a number refers to whether the number is even or odd For example, and have odd parity, and 18 and have even parity.)

Since adding or subtracting from a number does not change its parity, we have the following corollary to Lemma3.3.7:

Corollary 3.3.8 Neither a row move nor a column move ever changes the parity of the number of inversions

Now we can bundle up all these observations and state an invariant, that is, a property of the puzzle that never changes, no matter how you slide the tiles around Lemma 3.3.9 In every configuration reachable from the configuration shown in Figure3.7(a), the parity of the number of inversions is odd

“mcs-ftl” — 2010/9/8 — 0:40 — page 62 — #68

Chapter Induction 62 E H G F D C B A (a) E H G F D C B A (b)

Figure 3.9 An example of a column move in which the G-tile is moved into the adjacent hole above In this case, G changes order with E and H

Definition 3.3.6 A pair of letters L1and L2is an inversion if L1precedes L2in

the alphabet, but L1appears after L2in the puzzle order

For example, in the puzzle below, there are three inversions: D; F /, E; F /, E; G/ H E G D F C B A

There is exactly one inversion G; H / in the start state:

G H F E D C B A

“mcs-ftl” — 2010/9/8 — 0:40 — page 62 — #68

Chapter Induction 62 E H G F D C B A (a) E H G F D C B A (b)

Figure 3.9 An example of a column move in which the G-tile is moved into the adjacent hole above In this case, G changes order with E and H

Definition 3.3.6 A pair of letters L1and L2is an inversion if L1precedes L2in the alphabet, but L1appears after L2in the puzzle order

For example, in the puzzle below, there are three inversions: D; F /, E; F /, E; G/ H E G D F C B A

There is exactly one inversion G; H / in the start state:

G H F E D C B A

(62)

Bổ đề

Mỗi bước di chuyển, số cặp ngược tăng 2, giảm 2, giữ nguyên

Chứng minh

Chuyển hàng:khơng đổi khơng làm thay đổi thứ tự chữ

Chuyển cột:sẽ làm thay đổi thứ tự cặp chữ

▶ Nếu hai cặp không ngược:số cặp ngược tăng

▶ Nếu hai cặp ngược: số cặp ngược giảm

▶ Nếu hay cặp có cặp ngược: số cặp ngược giữ nguyên

(63)

Hệ

Trong bước di chuyển, tính chẵn lẻ số cặp ngược không đổi

(64)

Bổ đề

Số cặp ngược trong cấu hình đạt từ

“mcs-ftl” — 2010/9/8 — 0:40 — page 60 — #66

Chapter Induction 60 G H F E D C B A (a) G H F E D C B A (b) G E H F D C B A (c)

Figure 3.7 The 8-Puzzle in its initial configuration (a) and after one (b) and two (c) possible moves

3.3.4 The 8-Puzzle

In the 8-Puzzle, there are lettered tiles (A–H) and a blank square arranged in a 3⇥ grid Any lettered tile adjacent to the blank square can be slid into the blank. For example, a sequence of two moves is illustrated in Figure3.7

In the initial configuration shown in Figure3.7(a), the G and H tiles are out of order We can find a way of swapping G and H so that they are in the right order, but then other letters may be out of order Can you find a sequence of moves that puts these two letters in correct order, but returns every other tile to its original position? Some experimentation suggests that the answer is probably “no,” and we will prove that is so by finding an invariant, namely, a property of the puzzle that is always maintained, no matter how you move the tiles around If we can then show that putting all the tiles in the correct order would violate the invariant, then we can conclude that the puzzle cannot be solved

Theorem 3.3.3 No sequence of legal moves transforms the configuration in Fig-ure3.7(a) into the configuration in Figure3.8

We’ll build up a sequence of observations, stated as lemmas Once we achieve a critical mass, we’ll assemble these observations into a complete proof of Theo-rem3.3.3

Define a row move as a move in which a tile slides horizontally and a column move as one in which the tile slides vertically Assume that tiles are read top-to-bottom and left-to-right like English text, that is, the natural order, defined as follows: So when we say that two tiles are “out of order”, we mean that the larger letter precedes the smaller letter in this natural order

Our difficulty is that one pair of tiles (the G and H) is out of order initially An immediate observation is that row moves alone are of little value in addressing this

luôn lẻ

(65)

Chứng minh quy nạp

Đặt P(n) mệnh đề : “ Số cặp ngược cấu hình đạt từ

“mcs-ftl” — 2010/9/8 — 0:40 — page 60 — #66

Chapter Induction 60 G H F E D C B A (a) G H F E D C B A (b) G E H F D C B A (c)

Figure 3.7 The 8-Puzzle in its initial configuration (a) and after one (b) and two (c) possible moves

3.3.4 The 8-Puzzle

In the 8-Puzzle, there are lettered tiles (A–H) and a blank square arranged in a 3⇥ grid Any lettered tile adjacent to the blank square can be slid into the blank. For example, a sequence of two moves is illustrated in Figure3.7

In the initial configuration shown in Figure3.7(a), the G and H tiles are out of order We can find a way of swapping G and H so that they are in the right order, but then other letters may be out of order Can you find a sequence of moves that puts these two letters in correct order, but returns every other tile to its original position? Some experimentation suggests that the answer is probably “no,” and we will prove that is so by finding an invariant, namely, a property of the puzzle that is always maintained, no matter how you move the tiles around If we can then show that putting all the tiles in the correct order would violate the invariant, then we can conclude that the puzzle cannot be solved

Theorem 3.3.3 No sequence of legal moves transforms the configuration in Fig-ure3.7(a) into the configuration in Figure3.8

We’ll build up a sequence of observations, stated as lemmas Once we achieve a critical mass, we’ll assemble these observations into a complete proof of Theo-rem3.3.3

Define a row move as a move in which a tile slides horizontally and a column move as one in which the tile slides vertically Assume that tiles are read top-to-bottom and left-to-right like English text, that is, the natural order, defined as follows: So when we say that two tiles are “out of order”, we mean that the larger letter precedes the smaller letter in this natural order

Our difficulty is that one pair of tiles (the G and H) is out of order initially An immediate observation is that row moves alone are of little value in addressing this

sau n bước chuyển lẻ”

▶ Bước sở: P(0) Tại sao?

▶ Bước quy nạp: Giả sử P(n) đúng, hệ trước tính

chẵn lẻ không đổi số cặp ngược Ta P(n + 1) đúng.

(66)

Định lý

Không tồn dãy chuyển hợp lệ để chuyển từ “mcs-ftl” — 2010/9/8 — 0:40 — page 60 — #66

Chapter Induction 60 G H F E D C B A (a) G H F E D C B A (b) G E H F D C B A (c)

Figure 3.7 The 8-Puzzle in its initial configuration (a) and after one (b) and two (c) possible moves

3.3.4 The 8-Puzzle

In the 8-Puzzle, there are lettered tiles (A–H) and a blank square arranged in a 3⇥ grid Any lettered tile adjacent to the blank square can be slid into the blank For example, a sequence of two moves is illustrated in Figure3.7

In the initial configuration shown in Figure3.7(a), the G and H tiles are out of order We can find a way of swapping G and H so that they are in the right order, but then other letters may be out of order Can you find a sequence of moves that puts these two letters in correct order, but returns every other tile to its original position? Some experimentation suggests that the answer is probably “no,” and we will prove that is so by finding an invariant, namely, a property of the puzzle that is always maintained, no matter how you move the tiles around If we can then show that putting all the tiles in the correct order would violate the invariant, then we can conclude that the puzzle cannot be solved

Theorem 3.3.3 No sequence of legal moves transforms the configuration in Fig-ure3.7(a) into the configuration in Figure3.8

We’ll build up a sequence of observations, stated as lemmas Once we achieve a critical mass, we’ll assemble these observations into a complete proof of Theo-rem3.3.3

Define a row move as a move in which a tile slides horizontally and a column move as one in which the tile slides vertically Assume that tiles are read top-to-bottom and left-to-right like English text, that is, the natural order, defined as follows: So when we say that two tiles are “out of order”, we mean that the larger letter precedes the smaller letter in this natural order

Our difficulty is that one pair of tiles (the G and H) is out of order initially An immediate observation is that row moves alone are of little value in addressing this

sang

“mcs-ftl” — 2010/9/8 — 0:40 — page 61 — #67

3.3 Invariants 61

H G F E D C B A

Figure 3.8 The desired final configuration of the 8-puzzle

9 : problem:

Lemma 3.3.4 A row move does not change the order of the tiles

Proof A row move moves a tile from cell i to cell i C or vice versa This tile does not change its order with respect to any other tile Since no other tile moves, there is no change in the order of any of the other pairs of tiles ⌅ Let’s turn to column moves This is the more interesting case, since here the order can change For example, the column move in Figure3.9changes the relative order of the pairs G; H / and G; E/

Lemma 3.3.5 A column move changes the relative order of exactly two pairs of tiles

Proof Sliding a tile down moves it after the next two tiles in the order Sliding a tile up moves it before the previous two tiles in the order Either way, the relative order changes between the moved tile and each of the two tiles it crosses The relative order between any other pair of tiles does not change ⌅ These observations suggest that there are limitations on how tiles can be swapped Some such limitation may lead to the invariant we need In order to reason about swaps more precisely, let’s define a term referring to a pair of items that are out of order:

(67)

Nội dung

Nguyên lý quy nạp

(68)

Bài tập

Hãy dùng quy nạp để chứng minh số nguyên dương phân tích thành tích số nguyên tố

(69)

Nguyên lý quy nạp mạnh

Xét vị từ P(n) trên N Nếu

P(0) đúng, và

với n∈ N, (P(0) ∧ P(1) ∧ · · · ∧ P(n)) ⇒ P(n + 1), thì P(n) với n∈ N.

(70)

Ví dụ

Ở nước Quy nạp, họ dùng đơn vị tiền Mạnh Họ có hai loại tiền 3M (Mạnh) 5M Dù họ có vấn đề nhỏ với việc đổi tiền 4M 7M, họ nhận thấy họ đổi số tiền 8M Hãy giải thích cho họ xem điều

(71)

Unstacking Game

▶ Có chồng hộp Bạn thực dãy bước chuyển

Mỗi bước chuyển bạn chia hộp kích thước (a + b) thành hai chồng khác rỗng kích thước a b Và bạn ab điểm cho bước chuyển

▶ Trò chơi kết thúc chồng hộp hộp

▶ Điểm bạn tổng điểm bạn đạt bước

▶ Hãy tìm chiến lược chơi để tối đa hoá điểm bạn?

(72)

Một chiến lược kiểu “chia đơi” cho trị chơi với n = 10 đĩa

Điểm

10

5 25

5 6

3 2 6

2 2 2

1 2 1 1

1 2 1 2

1 2 1 1 1

1 1 1 1 1

1 1 1 1 1 1

45

(73)

Định lý

Mọi chiến lược trò chơi gồm chồng n hộp cho điểm

S(n) = n(n− 1)

2 .

(74)

Chứng minh

Ta gọi P(n) mệnh đề S(n) = n(n− 1)/2.

Bước sở:P(0) S(0) = 0.

Bước quy nạp:Giả sử P(0)∧ · · · ∧ P(n) để chứng minh

P(n + 1).

Xét trò chơi với n + đĩa Ta chia n + đĩa tùy ý thành hai phần không rỗng a, b thỏa mãn a + b = n + Theo giả thiết quy nạp, ta

S(a + b) = S(a) + S(b) + ab = a(a− 1)

2 +

b(b− 1)

2 + ab

= a

2− a + b2− b + 2ab

2 =

(a + b)2− (a + b)

= (a + b)(a + b− 1)

2 =

(n + 1)n

2 3

(75)

Đồ thị

Trần Vĩnh Đức

HUST

Ngày 24 tháng năm 2018

(76)

Tài liệu tham khảo

Norman L Biggs, Discrete Mathematics, Oxford University Press, 2002

(77)

1/26/16, 10:42 AM Hồ Hoàn Kiếm đến Bách Khoa, Hai Bà Trưng - Google Maps

Page of https://www.google.com/maps/dir/Hồ+Hồn+Kiếm,+Hàng+Trống,+Hồ…fe1abd:0x22b136bcf1c08e2a!2m2!1d105.8459098!2d21.0042694!3e2

Dữ liệu đồ ©2016 Google ki lô mét

50 p

4,1 km

via Phố Huế

51 p

4,2 km

via Hàng Bài

52 p

4,2 km

via Bà Triệu

Đi 4,1 km, 50 p Hồ Hoàn Kiếm đến Bách Khoa, Hai Bà Trưng

(78)

Nội dung

Đồ thị biểu diễn

Một số đồ thị đặc biệt

Đẳng cấu

Bậc

(79)

Định nghĩa

Mộtđồ thị G cặp có thứ tự G = (V, E), V một

tập, E tập với phần tử tập hai phần tử V. Các phần tử V gọi cácđỉnh, phần tử E gọi cáccạnh của G.

Ví dụ

Xét đồ thị G = (V, E) đó

V ={a, b, c, d, z}

E ={{a, b}, {a, d}, {b, z}, {c, d}, {d, z}}.

a

z b

d c

(80)

Định nghĩa

Hai đỉnh x y gọi là kề nhau (hayhàng xóm) nếu{x, y} là cạnh đồ thị

Ta biểu diễn đồ thị G = (V, E) bởi danh sách kề, mỗi đỉnh v giữ danh sách đỉnh kề với v.

Ví dụ a

z b

d c

a b c d z b a d a b

d z c d

z

(81)

Bài tập

Có ba ngơi nhà A, B, C, ngơi nhà kết nối với ba nhà cung cấp ga, nước, điện: G, W, E.

1 Hãy viết danh sách kề cho đồ thị biểu diễn toán vẽ

2 Liệu bạn vẽ đồ thị mặt phẳng để khơng có cạnh cắt khơng?

(82)

Ví dụ

▶ GS Mc Brain vợ bà April tới bữa tiệc có đơi vợ chồng khác

▶ Có vài cặp bắt tay không bắt tay với vợ chồng

▶ GS hỏi người khác xem họ bắt tay người ông nhận số khác

▶ Hỏi có người bắt tay April?

(83)

Nội dung

Đồ thị biểu diễn

Một số đồ thị đặc biệt

Đẳng cấu

Bậc

(84)

Đồ thị đầy đủ

Định nghĩa

Đồ thị đầy đủ gồm n đỉnh, ký hiệu Kn đồ thị có

cạnh nối cặp đỉnh phân biệt

10.2 Graph Terminology and Special Types of Graphs 655

EXAMPLE 5 Complete Graphs A complete graph on n vertices, denoted by Kn, is a simple graph

that contains exactly one edge between each pair of distinct vertices The graphs Kn, for

n= 1, 2, 3, 4, 5, 6, are displayed in Figure A simple graph for which there is at least one pair of distinct vertex not connected by an edge is called noncomplete.

K1 K2 K3 K4 K5 K6

FIGURE 3 The Graphs Knfor 1≤ n ≤ 6.

EXAMPLE 6 Cycles A cycle Cn, n≥ 3, consists of n vertices v1,v2, ,vn and edges {v1,v2},

{v2,v3}, , {vn−1,vn}, and {vn,v1} The cycles C3, C4, C5, and C6 are displayed in

Figure ▲

C3 C4 C5 C6

FIGURE 4 The Cycles C3, C4, C5, and C6.

EXAMPLE 7 Wheels We obtain a wheel Wnwhen we add an additional vertex to a cycle Cn, for n≥ 3,

and connect this new vertex to each of the n vertices in Cn, by new edges The wheels W3, W4,

W5, and W6are displayed in Figure ▲

W3 W4 W5 W6

FIGURE 5 The Wheels W3, W4, W5, and W6.

EXAMPLE 8 n-Cubes An n-dimensional hypercube, or n-cube, denoted by Qn, is a graph that has vertices

representing the 2nbit strings of length n Two vertices are adjacent if and only if the bit strings

that they represent differ in exactly one bit position We display Q1, Q2, and Q3in Figure

Note that you can construct the (n+ 1)-cube Qn+1from the n-cube Qnby making two

copies of Qn, prefacing the labels on the vertices with a in one copy of Qnand with a in the

other copy of Qn, and adding edges connecting two vertices that have labels differing only in

the first bit In Figure 6, Q3is constructed from Q2by drawing two copies of Q2as the top and

bottom faces of Q3, adding at the beginning of the label of each vertex in the bottom face and

1 at the beginning of the label of each vertex in the top face (Here, by face we mean a face of a cube in three-dimensional space Think of drawing the graph Q3in three-dimensional space

with copies of Q2as the top and bottom faces of a cube and then drawing the projection of the

resulting depiction in the plane.) ▲

(85)

Câu hỏi

Đồ thị Kn có cạnh?

(86)

Đồ thị vòng Định nghĩa

Đồ thị vòng Cn, với n≥ đồ thị có n đỉnh v1, v2, , vn

các cạnh

{v1, v2}, {v2, v3}, · · · , {vn−1, vn}, {vn, v1}

10.2 Graph Terminology and Special Types of Graphs 655

EXAMPLE 5 Complete Graphs A complete graph on n vertices, denoted by Kn, is a simple graph

that contains exactly one edge between each pair of distinct vertices The graphs Kn, for

n= 1, 2, 3, 4, 5, 6, are displayed in Figure A simple graph for which there is at least one

pair of distinct vertex not connected by an edge is called noncomplete.

K1 K2 K3 K4 K5 K6

FIGURE 3 The Graphs Kn for 1≤ n ≤ 6.

EXAMPLE 6 Cycles A cycle Cn, n≥ 3, consists of n vertices v1,v2, ,vn and edges {v1,v2},

{v2,v3}, , {vn−1,vn}, and {vn,v1} The cycles C3, C4, C5, and C6 are displayed in

Figure 4. ▲

C3 C4 C5 C6

FIGURE 4 The Cycles C3, C4, C5, and C6.

EXAMPLE 7 Wheels We obtain a wheel Wn when we add an additional vertex to a cycle Cn, for n≥ 3,

and connect this new vertex to each of the n vertices in Cn, by new edges The wheels W3, W4,

W5, and W6are displayed in Figure 5. ▲

W3 W4 W5 W6

FIGURE 5 The Wheels W3, W4, W5, and W6.

EXAMPLE 8 n-Cubes An n-dimensional hypercube, or n-cube, denoted by Qn, is a graph that has vertices

representing the 2nbit strings of length n Two vertices are adjacent if and only if the bit strings that they represent differ in exactly one bit position We display Q1, Q2, and Q3in Figure 6.

Note that you can construct the (n+ 1)-cube Qn+1 from the n-cube Qn by making two

copies of Qn, prefacing the labels on the vertices with a in one copy of Qnand with a in the

other copy of Qn, and adding edges connecting two vertices that have labels differing only in

the first bit In Figure 6, Q3is constructed from Q2by drawing two copies of Q2as the top and

bottom faces of Q3, adding at the beginning of the label of each vertex in the bottom face and

1 at the beginning of the label of each vertex in the top face (Here, by face we mean a face of a cube in three-dimensional space Think of drawing the graph Q3 in three-dimensional space

with copies of Q2as the top and bottom faces of a cube and then drawing the projection of the

resulting depiction in the plane.) ▲

(87)

Câu hỏi

Đồ thị Cn có cạnh?

(88)

Đồ thị bánh xe

Định nghĩa

Khi thêm đỉnh vào vòng Cn với n≥ nối đỉnh với mỗi

đỉnh Cn cạnh ta nhận đồ thị bánh xe Wn

10.2 Graph Terminology and Special Types of Graphs 655

EXAMPLE 5 Complete Graphs A complete graph on n vertices, denoted by Kn, is a simple graph

that contains exactly one edge between each pair of distinct vertices The graphs Kn, for

n= 1, 2, 3, 4, 5, 6, are displayed in Figure A simple graph for which there is at least one pair of distinct vertex not connected by an edge is called noncomplete.

K1 K2 K3 K4 K5 K6

FIGURE 3 The Graphs Knfor 1≤ n ≤ 6.

EXAMPLE 6 Cycles A cycle Cn, n≥ 3, consists of n vertices v1,v2, ,vn and edges {v1,v2},

{v2,v3}, , {vn−1,vn}, and {vn,v1} The cycles C3, C4, C5, and C6 are displayed in

Figure ▲

C3 C4 C5 C6

FIGURE 4 The Cycles C3, C4, C5, and C6.

EXAMPLE 7 Wheels We obtain a wheel Wn when we add an additional vertex to a cycle Cn, for n≥ 3,

and connect this new vertex to each of the n vertices in Cn, by new edges The wheels W3, W4,

W5, and W6are displayed in Figure ▲

W3 W4 W5 W6

FIGURE 5 The Wheels W3, W4, W5, and W6.

EXAMPLE 8 n-Cubes An n-dimensional hypercube, or n-cube, denoted by Qn, is a graph that has vertices

representing the 2nbit strings of length n Two vertices are adjacent if and only if the bit strings

that they represent differ in exactly one bit position We display Q1, Q2, and Q3in Figure

Note that you can construct the (n+ 1)-cube Qn+1 from the n-cube Qn by making two

copies of Qn, prefacing the labels on the vertices with a in one copy of Qnand with a in the

other copy of Qn, and adding edges connecting two vertices that have labels differing only in

the first bit In Figure 6, Q3is constructed from Q2by drawing two copies of Q2as the top and

bottom faces of Q3, adding at the beginning of the label of each vertex in the bottom face and

1 at the beginning of the label of each vertex in the top face (Here, by face we mean a face of a cube in three-dimensional space Think of drawing the graph Q3 in three-dimensional space

with copies of Q2as the top and bottom faces of a cube and then drawing the projection of the

resulting depiction in the plane.) ▲

(89)

Câu hỏi

Đồ thị Wn có cạnh?

(90)

Các khối n chiều

Định nghĩa

Các khối n chiều, ký hiệu Qn, đồ thị có 2n đỉnh, đỉnh

được biểu diễn xâu nhị phân độ dài n Hai đỉnh liền kề và xâu nhị phân biểu diễn chúng khác bit

656 10 / Graphs

Q1 Q2

0 00 01 10 11 Q3 000 001 100 101 111 110 010 011

FIGURE 6 The n-cube Qn, n= 1, 2, 3.

Bipartite Graphs

Sometimes a graph has the property that its vertex set can be divided into two disjoint subsets such that each edge connects a vertex in one of these subsets to a vertex in the other subset For example, consider the graph representing marriages between men and women in a village, where each person is represented by a vertex and a marriage is represented by an edge In this graph, each edge connects a vertex in the subset of vertices representing males and a vertex in the subset of vertices representing females This leads us to Definition

DEFINITION 6 A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint sets V1and V2such that every edge in the graph connects a vertex in V1and a vertex in V2

(so that no edge in G connects either two vertices in V1or two vertices in V2) When this

condition holds, we call the pair (V1, V2)a bipartition of the vertex set V of G.

In Example we will show that C6is bipartite, and in Example 10 we will show that K3is

not bipartite

EXAMPLE 9 C6is bipartite, as shown in Figure 7, because its vertex set can be partitioned into the two sets

V1= {v1,v3,v5} and V2= {v2,v4,v6}, and every edge of C6 connects a vertex in V1 and a

vertex in V2 ▲

EXAMPLE 10 K3is not bipartite To verify this, note that if we divide the vertex set of K3into two disjoint

sets, one of the two sets must contain two vertices If the graph were bipartite, these two vertices could not be connected by an edge, but in K3each vertex is connected to every other vertex by

an edge ▲

EXAMPLE 11 Are the graphs G and H displayed in Figure bipartite?

V1 V2

v1 v3 v5 v2 v4 v6

FIGURE 7 Showing That C6Is

Bipartite. a b c e d f g G a b e d H f c

(91)

Câu hỏi

Đồ thị Qn có cạnh?

(92)

Đồ thị hai phần

Định nghĩa

Một đồ thị gọi hai phần tập đỉnh V phân hoạch thành hai tập V1 và V2 cho cạnh đồ thị nối đỉnh của V1 tới đỉnh V2

656 10 / Graphs

Q1 Q2

0 1 00 01 10 11 Q3 000 001 100 101 111 110 010 011

FIGURE 6 The n-cube Qn, n = 1, 2, 3.

Bipartite Graphs

Sometimes a graph has the property that its vertex set can be divided into two disjoint subsets such that each edge connects a vertex in one of these subsets to a vertex in the other subset. For example, consider the graph representing marriages between men and women in a village, where each person is represented by a vertex and a marriage is represented by an edge In this graph, each edge connects a vertex in the subset of vertices representing males and a vertex in the subset of vertices representing females This leads us to Definition 5.

DEFINITION 6 A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint

sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2

(so that no edge in G connects either two vertices in V1 or two vertices in V2) When this

condition holds, we call the pair (V1, V2) a bipartition of the vertex set V of G.

In Example we will show that C6 is bipartite, and in Example 10 we will show that K3 is

not bipartite.

EXAMPLE 9 C6 is bipartite, as shown in Figure 7, because its vertex set can be partitioned into the two sets

V1 = {v1,v3,v5} and V2 = {v2,v4,v6}, and every edge of C6 connects a vertex in V1 and a

vertex in V2. ▲

EXAMPLE 10 K3 is not bipartite To verify this, note that if we divide the vertex set of K3 into two disjoint

sets, one of the two sets must contain two vertices If the graph were bipartite, these two vertices

could not be connected by an edge, but in K3 each vertex is connected to every other vertex by

an edge. ▲

EXAMPLE 11 Are the graphs G and H displayed in Figure bipartite?

V1 V2

v1 v3 v5 v2 v4 v6

FIGURE 7 Showing That C6 Is

Bipartite. a b c e d f g G a b e d H f c

FIGURE 8 The Undirected Graphs G and H

(93)

Câu hỏi

Đồ thị đồ thị hai phần?

656 10 / Graphs

Q1 Q2

0 00 01 10 11 Q3 000 001 100 101 111 110 010 011

FIGURE 6 The n-cube Qn, n= 1, 2, 3. Bipartite Graphs

Sometimes a graph has the property that its vertex set can be divided into two disjoint subsets such that each edge connects a vertex in one of these subsets to a vertex in the other subset. For example, consider the graph representing marriages between men and women in a village, where each person is represented by a vertex and a marriage is represented by an edge In this graph, each edge connects a vertex in the subset of vertices representing males and a vertex in the subset of vertices representing females This leads us to Definition 5.

DEFINITION 6 A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint

sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2

(so that no edge in G connects either two vertices in V1 or two vertices in V2) When this

condition holds, we call the pair (V1, V2)a bipartition of the vertex set V of G.

In Example we will show that C6 is bipartite, and in Example 10 we will show that K3 is

not bipartite.

EXAMPLE 9 C6 is bipartite, as shown in Figure 7, because its vertex set can be partitioned into the two sets

V1 = {v1,v3,v5} and V2 = {v2,v4,v6}, and every edge of C6 connects a vertex in V1 and a

vertex in V2. ▲

EXAMPLE 10 K3 is not bipartite To verify this, note that if we divide the vertex set of K3 into two disjoint sets, one of the two sets must contain two vertices If the graph were bipartite, these two vertices

could not be connected by an edge, but in K3each vertex is connected to every other vertex by

an edge. ▲

EXAMPLE 11 Are the graphs G and H displayed in Figure bipartite?

V1 V2

v1 v3 v5 v2 v4 v6

FIGURE 7 Showing That C6 Is

Bipartite. a b c e d f g G a b e d H f c

FIGURE 8 The Undirected Graphs G and H

(94)

Câu hỏi

Đồ thị C5 và C6 có phải đồ thị hai phần?

(95)

Đồ thị hai phần đầy đủ

Định nghĩa

Đồ thị hai phần đầy đủ Km,n đồ thị có tập đỉnh phân

hoạch thành hai tập tương ứng có m đỉnh n đỉnh có một cạnh nối hai đỉnh có đỉnh thuộc tập đỉnh thuộc tập

658 10 / Graphs

EXAMPLE 13 Complete Bipartite Graphs A complete bipartite graph Km,nis a graph that has its vertex

set partitioned into two subsets of m and n vertices, respectively with an edge between two vertices if and only if one vertex is in the first subset and the other vertex is in the second subset The complete bipartite graphs K2,3, K3,3, K3,5, and K2,6are displayed in Figure ▲

K2,3 K3,3

K3,5 K2,6

FIGURE 9 Some Complete Bipartite Graphs.

Bipartite Graphs and Matchings

Bipartite graphs can be used to model many types of applications that involve matching the elements of one set to elements of another, as Example 14 illustrates

EXAMPLE 14 Job Assignments Suppose that there are m employees in a group and n different jobs that need to be done, where m≥ n Each employee is trained to one or more of these n jobs We would like to assign an employee to each job To help with this task, we can use a graph to model employee capabilities We represent each employee by a vertex and each job by a vertex For each employee, we include an edge from that employee to all jobs that the employee has been trained to Note that the vertex set of this graph can be partitioned into two disjoint sets, the set of employees and the set of jobs, and each edge connects an employee to a job Consequently, this graph is bipartite, where the bipartition is (E, J ) where E is the set of employees and J is the set of jobs We now consider two different scenarios

First, suppose that a group has four employees: Alvarez, Berkowitz, Chen, and Davis; and suppose that four jobs need to be done to complete Project 1: requirements, architecture, implementation, and testing Suppose that Alvarez has been trained to requirements and testing; Berkowitz has been trained to architecture, implementation, and testing; Chen has been trained to requirements, architecture, and implementation; and Davis has only been trained to requirements We model these employee capabilities using the bipartite graph in Figure 10(a)

Second, suppose that a group has second group also has four employees: Washington, Xuan, Ybarra, and Ziegler; and suppose that the same four jobs need to be done to complete Project as are needed to complete Project Suppose that Washington has been trained to architecture; Xuan has been trained to requirements, implementation, and testing; Ybarra has been trained to architecture; and Ziegler has been trained to requirements, architecture and testing We model these employee capabilities using the bipartite graph in Figure 10(b)

To complete Project 1, we must assign an employee to each job so that every job has an employee assigned to it, and so that no employee is assigned more than one job We can this by assigning Alvarez to testing, Berkowitz to implementation, Chen to architecture, and Davis to requirements, as shown in Figure 10(a) (where blue lines show this assignment of jobs)

To complete Project 2, we must also assign an employee to each job so that every job has an employee assigned to it and no employee is assigned more than one job However, this is

(96)

658 10 / Graphs

EXAMPLE 13 Complete Bipartite Graphs A complete bipartite graph Km,nis a graph that has its vertex

set partitioned into two subsets of m and n vertices, respectively with an edge between two vertices if and only if one vertex is in the first subset and the other vertex is in the second subset

The complete bipartite graphs K2,3, K3,3, K3,5, and K2,6are displayed in Figure ▲

K2,3 K3,3

K3,5 K2,6

FIGURE 9 Some Complete Bipartite Graphs.

Bipartite Graphs and Matchings

Bipartite graphs can be used to model many types of applications that involve matching the elements of one set to elements of another, as Example 14 illustrates

EXAMPLE 14 Job Assignments Suppose that there are m employees in a group and n different jobs that

need to be done, where m≥ n Each employee is trained to one or more of these n jobs We

would like to assign an employee to each job To help with this task, we can use a graph to model employee capabilities We represent each employee by a vertex and each job by a vertex For each employee, we include an edge from that employee to all jobs that the employee has been trained to Note that the vertex set of this graph can be partitioned into two disjoint sets, the set of employees and the set of jobs, and each edge connects an employee to a job Consequently, this graph is bipartite, where the bipartition is (E, J ) where E is the set of employees and J is the set of jobs We now consider two different scenarios

First, suppose that a group has four employees: Alvarez, Berkowitz, Chen, and Davis; and suppose that four jobs need to be done to complete Project 1: requirements, architecture, implementation, and testing Suppose that Alvarez has been trained to requirements and testing; Berkowitz has been trained to architecture, implementation, and testing; Chen has been trained to requirements, architecture, and implementation; and Davis has only been trained to requirements We model these employee capabilities using the bipartite graph in Figure 10(a)

Second, suppose that a group has second group also has four employees: Washington, Xuan, Ybarra, and Ziegler; and suppose that the same four jobs need to be done to complete Project as are needed to complete Project Suppose that Washington has been trained to architecture; Xuan has been trained to requirements, implementation, and testing; Ybarra has been trained to architecture; and Ziegler has been trained to requirements, architecture and testing We model these employee capabilities using the bipartite graph in Figure 10(b)

To complete Project 1, we must assign an employee to each job so that every job has an employee assigned to it, and so that no employee is assigned more than one job We can this by assigning Alvarez to testing, Berkowitz to implementation, Chen to architecture, and Davis to requirements, as shown in Figure 10(a) (where blue lines show this assignment of jobs)

To complete Project 2, we must also assign an employee to each job so that every job has an employee assigned to it and no employee is assigned more than one job However, this is

(97)

Câu hỏi

Đồ thị Km,n có cạnh?

(98)

Bài tập

Hãy xây dựng đồ thị với đỉnh cạnh mà không chứa C3 (tam giác)

(99)

Nội dung

Đồ thị biểu diễn

Một số đồ thị đặc biệt

Đẳng cấu

Bậc

(100)

Định nghĩa

Hai đồ thị G1 và G2 gọi làđẳng cấunếu có song ánh α từ tập đỉnh G1 đến tập đỉnh G2 cho{α(x), α(y)} là một cạnh G1 nếu nếu {x, y} cạnh G2 Song ánh α gọi mộtđẳng cấu

(101)

Ví dụ

Hai đồ thị sau đẳng cấu với đẳng cấu α định nghĩa bởi:

α(a) = t, α(b) = v, α(c) = w, α(d) = u.

a b

c

d v u

w t

(102)

Ví dụ

Hai đồ thị sau có đẳng cấu không?

a

e b

d c

a

e b

d c

(103)

Bài tập

Hãy chứng minh hai đồ thị sau không đẳng cấu

(104)

Nội dung

Đồ thị biểu diễn

Một số đồ thị đặc biệt

Đẳng cấu

Bậc

(105)

Định nghĩa

Bậccủa đỉnh v đồ thị G = (V, E) số cạnh G chứa v Ta ký hiệu deg(v) bậc đỉnh v Có nghĩa rằng

deg(v) =|Dv| với Dv={e ∈ E | v ∈ e }.

Ví dụ a

z b

d c

đỉnh deg

a

b

c

d

z

(106)

Định lý

Tổng bậc deg(v), lấy đỉnh v đồ thị G = (V, E), hai lần số cạnh:

v∈V

deg(v) = 2|E|.

Ví dụ a

z b

d c

đỉnh thuộc vào cạnh

a {a, b}, {a, d} b {a, b}, {b, z} c {c, d}

d {a, d}, {c, d}, {d, z} z {b, z}, {d, z}

(107)

Một đỉnh đồ thị G làlẻ bậc lẻ, làchẵn bậc chẵn

Hệ

Số đỉnh lẻ đồ thị số chẵn

Chứng minh

v∈Vlẻ

deg(v) +

v∈Vchẵn

deg(v) = 2|E|

(108)

Bậc đẳng cấu

Nếu α : V1 → V2 là đẳng cấu G1 và G2

α(v) = w, vậy

deg(v) = deg(w). Tại sao?

Nếu G1 có đỉnh x với deg(x) = δ0 và G2 khơng có đỉnh có bậc δ0, G1 và G2 không đẳng cấu

(109)

Bài tập

Các dãy số sau bậc đỉnh đồ thị khơng? Nếu có vẽ đồ thị

1. 2, 2, 2, 3 2. 1, 2, 2, 3, 4

3. 2, 2, 4, 4, 4 4. 1, 2, 3, 4.

(110)

Bài tập

Xét đồ thị G = (V, E),phần bù G G đồ thị có cùng

tập đỉnh V tập cạnh là tất cặp đỉnh phân biệt không kề G

Giả sử G có n đỉnh bậc là

d1, d2, , dn.

Các bậc G gì?

(111)

Đồ thị quy

Đồ thị mà đỉnh có bậc r gọi là

chính quy Khi r|V| = 2|E|.

Đồ thị Kn là đồ thị quy bậc n− 1.

Đồ thị vòng Cn đồ thị quy bậc

Đồ thị Qn đồ thị quy bậc ?

(112)

a

e b

d c

0

4

3

Hình:Đồ thị đầy đủ K5 và đồ thị chu trình C5

(113)

Bài tập

Liệt kê đồ thị quy bậc (đơi khơng đẳng cấu) với bảy đỉnh

(114)

Bài tập

Chứng minh đồ thị với hai đỉnh ln có hai đỉnh bậc

(115)

Nội dung

Đồ thị biểu diễn

Một số đồ thị đặc biệt

Đẳng cấu

Bậc

(116)

Định nghĩa

Mộthành trình trong đồ thị G dãy đỉnh

v1, v2, , vk,

thỏa mãn vi và vi+1 kề (với 1≤ i ≤ k − 1). a

e b

d c

(117)

Định nghĩa

Hành trình mà đỉnh khác gọi

đường đi

a

e b

d c

(118)

Đồ thị cộng tác

▶ Đỉnh: tác giả

Đỉnh a nối b hai tác giả a b viết chung báo

Số Erdưs nhà tốn học m là đường ngắn m Paul Erdös

10.4 Connectivity 681

TABLE 1 The Number of Mathematicians with a Given Erd˝os Number (as of early 2006).

Erd˝os Number Number of People

0 1 504 6,593 33,605 83,642 87,760 40,014 11,591 3,146 819 10 244 11 68 12 23 13

TABLE 2 The Number of Actors with a Given Bacon Number (as of early 2011).

Bacon Number Number of People

0 1 2,367 242,407 785,389 200,602 14,048 1,277 114 16

game where participants where challenged to find a sequence of movies leading from each actor named to Kevin Bacon We can find a number similar to a Bacon number using any actor as the

center of the acting universe ▲

Connectedness in Undirected Graphs

When does a computer network have the property that every pair of computers can share infor-mation, if messages can be sent through one or more intermediate computers? When a graph is used to represent this computer network, where vertices represent the computers and edges represent the communication links, this question becomes: When is there always a path between two vertices in the graph?

DEFINITION 3 An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph An undirected graph that is not connected is called disconnected We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph

Thus, any two computers in the network can communicate if and only if the graph of this network is connected

EXAMPLE 4 The graph G1in Figure is connected, because for every pair of distinct vertices there is a

path between them (the reader should verify this) However, the graph G2in Figure is not

connected For instance, there is no path in G2between vertices a and d ▲

We will need the following theorem in Chapter 11

(119)

Đồ thị Hollywood

▶ Đỉnh: diễn viên

Diễn viên a nối với diễn viên b nếu

a b đóng chung phim

Số Bacon diễn viên c đường đi ngắn c Kevin Bacon

10.4 Connectivity 681

TABLE 1 The Number

of Mathematicians with a Given Erd˝os Number (as of early 2006).

Erd˝os Number Number of People

0 1 504 6,593 33,605 83,642 87,760 40,014 11,591 3,146 819 10 244 11 68 12 23 13

TABLE 2 The Number

of Actors with a Given Bacon Number (as of early 2011).

Bacon Number Number of People

0 1 2,367 242,407 785,389 200,602 14,048 1,277 114 16

game where participants where challenged to find a sequence of movies leading from each actor named to Kevin Bacon We can find a number similar to a Bacon number using any actor as the

center of the acting universe ▲

Connectedness in Undirected Graphs

When does a computer network have the property that every pair of computers can share infor-mation, if messages can be sent through one or more intermediate computers? When a graph is used to represent this computer network, where vertices represent the computers and edges represent the communication links, this question becomes: When is there always a path between two vertices in the graph?

DEFINITION 3 An undirected graph is called connected if there is a path between every pair of distinct

vertices of the graph An undirected graph that is not connected is called disconnected We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph

Thus, any two computers in the network can communicate if and only if the graph of this network is connected

EXAMPLE 4 The graph G1 in Figure is connected, because for every pair of distinct vertices there is a

path between them (the reader should verify this) However, the graph G2 in Figure is not

connected For instance, there is no path in G2between vertices a and d ▲

We will need the following theorem in Chapter 11

(120)

Định nghĩa

Ta ký hiệu x ∼ y hai đỉnh x y G nối với nhau đường Có nghĩa rằng, tồn đường

v1, v2,· · · , vk

trong G với x = v1 và y = vk a

e b

d c

(121)

Dễ thấy, quan hệ∼ quan hệ tương đương tập đỉnh V G. Vậy V phân hoạch thành lớp tương đương rời nhau.

Hai đỉnh nằm lớp chúng có đường đi, hai lớp khác nếukhơng có đường

Ví dụ

Với đồ thị bên, ta có phân hoạch:

V = Vđỏ Vxanh

a

b

c

d e

f

(122)

Định nghĩa

Giả sử G = (V, E) đồ thị phân hoạch V tương ứng với quan hệ tương đương ∼ là

V = V1∪ V2∪ · · · ∪ Vr.

Ký hiệu Ei (với 1≤ i ≤ r) tập E bao gồm cạnh

với đầu mút nằm Vi Vậy đồ thị Gi= (Vi, Ei)

gọi cácthành phần liên thơng của G.

Ta nói Gliên thơng có thành phần liên thơng

(123)

Ví dụ

Đồ thị khơng liên thơng Nó có hai thành phần liên thông

a

b

c

d e

f

(124)

Bài tập

Tìm số thành phần liên thơng đồ thị với danh sách kề

a b c d e f g h i j f c b h c a b d a a

i g e g i c f f

j g j e

(125)

Bài tập

Đồ thị mô tả bữa tiệc bà April có thành phần liên thông?

(126)

Định nghĩa

Một hành trình

v1, v2, · · · , vr+1

trong đỉnh phân biệt ngoại trừ v1 = vr+1 gọi

mộtchu trình

Vì có r đỉnh phân biệt r cạnh nên ta thường gọi là

r-chu trình, hay chu trìnhđộ dài r.

a

e b

d c

(127)

Bài tập

▶ Hình thể địa điểm thú vị đảo Wanda đường chúng

▶ Hãy tìm đường đảo để thăm địa điểm lần trở vị trí xuất phát

p q

s

t r

u

(128)

Bài tập

Hãy tìm cách để hết đường, đường lần Địa điểm bắt đầu kết thúc khác

p q

s

t r

u

(129)

Định nghĩa

▶ Chu trình chứa đỉnh đồ thị gọi chu trình

Hamilton

▶ Hành trình dùng cạnh đúngmột lần gọi làhành trình

Euler

(130)

Bài tập

Tìm chu trình Hamilton đồ thị tạo đỉnh cạnh khối lập phương

10.7 Planar Graphs 719

FIGURE 2 The Graph K4.

FIGURE 3 K4 Drawn with No Crossings.

FIGURE 4 The Graph Q3.

FIGURE 5 A Planar Representation of Q3.

DEFINITION 1 A graph is called planar if it can be drawn in the plane without any edges crossing (where

a crossing of edges is the intersection of the lines or arcs representing them at a point other than their common endpoint) Such a drawing is called a planar representation of the graph.

A graph may be planar even if it is usually drawn with crossings, because it may be possible to draw it in a different way without crossings.

EXAMPLE 1 Is K4 (shown in Figure with two edges crossing) planar?

Solution: K4 is planar because it can be drawn without crossings, as shown in Figure 3. ▲

EXAMPLE 2 Is Q3, shown in Figure 4, planar?

Solution: Q3 is planar, because it can be drawn without any edges crossing, as shown in

Figure 5. ▲

We can show that a graph is planar by displaying a planar representation It is harder to show that a graph is nonplanar We will give an example to show how this can be done in an ad hoc fashion Later we will develop some general results that can be used to this.

EXAMPLE 3 Is K3,3, shown in Figure 6, planar?

Solution: Any attempt to draw K3,3 in the plane with no edges crossing is doomed We now

show why In any planar representation of K3,3, the vertices v1 and v2 must be connected to both

v4 and v5 These four edges form a closed curve that splits the plane into two regions, R1 and

R2, as shown in Figure 7(a) The vertex v3 is in either R1 or R2 When v3 is in R2, the inside

of the closed curve, the edges between v3 and v4 and between v3 and v5 separate R2 into two

subregions, R21 and R22, as shown in Figure 7(b).

v1 v2

v6

v3

v5

v4

FIGURE 6 The Graph K3,3.

v1 v4 v5 v2 v1 v4 v5 v2 v3

R2 R1 R1

R21

(a) (b)

R22

(131)

Bài tập

Năm tới, Dr Chunner Dr Dodder định thăm đảo Mianda Các địa điểm hấp dẫn đường nối chúng biểu diễn đồ thị có danh sách kề

0

1 1

3 5

5 7

7 8 8

▶ Liệu họ tìm đường đảo để thăm địa điểm lần trở vị trí xuất phát?

▶ Liệu họ tìm cách để hết đường, đường lần; địa điểm bắt đầu kết thúc khác nhau?

(132)

Cây

Trần Vĩnh Đức

HUST

Ngày 24 tháng năm 2018

(133)

Tài liệu tham khảo

Norman L Biggs, Discrete Mathematics, Oxford University Press, 2002

L Lovász, J Pelikán, K Vesztergombi, Discrete Mathematics:

Elementary and Beyond, Springer-Verlag New York, 2003.

K H Rosen, Toán học rời rạc ứng dụng tin học.

(134)

Nội dung

Một số tính chất

(135)

Định nghĩa

Ta nói đồ thị T mộtcây có hai tính chất: (T1) T liên thơng;

(T2) T khơng có chu trình.

Ví dụ

(136)

Các với 1, đỉnh

(137)

Có hai với đỉnh

(138)

Có ba với đỉnh

(139)

Bài tập

Ta biết có sáu (đôi không đẳng cấu) với sáu đỉnh; vẽ chúng

(140)

Mệnh đề

Nếu T = (V, E) với hai đỉnh, với cặp đỉnh x, y có đường từ x tới y.

Chứng minh

Vì T liên thơng nên có đường từ x tới y Nếu có đường khác từ x tới y, ta có chu trình

x

y

Mâu thuẫn với định nghĩa

(141)

Bài tập

Hãy chứng minh tính chất:

(T3) với cặp đỉnh x, y có đường từ x tới y;

kéo theo hai tính chất: (T1) T liên thơng; và

(T2) T khơng có chu trình.

(142)

Mệnh đề

Nếu T = (V, E) với hai đỉnh, đồ thị thu được từ T cách xóa cạnh có hai thành phần liên thông, thành phần

(143)

Mệnh đề

Nếu T = (V, E) thì|E| = |V| − 1.

1

2

5

9

(144)

Chứng minh quy nạp mạnh

Đặt P(n) = “Cây với n đỉnh có n− cạnh”

Bước sở:P(1) Tại sao?

Bước quy nạp:Giả sử P(1),· · · , P(k) để chứng minh

P(k + 1).

Xét T với |V| = k + xét uv cạnh T.

Xóa cạnh uv khỏi T ta hai T1 = (V1, E1)

T2 = (V2, E2), ta có

|V1| + |V2| = |V|, |E1| + |E2| = |E| − 1.

▶ Áp dụng giả thiết quy nạp ta

|E| = |E1| + |E2| + 1

= (|V1| − 1) + (|V2| − 1) + 1 =|V| − 1.

(145)

Định lý

Nếu T = (V, E) với hai đỉnh, thì:

(T3) với cặp đỉnh x, y có đường từ x tới y;

(T4) đồ thị thu từ T cách xóa cạnh có hai thành phần liên thông, thành phần cây;

(T5) |E| = |V| − 1.

(146)

Bài tập

Xét T = (V, E) với|V| ≥ Hãy chứng minh T có nhất hai đỉnh bậc

(147)

Bài tập

Xét T = (V, E) với |V| ≥ Hãy dùng tính chất (T5) |E| = |V| − 1;

để chứng minh T có hai đỉnh bậc 1.

(148)

Bài tập

Ta nói đồ thị F mộtrừng có tính chất: (T2) F khơng có chu trình.

Hãy chứng minh F = (V, E) rừng với c thành phần liên thơng

|E| = |V| − c.

(149)

Định lý

Xét đồ thị T = (V, E) Các khẳng định sau tương đương nhau:

1. T cây;

2. T không chứa chu trình và|E| = |V| − 1;

3. T liên thông và |E| = |V| − 1;

4. T đồ thị liên thơng, xóa cạnh thì

đồ thị thu không liên thông;

5. Hai đỉnh khác T nối với đúng đường;

6. T khơng chứa chu trình, ta thêm cạnh nối hai

đỉnh không kề T đồ thị nhận có đúng chu trình

(150)

Bài tập

Hãy chứng minh định lý trước

(151)

Nội dung

Một số tính chất

(152)

Câu hỏi

Có với n đỉnh?

(153)

Câu hỏi

Hai có trùng nhau?

(154)

Cây gán nhãn

▶ Ta cố định đỉnh cây, đỉnh gán nhãn

▶ Hai giống chúng có tập cạnh

(155)

Ví dụ

Hoán đổi nhãn gán nhãn cho ta gán nhãn khác

(156)

Bài tập

Tìm số gán nhãn với 2, 3, 4, đỉnh?

(157)

Định lý (Cayley)

Số gán nhãn với n đỉnh nn−2

Trong phần lại mục này, ta chứng minh định lý Cayley

(158)

Lưu trữ cây: dùng ma trận kề

0 1 0 0 0

0 0 0 0

1 0 1 0

1 0 0 0 0

0 0 0 0

0 0 0 0

0 1 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 1

(159)

Mệnh đề

Số lượng gán nhãn với n đỉnh phải không nhiều 2(n2−n)/2

Tại sao?

(160)

Lưu trữ cây: dùng danh sách cạnh

7 6

9 2

(161)

Mệnh đề

Số lượng gán nhãn với n đỉnh phải 22n log2n.

Tại sao?

(162)

Lưu trữ cây: dùng Father code

▶ Cố định đỉnh làm gốc (ví dụ đỉnh có nhãn nhỏ nhất)

▶ Liệt kê cạnh giống lưu trữ dùng danh sách cạnh (theo hai dòng); nhiên

▶ với cạnh, đỉnh dịng ln đỉnh gần gốc (hay gọi cha của) đỉnh dòng trên,

▶ đỉnh thứ tự

(163)

Father code: Ví dụ

1

6 0 9

Câu hỏi

Tại dòng lại số 1, 2, 3, 4, 5, 6, 7, 8, 9?

(164)

Father code

Nếu có n đỉnh dịng ln 1, 2, , n− 1.

▶ Tại số khơng xuất dịng đầu tiên?

▶ Vậy ta xóa dịng

▶ Father code dòng thứ

(165)

Bài tập

Xét ”mã” sau:

1 (0, 1, 2, 3, 4, 5, 6, 7);

2 (7, 6, 5, 4, 3, 2, 1, 0);

3 (0, 0, 0, 0, 0, 0, 0, 0);

4 (2, 3, 1, 2, 3, 1, 2, 3).

Những mã ”father codes” cây?

(166)

Mệnh đề

Số lượng gán nhãn với n đỉnh phải không nhiều nn−1

(167)

Lưu trữ cây: dùng Prüfer code mở rộng

Thuật tốn tính Prüfer code mở rộng từ

1. Nếu cạnh thuật tốn dừng

2. Tìm đỉnh u có bậc có nhãn nhỏ nhất khác

3. Gọi cạnh có đầu mút u là{u, v} Ghi ra uv

4. Xóa đỉnh u cạnh {u, v} khỏi cây.

5. Quay lại bước

8.4 How to Store Trees 151

0

FIGURE 8.5 A tree reconstructed from its Prăufer code

How does the first row start? Remember that this is the node that we delete in the first step; by the rule of constructing the Prăufer code, this is the node with degree with smallest label Could this node be node 1? No, because then we would have to delete it in the first step, and it could no longer occur, but it does By the same token, no number occurring in the second row could be a leaf of the tree at the beginning This rules out 2, 3, and

What about 5? It does not occur in the second row; does this mean that it is a leaf of the original tree? The answer is yes; otherwise, would have been the father of some other node, and it would have been written in the second row when this other node was deleted Thus was a leaf with smallest label, and the first row of the extended Prăufer code must start with

Lets try to figure out the next entry in the first row, which is, as we know, the leaf with smallest label of the tree after was deleted The node is still ruled out, since it occurs later in the second row ; but does not occur again, which means (by the same argument as before) that was the leaf with smallest label after was deleted Thus the second entry in the first row is

Similarly, the third entry must be 4, since all the smaller numbers either occur later or have been used already Continuing in a similar fashion, we get that the full array must have been

5 3 This corresponds to the tree in Figure 8.5

Proof [of Lemma 8.4.1] The considerations above are completely general, and can be summed up as follows:

Each entry in the first row of the extended Prăufer code is the smallest integer that does not occur in the first row before it, nor in the second row below or after it

(168)

Prüfer code mở rộng

1

6 9

Câu hỏi

Tại vị trí cuối hàng 0?

(169)

Bổ đề

Hàng Prüfer code mở rộng tính từ hàng thứ hai

(170)

Ví dụ

Giả sử ta có Prüfer code mở rộng thiếu hàng sau:

x1

2 3

Đỉnh x1 phải thỏa mãn ba điều kiện:

1 x1∈ {0, 1, , 7} Tại sao?

2 x1 đỉnh bậc 1, có nhãn nhỏ khác

3 khi xây dựng dãy từ cây, x1 bị xóa khỏi bước

Điều kiện x1 không xuất hàng Tại sao? Từ điều kiện 2, ta x1 = Tại sao?

(171)

Ví dụ

Tiếp tục ví dụ trước, ta có:

5 x2

2 3

Đỉnh x2 phải thỏa mãn ba điều kiện:

1 x2∈ {0, 1, , 7} Tại sao?

2 x2 đỉnh bậc 1, có nhãn nhỏ khác

3 khi xây dựng dãy từ cây, x2 bị xóa khỏi bước thứ hai

Vậy x2 =

(172)

Bài tập

Hãy hoàn thành nốt hàng Prüfer code mở rộng sau

5

2 3

(173)

Khẳng định

Mỗi phần tử hàng Prüfer code mở rộng số nguyên nhỏ thỏa mãn:

▶ hàng đầu tiên, số không xuất trước nó;

▶ hàng thứ hai, số khơng xuất phía sau

Ví dụ

/

1 3/ 4/ ?

6 6/ 2/ 9/ 9/ 2/ 0/

(174)

Prüfer code

▶ Ta khơng cần lưu trữ tồn Prüfer code mở rộng, mà

ta cần lưu tữ dãy gồm n− phần tử củahàng thứ hai

▶ Dãy gọi làPrüfer code

Vậy thì, Prüfer code dãy số độ dài n− 2, với phần tử số nguyên từ đến n− 1.

(175)

Bổ đề

Mọi dãy có độ dài n− gồm số nguyên n − là Prüfer code n đỉnh đó.

Ta hoàn thành chứng minh định lý sau chưa?

Định lý (Cayley)

Số gán nhãn với n đỉnh nn−2.

(176)

Bài tập (Lập trình)

Viết chương trình nhập vào dãy mã Prüfer in Bạn dạng danh sách cạnh, sử dụng công cụ Graphviz để vẽ tự động

(177)

Cài đặt Prufer Code

1 Version

2 Version

3 Version

(178)

Tô màu đỉnh đồ thị

Trần Vĩnh Đức

HUST

Ngày 24 tháng năm 2018

(179)

Tài liệu tham khảo

Norman L Biggs, Discrete Mathematics, Oxford University Press, 2002

(180)

Nội dung

Định nghĩa ví dụ

Thuật tốn tham lam tô màu đỉnh

Đồ thị hai phần

(181)

Ví dụ

Trường BK muốn xếp học cho sáu môn học v1, v2, v3, v4, v5, v6 biết có vài sinh viên học môn :

v1 và v2, v1 và v4, v3 và v5, v2 và v6,

v4 và v5, v5 và v6, v1 và v6

v1

v2

v3

v4

v5

v6

(182)

Xếp lịch học

v1

v2

v3

v4 v5

v6

Tiết Tiết Tiết Tiết

v1 và v3 v2 và v4 v5 v6

(183)

Xếp lịch học

▶ Ta tìm cách phân hoạch tập đỉnh thành phần cho không phần chứa cặp đỉnh kề

▶ Một cách hình thức, hàm

c : {v1, v2, v3, v4, v5, v6} −→ {1, 2, 3, 4} gán đỉnh với học

▶ Không tổng quát ta dùng số nguyên dương cho màu

(184)

Định nghĩa

Một cáchtô màuđỉnh đồ thị G = (V, E) hàm

c : V−→ N

thỏa mãn tính chất : Nếu{x, y} ∈ E c(x) ̸= c(y).

v1

v2

v3

v4

v5

v6

(185)

Định nghĩa

Sắc sốcủa đồ thị G, ký hiệu χ(G), số nguyên k nhỏ nhất

thỏa mãn có cách tơ màu G dùng k màu.

Nói cách khác, χ(G) = k có cách tơ màu c từ

V tới tập {1, 2, , k}, k số nguyên nhỏ thỏa mãn tính

chất

Ví dụ

Tìm sắc số đồ thị

v1

v2

v3

v4

v5 v6

(186)

Tìm số màu

Để chứng minh rằngsắc số của đồ thị k ta phải:

1 tìm cách tơ màu dùng k màu;

2 chứng minh khơng có cách tơ màu dùng k màu

(187)

Bài tập

Tìm sắc số đồ thị sau: (i) đồ thị đầy đủ Kn;

(ii) đồ thị vòng C2r; (iii) đồ thị vòng C2r+1;

(188)

Bài tập

Tìm sắc số đồ thị sau:

(189)

Bài tập

Hãy mơ tả tất đồ thị G có χ(G) = 1.

(190)

Nội dung

Định nghĩa ví dụ

Thuật tốn tham lam tơ màu đỉnh

Đồ thị hai phần

(191)

Bài tốn

Cho đồ thị G Hãy tìm χ(G).

là tốn khó Người ta chưa biết thuật tốn “nhanh” để giải nó, hầu hết người tin khơng có thuật tốn

(192)

Thuật toán tham lam

1. Sắp thứ tự đỉnh theo thứ tự đó: v1, v2,· · · , vn

2. for i = 1, 2, , n :

3. Gán màuhợp lệ nhỏ cho vi

(193)

Bài tập

Dùng thuật toán tham lam để tô màu đồ thị sau:

v1

v2

v3

v4 v5

v6

(194)

Bài tập

Tìm cách thứ tự đỉnh để thuật tốn tham lam tơ màu đồ thị sau dùng màu

(195)

Bài tập

Tìm cách thứ tự đỉnh để thuật tốn tham lam tơ màu đồ thị sau dùng màu

(196)

Mệnh đề

Nếu đỉnh G có bậc≤ k, thì thuật tốn tham lam

dùng nhiều k + màu.

Thử chứng minh quy nạp theo k

Đặt P(k) = “nếu đỉnh G có bậc≤ k thuật tốn tham lam dùng nhiều k + màu”

Bước sở : P(0) Tại sao?

Bước quy nạp : Giả sử P(k) để chứng minh P(k + 1) !!!

(197)

Chứng minh quy nạp theo số đỉnh

Đặt P(n) = “Đồ thị G vớin đỉnh và bậc đỉnh G đều

≤ k thuật toán tham lam dùng nhiều k + màu.”

Bước sở : P(1) G khơng có cạnh nào.

Bước quy nạp : Giả sử P(n) để chứng minh P(n + 1).

Xét G đồ thị với n + đỉnh có bậc lớn nhất≤ k.

Sắp xếp đỉnh theo thứ tự đó: v1, v2, , vn, vn+1

Xóa đỉnh vn+1 khỏi G ta thu đồ thị G′

Đồ thị G′ có bậc lớn ≤ k Tại sao?

Theo quy nạp, thuật tốn tham lam tơ màu G′ dùng nhiều nhất k + màu.

(198)

Chứng minh (tiếp)

vn+1

u1

u2

uℓ

vn+1 có ℓ≤ k hàng xóm

Thêm đỉnh vn+1 và cạnh liên quan vào lại G′ để G.

Đỉnh vn+1≤ k hàng xóm Tại sao?

▶ Vậy tồn màu hợp lệ {1, 2, , k + 1} để tô cho

vn+1

Vậy thuật tốn tham lam tơ màu G dùng không k + 1

màu 3

(199)

Bài tập

Một đồ thị cóđộ rộng k− đỉnh có sắp

xếp thành dãy

v1, v2,· · · , vn

sao cho đỉnh vi có cạnh nối với nhiều k− đỉnh đứng

trước

Hãy dùng quy nạp để chứng minh đồ thị với độ rộng nhỏ hơn k− tơ k màu.

(200)

Mệnh đề

Cho G đồ thị với đỉnh có bậc≤ k Nếu G liên thơng và khơngchính quy, χ(G)≤ k.

Hình:Đồ thị có độ rộng Tại sao?

(Miễn phí) Graphviz

Ngày đăng: 03/04/2021, 10:44

Tài liệu cùng người dùng

Tài liệu liên quan