Upcoming SlideShare
×

# [ACM-ICPC] Minimal Spanning Tree

830 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
830
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
18
0
Likes
0
Embeds 0
No embeds

No notes for slide

### [ACM-ICPC] Minimal Spanning Tree

1. 1. Minimal Spanning Tree陳鵬宇 (float)<float.tw@gmail.com>
2. 2. Rights to CopyAttribution-ShareAlike 3.0You are free: – to Share — to copy, distribute and transmit the work – to Remix — to adapt the work – to make commercial use of the work ● Under the following conditions: – Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). – Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. – License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode
3. 3. Spanning Tree● 生成樹● 從圖中分離出一顆樹包含圖中所有點
4. 4. Spanning Tree● 生成樹● 從圖中分離出一顆樹包含圖中所有點
5. 5. Minimal Spanning Tree● 最小生成樹● 邊的權重和最小的生成樹 5 10 8
6. 6. Minimal Spanning Tree● 最小生成樹● 邊的權重和最小的生成樹 5 10 8
7. 7. Algorithm● Prims Algorithm● Kruskals Algorithm
8. 8. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
9. 9. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
10. 10. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
11. 11. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
12. 12. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
13. 13. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 D
14. 14. Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊 3 B A 5 6 9 8 C 7 Cost 15 D
15. 15. Kruskals Algorithm● 兩顆 MST( 把圖切割 ) 要合併時挑選之間最小權 重邊總是最好的● 單獨的點可以視為一個 MST
16. 16. Kruskals Algorithm 3 B A 5 6 9 8 C 7 D
17. 17. Kruskals Algorithm● 所有邊 3 B A – AB – 3 – AC – 5 5 6 – AD – 8 9 – BC – 6 8 – BD – 9 C 7 – CD – 7 D
18. 18. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
19. 19. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
20. 20. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
21. 21. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
22. 22. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
23. 23. Kruskals Algorithm● sort 3 B A – AB – 3 – AC – 5 5 6 – BC – 6 9 – CD – 7 8 – AD – 8 C 7 – BD – 9 D
24. 24. Note● MST 並不唯一
25. 25. PracticeUVa - 10034
26. 26. Thank You for Your Listening.102/3/27 26