[acm-icpc] minimal spanning tree
TRANSCRIPT
![Page 2: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/2.jpg)
Rights to CopyAttribution-ShareAlike 3.0
You 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
![Page 3: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/3.jpg)
Spanning Tree● 生成樹● 從圖中分離出一顆樹包含圖中所有點
![Page 4: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/4.jpg)
Spanning Tree● 生成樹● 從圖中分離出一顆樹包含圖中所有點
![Page 5: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/5.jpg)
Minimal Spanning Tree● 最小生成樹● 邊的權重和最小的生成樹
5
8
10
![Page 6: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/6.jpg)
Minimal Spanning Tree● 最小生成樹● 邊的權重和最小的生成樹
5
8
10
![Page 7: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/7.jpg)
Algorithm● Prim's Algorithm● Kruskal's Algorithm
![Page 8: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/8.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 9: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/9.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 10: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/10.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 11: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/11.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 12: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/12.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 13: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/13.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
![Page 14: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/14.jpg)
Prim Algorithm● 每次擴張選擇與樹連接的最小權重邊
A
D
B
C
5
3
7
9
6
8
Cost 15
![Page 15: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/15.jpg)
Kruskal's Algorithm● 兩顆 MST( 把圖切割 ) 要合併時挑選之間最小權
重邊總是最好的● 單獨的點可以視為一個 MST
![Page 16: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/16.jpg)
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 17: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/17.jpg)
● 所有邊– AB – 3– AC – 5– AD – 8– BC – 6– BD – 9– CD – 7
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 18: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/18.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 19: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/19.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 20: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/20.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 21: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/21.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 22: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/22.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 23: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/23.jpg)
● sort– AB – 3– AC – 5– BC – 6– CD – 7– AD – 8– BD – 9
Kruskal's Algorithm
A
D
B
C
5
3
7
9
6
8
![Page 24: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/24.jpg)
Note● MST 並不唯一
![Page 25: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/25.jpg)
Practice
UVa - 10034
![Page 26: [ACM-ICPC] Minimal Spanning Tree](https://reader031.vdocuments.site/reader031/viewer/2022012318/55513e4bb4c905bd1c8b49a8/html5/thumbnails/26.jpg)
102/3/27 26
Thank You for Your Listening.