SlideShare a Scribd company logo
1 of 11
SPANNING
TREE
What is Minimum
Spanning Tree (MST)
Let's start with Spanning Tree:
A spanning tree is defined as a tree-like subgraph of a connected, undirected graph that includes all
the vertices of the graph.it is a subset of the edges of the graph that forms a tree (acyclic) where
every node of the graph is a part of the tree.
What is minimum Spanning tree?
The minimum spanning tree has all the properties of a spanning tree with an added constraint of
having the minimum possible weights among all possible spanning trees. Like a spanning tree,
there can also be many possible MSTs for a graph.
Properties of a
Spanning Tree:
The spanning tree holds the below-mentioned principles:
The number of vertices (V) in the graph and the spanning tree is the same.
There is a fixed number of edges in the spanning tree which is equal to one less than the
total number of vertices ( E = V-1 ).
The spanning tree should not be disconnected, as in there should only be a single source of
component, not more than that.
The spanning tree should be acyclic, which means there would not be any cycle in the tree.
The total cost (or weight) of the spanning tree is defined as the sum of the edge weights of all
the edges of the spanning tree.
There can be many possible spanning trees for a graph.
There are two famous algorithms for finding the Minimum Spanning
Tree:
Kruskal’s Algorithm
Kruskal’s Algorithm builds the spanning tree by adding edges one by one into a growing spanning tree.
Kruskal's algorithm follows greedy approach as in each iteration it finds an edge which has least weight
and add it to the growing spanning tree.
Sort the graph edges with respect to their weights.
Start adding edges to the MST from the edge with the smallest weight until the edge of the largest weight.
Only add edges which doesn't form a cycle , edges which connect only disconnected components.
This algorithm can be implemented efficiently using a DSU ( Disjoint-Set ) data structure to keep track of
the connected components of the graph. This is used in a variety of practical applications such as network
design, clustering, and data analysis.
Prim’s Algorithm
Prim’s Algorithm also use Greedy approach to find the minimum spanning tree. In Prim’s Algorithm we
grow the spanning tree from a starting position. Unlike an edge in Kruskal's, we add vertex to the growing
spanning tree in Prim's.
Algorithm Steps:
Maintain two disjoint sets of vertices. One containing vertices that are in the growing
spanning tree and other that are not in the growing spanning tree.
Select the cheapest vertex that is connected to the growing spanning tree and is not in the
growing spanning tree and add it into the growing spanning tree. This can be done using
Priority Queues. Insert the vertices, that are connected to growing spanning tree, into the
Priority Queue.
Check for cycles. To do that, mark the nodes which have been already selected and insert
only those nodes in the Priority Queue that are not marked.
Time Complexity:
Primes algorithm:
The time complexity of the Prim’s Algorithm is
O((V+E)log(V)). because each edge is inserted in the
priority queue only once and insertion in priority
queue take logarithmic time.
Kruskal’s algorithm:
In Kruskal’s algorithm, most time consuming
operation is sorting because the total complexity of
the Disjoint-Set operations will be O(Elog(V)).
Application :
1. Network design: Spanning trees can be used in
network design to find the minimum number of
connections required to connect all nodes.
Minimum spanning trees, in particular, can help
minimize the cost of the connections by selecting
the cheapest edges.
2. Image processing: Spanning trees can be used
in image processing to identify regions of similar
intensity or color, which can be useful for
segmentation and classification tasks.
3. Social network analysis: Spanning trees and
minimum spanning trees can be used in social
network analysis to identify important
connections and relationships among individuals
or groups.
To learn more
about spanning
tree and MST
please visit at gfg
.

More Related Content

Similar to Presentation.pptx

prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithmshreeuva
 
Graph and Density Based Clustering
Graph and Density Based ClusteringGraph and Density Based Clustering
Graph and Density Based ClusteringAyushAnand105
 
Prim's and Kruskal's Algorithm
Prim's and Kruskal's AlgorithmPrim's and Kruskal's Algorithm
Prim's and Kruskal's AlgorithmOmTanna1
 
ADA Unit — 2 Greedy Strategy and Examples | RGPV De Bunkers
ADA Unit — 2 Greedy Strategy and Examples | RGPV De BunkersADA Unit — 2 Greedy Strategy and Examples | RGPV De Bunkers
ADA Unit — 2 Greedy Strategy and Examples | RGPV De BunkersRGPV De Bunkers
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15Kumar
 
Skiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning treesSkiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning treeszukun
 
Minimum Spanning Tree.pptx
Minimum Spanning Tree.pptxMinimum Spanning Tree.pptx
Minimum Spanning Tree.pptxHrRajon2
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mstSSE_AndyLi
 
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.pdfzefergaming
 
Minimum Spanning Tree using Kruskal's Algorithm
Minimum Spanning Tree using Kruskal's Algorithm Minimum Spanning Tree using Kruskal's Algorithm
Minimum Spanning Tree using Kruskal's Algorithm Mrunal Patil
 
OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.IJERA Editor
 

Similar to Presentation.pptx (20)

MST
MSTMST
MST
 
Data structure
Data structureData structure
Data structure
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
 
