![Page 1: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/1.jpg)
Prim’s Algorithmand an MST Speed-UpBERJ CHILINGIRIAN
![Page 2: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/2.jpg)
Today’s Plan
(1) Prim’s Algorithm (2) Implementation (3) Runtime Analysis (4) Speed-Up
![Page 3: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/3.jpg)
Key Idea
Boruvka’s Algorithm
Prim’s Algorithm
Improved MST Algorithm
![Page 4: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/4.jpg)
Minimum Spanning Tree
Given: undirected, connected, weighted graph
Return: tree with all vertices and of minimum weight
n verticesm edges
![Page 5: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/5.jpg)
Prim’s Algorithm: The Idea
![Page 6: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/6.jpg)
Algorithm
![Page 7: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/7.jpg)
Correctness
Cut Lemma: At every step, all edges in are in the edges of the MST.
![Page 8: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/8.jpg)
Simple Implementation
![Page 9: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/9.jpg)
Better Implementation
![Page 10: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/10.jpg)
Runtime Analysis
Procedure Number of Calls
Time per OperationArray
Time per OperationBinary Heap
Time per OperationFibonacci Heap
Insert
Extract Min
Decrease Key
Prim’s -
![Page 11: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/11.jpg)
Achieving Time
Yao, 1975:
use linear median finding algorithm to approx. sorting of edges
Boruvka’s + Prim’s:
run Boruvka’s for iterations to produce
run Prim’s on
![Page 12: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/12.jpg)
Boruvka’s + Prim’s
After iterations of Boruvka’s Algorithm# of Edges# of Vertices
![Page 13: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/13.jpg)
Boruvka’s + Prim’s
Suppose , then
# of vertices is
![Page 14: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/14.jpg)
Boruvka’s + Prim’s
Boruvka’s AlgorithmFor iterations
Prim’s Algorithm𝐺∗
𝑂 ¿
𝑂 (𝑚+𝑛∗ log𝑛)=𝑂 (𝑚+ 𝑛log𝑛
log𝑛)=𝑂 (𝑚+𝑛)
![Page 15: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/15.jpg)
Boruvka’s + Prim’s
𝑂 (𝑚 log log𝑛)+𝑂(𝑚+ 𝑛log𝑛
log𝑛)=𝑂 (𝑚 log log𝑛)
Boruvka’s Algorithm Prim’s Algorithm
![Page 16: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/16.jpg)
Questions?
![Page 17: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN](https://reader036.vdocuments.site/reader036/viewer/2022062320/56649d765503460f94a570a9/html5/thumbnails/17.jpg)
Similarity to Dijkstra’sDIJKSTRA’S ALGORITHM
PRIM’S ALGORITHM