Minimum Spanning Tree: Kruskal's Algorithm and Prim's Algorithm, Study notes of Digital & Analog Electronics

The concept of a minimum spanning tree in graph theory and presents two popular algorithms, kruskal's algorithm and prim's algorithm, for finding the minimum spanning tree of a given graph. The steps and running time of each algorithm.

Typology: Study notes

2010/2011

Uploaded on 09/02/2011

hamit1990
hamit1990 🇮🇳

4.3

(76)

95 documents

1 / 38

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Minimum Spanning Tree
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Minimum Spanning Tree: Kruskal's Algorithm and Prim's Algorithm and more Study notes Digital & Analog Electronics in PDF only on Docsity!

Minimum Spanning Tree

A spanning tree of a graph is just a subgraph that

contains all the vertices and is a tree.

A graph may have many spanning trees.

or or or

Graph A Some Spanning Trees from Graph A

Spanning Trees

Minimum Spanning Trees

The Minimum Spanning Tree for a given graph is the Spanning Tree of

minimum cost for that graph.

Complete Graph Minimum Spanning Tree

Algorithms for Obtaining the Minimum Spanning Tree

  • (^) Kruskal's Algorithm
  • Prim's Algorithm

The steps are:

  1. The forest is constructed - with each node in a separate tree.
  2. The edges are placed in a priority queue.
  3. Until we've added n-1 edges,
    1. Extract the cheapest edge from the queue,
    2. If it forms a cycle, reject it,
    3. Else add it to the forest. Adding it to the forest will join two

trees together.

Every step will have joined two trees in the forest together, so that at

the end, there will only be one tree in T.

A

B C

D

E

F

G

H

I

J

Complete Graph

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Sort Edges

(in reality they are placed in a priority

queue - not sorted - but sorting them

makes the algorithm easier to visualize)

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Cycle

Don’t Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Add Edge

A

B C

D

E

F

G

H

I

J

B

B

D

J

C

C

E

F

D

D H

J

E G

F

F

G

I

G

G

I

J

H J

I J

A D

B C

A B

Cycle

Don’t Add Edge