8_MST_pptx.pptx
8_MST_pptx.pptx8_MST_pptx.pptx
8_MST_pptx.pptx
 
Graph and Density Based Clustering
Graph and Density Based ClusteringGraph and Density Based Clustering
Graph and Density Based Clustering
 
Prim's and Kruskal's Algorithm
Prim's and Kruskal's AlgorithmPrim's and Kruskal's Algorithm
Prim's and Kruskal's Algorithm
 
Graph 2
Graph 2Graph 2
Graph 2
 
ADA Unit — 2 Greedy Strategy and Examples | RGPV De Bunkers
ADA Unit — 2 Greedy Strategy and Examples | RGPV De BunkersADA Unit — 2 Greedy Strategy and Examples | RGPV De Bunkers
ADA Unit — 2 Greedy Strategy and Examples | RGPV De Bunkers
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Skiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning treesSkiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning trees
 
Minimum Spanning Tree.pptx
Minimum Spanning Tree.pptxMinimum Spanning Tree.pptx
Minimum Spanning Tree.pptx
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst
 
26 spanning
26 spanning26 spanning
26 spanning
 
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
 
Graph clustering
Graph clusteringGraph clustering
Graph clustering
 
Combinatorial Optimization
Combinatorial OptimizationCombinatorial Optimization
Combinatorial Optimization
 
Bigdata analytics
Bigdata analyticsBigdata analytics
Bigdata analytics
 
Minimum Spanning Tree using Kruskal's Algorithm
Minimum Spanning Tree using Kruskal's Algorithm Minimum Spanning Tree using Kruskal's Algorithm
Minimum Spanning Tree using Kruskal's Algorithm
 
OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Presentation.pptx

  • 2. Let's start with Spanning Tree: A spanning tree is defined as a tree-like subgraph of a connected, undirected graph that includes all the vertices of the graph.it is a subset of the edges of the graph that forms a tree (acyclic) where every node of the graph is a part of the tree. What is minimum Spanning tree? The minimum spanning tree has all the properties of a spanning tree with an added constraint of having the minimum possible weights among all possible spanning trees. Like a spanning tree, there can also be many possible MSTs for a graph.
  • 3. Properties of a Spanning Tree: The spanning tree holds the below-mentioned principles: The number of vertices (V) in the graph and the spanning tree is the same. There is a fixed number of edges in the spanning tree which is equal to one less than the total number of vertices ( E = V-1 ). The spanning tree should not be disconnected, as in there should only be a single source of component, not more than that. The spanning tree should be acyclic, which means there would not be any cycle in the tree. The total cost (or weight) of the spanning tree is defined as the sum of the edge weights of all the edges of the spanning tree. There can be many possible spanning trees for a graph.
  • 4. There are two famous algorithms for finding the Minimum Spanning Tree:
  • 5. Kruskal’s Algorithm Kruskal’s Algorithm builds the spanning tree by adding edges one by one into a growing spanning tree. Kruskal's algorithm follows greedy approach as in each iteration it finds an edge which has least weight and add it to the growing spanning tree. Sort the graph edges with respect to their weights. Start adding edges to the MST from the edge with the smallest weight until the edge of the largest weight. Only add edges which doesn't form a cycle , edges which connect only disconnected components. This algorithm can be implemented efficiently using a DSU ( Disjoint-Set ) data structure to keep track of the connected components of the graph. This is used in a variety of practical applications such as network design, clustering, and data analysis.
  • 6.
  • 7. Prim’s Algorithm Prim’s Algorithm also use Greedy approach to find the minimum spanning tree. In Prim’s Algorithm we grow the spanning tree from a starting position. Unlike an edge in Kruskal's, we add vertex to the growing spanning tree in Prim's. Algorithm Steps: Maintain two disjoint sets of vertices. One containing vertices that are in the growing spanning tree and other that are not in the growing spanning tree. Select the cheapest vertex that is connected to the growing spanning tree and is not in the growing spanning tree and add it into the growing spanning tree. This can be done using Priority Queues. Insert the vertices, that are connected to growing spanning tree, into the Priority Queue. Check for cycles. To do that, mark the nodes which have been already selected and insert only those nodes in the Priority Queue that are not marked.
  • 8.
  • 9. Time Complexity: Primes algorithm: The time complexity of the Prim’s Algorithm is O((V+E)log(V)). because each edge is inserted in the priority queue only once and insertion in priority queue take logarithmic time. Kruskal’s algorithm: In Kruskal’s algorithm, most time consuming operation is sorting because the total complexity of the Disjoint-Set operations will be O(Elog(V)).
  • 10. Application : 1. Network design: Spanning trees can be used in network design to find the minimum number of connections required to connect all nodes. Minimum spanning trees, in particular, can help minimize the cost of the connections by selecting the cheapest edges. 2. Image processing: Spanning trees can be used in image processing to identify regions of similar intensity or color, which can be useful for segmentation and classification tasks. 3. Social network analysis: Spanning trees and minimum spanning trees can be used in social network analysis to identify important connections and relationships among individuals or groups.
  • 11. To learn more about spanning tree and MST please visit at gfg .