prim’s algorithm and an mst speed- up berj chilingirian
TRANSCRIPT
Prim’s Algorithmand an MST Speed-UpBERJ CHILINGIRIAN
Today’s Plan
(1) Prim’s Algorithm (2) Implementation (3) Runtime Analysis (4) Speed-Up
Key Idea
Boruvka’s Algorithm
Prim’s Algorithm
Improved MST Algorithm
Minimum Spanning Tree
Given: undirected, connected, weighted graph
Return: tree with all vertices and of minimum weight
n verticesm edges
Prim’s Algorithm: The Idea
Algorithm
Correctness
Cut Lemma: At every step, all edges in are in the edges of the MST.
Simple Implementation
Better Implementation
Runtime Analysis
Procedure Number of Calls
Time per OperationArray
Time per OperationBinary Heap
Time per OperationFibonacci Heap
Insert
Extract Min
Decrease Key
Prim’s -
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
Boruvka’s + Prim’s
After iterations of Boruvka’s Algorithm# of Edges# of Vertices
Boruvka’s + Prim’s
Suppose , then
# of vertices is
Boruvka’s + Prim’s
Boruvka’s AlgorithmFor iterations
Prim’s Algorithm𝐺∗
𝑂 ¿
𝑂 (𝑚+𝑛∗ log𝑛)=𝑂 (𝑚+ 𝑛log𝑛
log𝑛)=𝑂 (𝑚+𝑛)
Boruvka’s + Prim’s
𝑂 (𝑚 log log𝑛)+𝑂(𝑚+ 𝑛log𝑛
log𝑛)=𝑂 (𝑚 log log𝑛)
Boruvka’s Algorithm Prim’s Algorithm
Questions?
Similarity to Dijkstra’sDIJKSTRA’S ALGORITHM
PRIM’S ALGORITHM