0% found this document useful (0 votes)
44 views21 pages

Minimum Spanning Tree

Kruskal's algorithm is a minimum spanning tree algorithm that finds an MST for a connected, undirected, weighted graph. It works by sorting the edges by weight and building the MST by adding edges in order of increasing weight, skipping edges that would cause cycles. The time complexity of Kruskal's algorithm is O(E log E) or O(E log V) as it sorts edges and uses a disjoint-set data structure. Minimum spanning trees have applications in network design, image processing, and other domains.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views21 pages

Minimum Spanning Tree

Kruskal's algorithm is a minimum spanning tree algorithm that finds an MST for a connected, undirected, weighted graph. It works by sorting the edges by weight and building the MST by adding edges in order of increasing weight, skipping edges that would cause cycles. The time complexity of Kruskal's algorithm is O(E log E) or O(E log V) as it sorts edges and uses a disjoint-set data structure. Minimum spanning trees have applications in network design, image processing, and other domains.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Minimum

Spanning
Tree
Tyler Bert N. Baring
BSCS - IV
Table of
Definition
01 What is Minimum Spanning
Tree (MST)?
Contents

History
02 A brief history of MST

Algorithm Illustration
03 Actual Algorithm Illustration
of MST

Design Technique
04 Algorithm Design Technique
used
Table of
Running Time
05 Time complexity Contents

Application
06 Where this algorithm is used

References
07 Sources
Brief History
Czech scientist Otakar Borůvka
developed the first known algorithm for Edsger Wybe Dijkstra rediscovered it
finding a minimum spanning tree, in in 1959, and called it Prim's algorithm.
1926. He wanted to solve the problem of The other algorithm is called Kruskal's
finding an efficient coverage of Moravia algorithm, and was pulbished by
with electricity. Today, this algorithm is Joseph Kruskal in 1956. All three
known as Borůvka's algorithm. algorithms are greedy, and run in
polynomial time.

1 2 3 4

The fastest minimum spanning tree algorithm to


Two other algorithms are
date was developed by Bernard Chazelle. The
commonly used today. One of them
algorithm is based on the soft heap, an
was developed by Vojtěch Jarník in
approximate priority queue. Its running time is
1930, and put in practice by Robert
O(m α(m,n)), where m is the number of edges, n
Clay Prim in 1957.
is the number of vertices and α is the classical
functional inverse of the Ackermann function.
Actual Algorithm
Illustration
Kruskal’s Algorithm
Kruskal’s Algorithm
It is used for finding the
Minimum Spanning Tree
Kruskal’s Algorithm is a (MST) of a given graph. To apply Kruskal’s
famous greedy algorithm, the given graph
algorithm. must be weighted, connected
and undirected.
Kruskal’s Algorithm Implementation
• Keep adding edges until all the
• Sort all the edges from vertices are connected and a
low weight to high Minimum Spanning Tree (MST)
weight. is obtained.

Step Step Step


1 2 3

• Take the edge with the lowest weight


and use it to connect the vertices of
graph.
• If adding an edge creates a cycle, then
reject that edge and go for the next least
weight edge.
Pseudocode of Kruskal’s Algorithm
algorithm Kruskal(G) is
F:= ∅
for each v ∈ G.V do
MAKE-SET(v)
for each (u, v) in G.E ordered by weight(u, v), increasing do
if FIND-SET(u) ≠ FIND-SET(v) then
F:= F ∪ {(u, v)} ∪ {(v, u)}
UNION(FIND-SET(u), FIND-SET(v))
return F
Constructing the MST for the
given graph using Kruskal’s
Algorithm
Step 1

Simply draw all the vertices

Reference
Step 2

Connect these vertices using


edges with minimum weights
such that no cycle gets formed.

Reference
Step 3

Reference
Step 4

Reference
Step 5

Reference
Step 6

Reference
Step 7

Since all the vertices have been


connected / included in the
MST, so we stop.

Reference
Weight of the MST
= Sum of all edge weights

= 10 + 25 + 22 + 12 + 16 + 14

= 99 units
Algorithm Design Technique

Kruskal’s Algorithm Analysis

01 02
Time Complexity-
Worst case time complexity of • The edges are maintained as min
Kruskal’s Algorithm heap.
= O(ElogV) or O(ElogE) • The next edge can be obtained in
O(logE) time if graph has E edges.
• Reconstruction of heap takes O(E)
time.
Special Case • So, Kruskal’s Algorithm takes

03 • If the edges are already sorted, O(ElogE) time.


• The value of E can be at most
then there is no need to
O(V2).
construct min heap.
• So, O(logV) and O(logE) are same.
• So, deletion from min heap time
is saved. For better understanding of Kruskal’s Algorithm,
• In this case, time complexity of here’s a YouTube Vid :
Kruskal’s Algorithm = O(E + V) https://youtu.be/DekG1-WdCrY
Running Time
Complexity
For a graph with E edges and V vertices, Kruskal's algorithm can be shown to run in O(E log E) time, or
equivalently, O(E log V) time, all with simple data structures. These running times are equivalent because:

• E is at most and
• Each isolated vertex is a separate component of the minimum spanning forest. If we ignore isolated
vertices we obtain V ≤ 2E, so log V is
We can achieve this bound as follows: first sort the edges by weight using a comparison sort in O(E log E)
time; this allows the step "remove an edge with minimum weight from S" to operate in constant time. Next,
we use a disjoint-set data structure to keep track of which vertices are in which components. We place each
vertex into its own disjoint set, which takes O(V) operations. Finally, in worst case, we need to iterate
through all edges, and for each edge we need to do two 'find' operations and possibly one union. Even a
simple disjoint-set data structure such as disjoint-set forests with union by rank can perform O(E) operations
in O(E log V) time. Thus the total time is O(E log E) = O(E log V).
For a detailed explanation of the example, click here
https://bit.ly/3VjFJWR
Application
Minimum spanning trees have direct applications in the design of networks, including computer networks,
telecommunications networks, transportation networks, water supply networks, and electrical grids. They are
invoked as subroutines in algorithms for other problems, including the Christofides algorithm for
approximating the traveling salesman problem, approximating the multi-terminal minimum cut problem (which
is equivalent in the single-terminal case to the maximum flow problem),[19] and approximating the minimum-
cost weighted perfect matching.

Other practical applications based on minimal spanning trees include:

Taxonomy Image Registration Curcuit Design


and Segmentation
Other applications also include; Cluster analysis, Handwriting Recognition, Comparing Ecotoxicology data, Topological
observability in power systems, Minimax process control, Curvilinear feature extraction in computer vision, Constructing
trees for broadcasting in computer networks, and more.
References
● History - https://bit.ly/3AqKaGT

● Actual Algorithm Illustration –


https://www.gatevidyalay.com/kruskals-algorithm-kruskals-algorithm-example

● Algorithm Design Technique used –


https://www.javatpoint.com/kruskal-algorithm

● Running Time –
https://en.wikipedia.org/wiki/Kruskal's_algorithm#Complexity

● Application – https://bit.ly/3giYY3e

You might also like