Top Banner
Prim’s Algorithm and an MST Speed-Up BERJ CHILINGIRIAN
17
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

Prim’s Algorithmand an MST Speed-UpBERJ CHILINGIRIAN

Page 2: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

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.

Key Idea

Boruvka’s Algorithm

Prim’s Algorithm

Improved MST Algorithm

Page 4: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

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.

Prim’s Algorithm: The Idea

Page 6: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

Algorithm

Page 7: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

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.

Simple Implementation

Page 9: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

Better Implementation

Page 10: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

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.

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.

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.

Boruvka’s + Prim’s

Suppose , then

# of vertices is

Page 14: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

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.

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.

Questions?

Page 17: Prim’s Algorithm and an MST Speed- Up BERJ CHILINGIRIAN.

Similarity to Dijkstra’sDIJKSTRA’S ALGORITHM

PRIM’S ALGORITHM