SlideShare a Scribd company logo
Minimum Spanning Tree
M.Balamurugan
Assistant Professor
Dept of Computer Science
Sri Kaliswari College
Sivakasi
TREE
B
A
FE
C
D
Connected acyclic graph
Tree with n nodes contains
exactly n-1 edges.
GRAPH
Graph with n nodes contains
less than or equal to n(n-1)/2
edges.
A connected,
undirected
graph
Four of the spanning trees of the graph
SPANNING TREE...
Suppose you have a connected undirected graph
Connected: every node is reachable from every
other node
Undirected: edges do not have an associated
direction
...then a spanning tree of the graph is a connected
subgraph in which there are no cycles
Minimizing costs
Applications:
electric power
water
telephone lines
MINIMUM SPANNING TREE
 Let G = (V, E) be a connected, undirected
graph where V is the set of nodes and E is
the set of edges. Each edge has a given
nonnegative length. The problem is to find
a subset T of the edges of G such that all
the nodes remain connected when only the
edges in T are used, and the sum of the
lengths of the edges in T is as small as
possible possible. Since G is connected, at
least one solution must exist.
Finding Spanning Trees
• There are two basic algorithms for finding minimum-cost
spanning trees, and both are greedy algorithms
• Kruskal’s algorithm:
Created in 1957 by Joseph Kruskal
• Prim’s algorithm
Created by Robert C. Prim
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
List the edges in
order of size:
ED 2
AB 3
AE 4
CD 4
BC 5
EF 5
CF 6
AF 7
BF 8
CF 8
Kruskal’s Algorithm
E
Select the shortest
edge in the network
ED 2
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
E
Select the next
shortest
edge which does not
create a cycle
ED 2
AB 3A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
E
Select the next
shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4 (or AE 4)
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
E
Select the next
shortest edge which
does not create a cycle
E
A
C
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
D CD 4
AE 4
BC 5 – forms a cycle
EF 5
A
F
B
C
E
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
All vertices have been
connected.
The solution is
ED 2
AB 3
CD 4
AE 4
EF 5
Total weight of tree:
18
A
F
B
C
D
E
2
7
4
5
8 6
4
5
3
8
Kruskal’s Algorithm
Algorithm
Kruskal’s Algorithm:
complexity
Sorting loop:
Initialization of components:
Finding and merging:
O(a log n)
O(n)
O(a log n)
O(a log n)
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Select any vertex
A
Select the shortest
edge connected to
that vertex
AB 3
Prim’s
Algorithm
E
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Select the shortest
edge connected to
any vertex already
connected.
AE 4
Prim’s
Algorithm
E
Select the shortest
edge connected to
any vertex already
connected.
ED 2
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Prim’s
Algorithm
E
Select the shortest
edge connected to
any vertex already
connected.
DC 4
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Prim’s
Algorithm
E
Select the shortest
edge connected to
any vertex already
connected.
EF 5A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
Prim’s
Algorithm
E
A
F
B
C
D
2
7
4
5
8 6
4
5
3
8
All vertices have been
connected.
The solution is
AB 3
AE 4
ED 2
DC 4
EF 5
Total weight of tree:
18
Prim’s
Algorithm
E
Prim’s
Algorithm
Complexity:
Outer loop: n-1 times
Inner loop: n times
O(n2)
Minimum Connector
Algorithms
Kruskal’s algorithm
1. Select the shortest edge
in a network
2. Select the next shortest
edge which does not create
a cycle
3. Repeat step 2 until
all vertices have
been connected
Prim’s algorithm
1. Select any vertex
2. Select the shortest edge
connected to that vertex
3. Select the shortest edge
connected to any vertex
already connected
4. Repeat step 3 until all
vertices have been
connected
Thank you!!

More Related Content

What's hot

All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
 

What's hot (20)

Least Squares method
Least Squares methodLeast Squares method
Least Squares method
 
Graph theory
Graph theory Graph theory
Graph theory
 
linear Algebra least squares
linear Algebra least squareslinear Algebra least squares
linear Algebra least squares
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
 
Connectivity of graph
Connectivity of graphConnectivity of graph
Connectivity of graph
 
Graph: Euler path and Euler circuit
Graph: Euler path and Euler circuitGraph: Euler path and Euler circuit
Graph: Euler path and Euler circuit
 
H0431038048
H0431038048H0431038048
H0431038048
 
Graph theory and life
Graph theory and lifeGraph theory and life
Graph theory and life
 
Finite difference method for charge calculation
Finite difference method for charge calculationFinite difference method for charge calculation
Finite difference method for charge calculation
 
Linear Algebra Applications
Linear Algebra ApplicationsLinear Algebra Applications
Linear Algebra Applications
 
Graph transformations
Graph transformationsGraph transformations
Graph transformations
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
Digital Logic Design-Lecture 5
Digital Logic Design-Lecture 5Digital Logic Design-Lecture 5
Digital Logic Design-Lecture 5
 
Curve Fitting - Linear Algebra
Curve Fitting - Linear AlgebraCurve Fitting - Linear Algebra
Curve Fitting - Linear Algebra
 
Planar graph
Planar graphPlanar graph
Planar graph
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Graph Theory: Connectivity & Isomorphism
Graph Theory: Connectivity & Isomorphism Graph Theory: Connectivity & Isomorphism
Graph Theory: Connectivity & Isomorphism
 
Vector analysis & matrix
Vector analysis & matrixVector analysis & matrix
Vector analysis & matrix
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
Few More Results on Sum Labeling of Split Graphs
Few More Results on Sum Labeling of Split GraphsFew More Results on Sum Labeling of Split Graphs
Few More Results on Sum Labeling of Split Graphs
 

Similar to Minimum Spanning Tree

APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
KUSHDHIRRA2111026030
 
Decision maths 1 graphs and networks
Decision maths 1 graphs and networksDecision maths 1 graphs and networks
Decision maths 1 graphs and networks
Michael Mireku
 
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
SintooChauhan6
 
Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdf
zefergaming
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
HJ DS
 

Similar to Minimum Spanning Tree (20)

Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
Graph theory1234
Graph theory1234Graph theory1234
Graph theory1234
 
Decision maths 1 graphs and networks
Decision maths 1 graphs and networksDecision maths 1 graphs and networks
Decision maths 1 graphs and networks
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
 
kruskal.ppt
kruskal.pptkruskal.ppt
kruskal.ppt
 
minimum spanning tree
minimum spanning tree minimum spanning tree
minimum spanning tree
 
Network and Tree in Graph Theory
Network and Tree in Graph TheoryNetwork and Tree in Graph Theory
Network and Tree in Graph Theory
 
Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdf
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Day 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on dsDay 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on ds
 
Ijciras1101
Ijciras1101Ijciras1101
Ijciras1101
 
Optimisation random graph presentation
Optimisation random graph presentationOptimisation random graph presentation
Optimisation random graph presentation
 
Split block domination in graphs
Split block domination in graphsSplit block domination in graphs
Split block domination in graphs
 
Kruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmKruskal & Prim's Algorithm
Kruskal & Prim's Algorithm
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
kruskal prim
kruskal primkruskal prim
kruskal prim
 
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
 

More from Balamurugan M (7)

Sorting algorithms in Data Structure
Sorting algorithms in Data StructureSorting algorithms in Data Structure
Sorting algorithms in Data Structure
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
Unit 3 notes
Unit 3 notesUnit 3 notes
Unit 3 notes
 
Unit 2 notes
Unit 2 notesUnit 2 notes
Unit 2 notes
 
Unit 1 notes
Unit 1 notesUnit 1 notes
Unit 1 notes
 
Attributes of output primitives unit ii
Attributes of output primitives unit iiAttributes of output primitives unit ii
Attributes of output primitives unit ii
 
Face recognition
Face recognitionFace recognition
Face recognition
 

Recently uploaded

extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
DiyaBiswas10
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
Scintica Instrumentation
 

Recently uploaded (20)

Comparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratesComparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebrates
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
 
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
THE IMPORTANCE OF MARTIAN ATMOSPHERE SAMPLE RETURN.
 
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
 
Shuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptxShuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptx
 
Astronomy Update- Curiosity’s exploration of Mars _ Local Briefs _ leadertele...
Astronomy Update- Curiosity’s exploration of Mars _ Local Briefs _ leadertele...Astronomy Update- Curiosity’s exploration of Mars _ Local Briefs _ leadertele...
Astronomy Update- Curiosity’s exploration of Mars _ Local Briefs _ leadertele...
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
 
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
 
Microbial Type Culture Collection (MTCC)
Microbial Type Culture Collection (MTCC)Microbial Type Culture Collection (MTCC)
Microbial Type Culture Collection (MTCC)
 
National Biodiversity protection initiatives and Convention on Biological Di...
National Biodiversity protection initiatives and  Convention on Biological Di...National Biodiversity protection initiatives and  Convention on Biological Di...
National Biodiversity protection initiatives and Convention on Biological Di...
 
SAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniquesSAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniques
 
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdfGEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdf
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
 
EY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxEY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptx
 
A Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on EarthA Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on Earth
 
In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
 
Citrus Greening Disease and its Management
Citrus Greening Disease and its ManagementCitrus Greening Disease and its Management
Citrus Greening Disease and its Management
 
FAIRSpectra - Towards a common data file format for SIMS images
FAIRSpectra - Towards a common data file format for SIMS imagesFAIRSpectra - Towards a common data file format for SIMS images
FAIRSpectra - Towards a common data file format for SIMS images
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
 

Minimum Spanning Tree