SlideShare a Scribd company logo
Minimal Spanning
Tree
Basic Terminology,
Applications and
Algorithms
 Introduction
 What is Minimal Spanning Tree (MST)
 Applications
 Where we can use MST
 Functions
 How to find MST
 Prim’s algorithm
 Kruskal’s algorithm
 Conclusions
Overview
Slide 2
 A Spanning Tree (ST) of a graph is a subgraph that contains all the
vertices and is a tree, i.e., no Cycle & Connected.
 A graph may have many spanning trees.
Introduction
16 ST
Slide 3
 A Spanning Tree (ST) of a graph is a subgraph that contains all the
vertices and is a tree, i.e., no Cycle & Connected.
 A graph may have many spanning trees.
 Let, the edges were weighted.
 Minimal Spanning Tree (MST) is spanning tree with the minimum sum
of edges,
Introduction Cont …
( , )
( ) ( , )
u v T
w T w u v

 
Slide 4
 Phone network design.
Applications of MST
Central office
The phone company charges different
amounts of money to connect different pairs of cities.
Expensive
Slide 5
 Phone network design.
Applications of MST Cont …
Central office
Better Approach
The phone company charges different
amounts of money to connect different pairs of cities.
Slide 6
 Electronic circuitry
 Set of pins wiring them together.
 We want to minimize the total length of the wires.
 Minimum Spanning Trees can be used to model this problem.
Applications of MST Cont …
Slide 7
How We Can Find a MST
Robert Clay Prim is an American mathematician and computer
scientist.
During the climax of World War II (1941–1944), Prim worked as an
engineer for General Electric. From 1944 until 1949, he was hired by the
United States Naval Ordnance Lab as an engineer and later a
mathematician. At Bell Laboratories, he served as director of
mathematics research from 1958 to 1961. There, Prim implimented the
Prim's algorithm.
Which is was originally discovered in 1930 by mathematician Vojtech
Jarnik and later later rediscovered by Edsger Dijkstra in 1959.
Vojtěch Jarník was a Czech mathematician.
His main area of work was in number theory and mathematical analysis;
he proved a number of results on lattice point problems. He also
developed the graph theory algorithm which is now known as Prim's
algorithm.
 Greedy
 Two Most Popular Algorithms
 Prime’s Algorithm
 Kruskal’s Algorithm
Slide 8
How We Can Find a MST Cont …
 Greedy
 Two Most Popular Algorithms
 Prime’s Algorithm
 Kruskal’s Algorithm
Joseph Bernard Kruskal, Jr. is an American mathematician.
His best known work is Kruskal's algorithm for computing the minimal
spanning tree. The algorithm first orders the edges by weight and then
proceeds through the ordered list adding an edge to the partial MST
provided that adding the new edge does not create a cycle.
Kruskal also applied his work in linguistics, in an experimental
lexicostatistical study of Indo-European languages, together with the
linguists Isidore Dyen and Paul Black.
Slide 9
Prime’s Algorithm
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Select a vertex to be a tree-node
while (there are non-tree vertices) {
if there is no edge connecting a tree
node with a non-tree node
return “no spanning tree”
select an edge of minimum weight
between a tree node and a non-tree node
add the selected edge and its new vertex
to the tree
}
return tree
Slide 10
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 11
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 12
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 13
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 14
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 15
Prime’s Algorithm Cont …
 Vertex based algorithm
 Grows one tree T, one vertex at a time
 Tree-vertices: in the tree constructed so far
 Non-tree vertices: rest of vertices
 Prim’s Selection rule “Select the minimum weight edge between a tree-
node and a non-tree node and add to the tree.”
Slide 16
Weight of the Spanning Tree
=23+29+31+32+47+54+66
=282
More Detail
 r : Grow the minimum spanning tree from the root vertex “r”.
 Q : is a priority queue, holding all vertices that are not in the tree
now.
 key[v] : is the minimum weight of any edge connecting v to a
vertex in the tree.
 p [v] : names the parent of v in the tree.
 T[v] – Vertex v is already included in MST if T[v]==1, otherwise, it
is not included yet.
Prime’s Algorithm Cont …
Slide 17
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
V a b c d e f g h i
T 1 0 0 0 0 0 0 0 0
Key 0 - - - - - - - -
p -1 - - - - - - - -
Prime’s Algorithm Cont …
Slide 18
root
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
V a b c d e f g h i
T 1 0 0 0 0 0 0 0 0
Key 0 4 - - - - - 8 -
p -1 a - - - - - a -
Prime’s Algorithm Cont …
Slide 19
root
V a b c d e f g h i
T 1 1 0 0 0 0 0 0 0
Key 0 4 8 - - - - 8 -
p -1 a b - - - - a -
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Important: Update Key[v] only if T[v]==0
Prime’s Algorithm Cont …
Slide 20
root
V a b c d e f g h i
T 1 1 1 0 0 0 0 0 0
Key 0 4 8 7 - 4 - 8 2
p -1 a b c - c - a c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 21
root
V a b c d e f g h i
T 1 1 1 0 0 0 0 0 1
Key 0 4 8 7 - 4 6 7 2
p -1 a b c - c i i c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 22
root
V a b c d e f g h i
T 1 1 1 0 0 1 0 0 1
Key 0 4 8 7 10 4 2 7 2
p -1 a b c f c f i c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 23
root
V a b c d e f g h i
T 1 1 1 0 0 1 1 0 1
Key 0 4 8 7 10 4 2 1 2
p -1 a b c f c f g c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 24
root
V a b c d e f g h i
T 1 1 1 0 0 1 1 1 1
Key 0 4 8 7 10 4 2 1 2
p -1 a b c f c f g c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 25
root
V a b c d e f g h i
T 1 1 1 1 0 1 1 1 1
Key 0 4 8 7 9 4 2 1 2
p -1 a b c d c f g c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
Prime’s Algorithm Cont …
Slide 26
root
V a b c d e f g h i
T 1 1 1 1 1 1 1 1 1
Key 0 4 8 7 9 4 2 1 2
p -1 a b c d c f g c
a
b
h
c d
e
f
g
i
4
8 7
9
10
14
4
2
2
6
1
7
11
8
All T[v] = 1
So Done
Prime’s Algorithm Cont …
Slide 27
root
Kruskal’s Algorithm
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
 Edge based algorithm
 Add the edges one at a time, in increasing weight order
 It maintains a forest of trees.
 An edge is accepted it if connects vertices of distinct trees
Slide 28
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 29
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 30
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 31
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 32
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 33
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 34
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Up to this point, we have simply
taken the edges in order of their
weight. But now we will have to
reject an edge since it forms a
cycle when added to those
already chosen.
Slide 35
Kruskal’s Algorithm Cont …
Basic Terminology
 Cut : Partition of V. Ex: (S, V-S)
 Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is
in S and the other is in V-S.
 Light edge : An edge crossing a cut if its weight is the minimum of
any edge crossing the cut.
 Kruskal’s Algorithm
Slide 36
Weight of the Spanning Tree
=23+29+31+32+47+54+66
=282
Prime’s Vs Kruskal’s
Slide 37
Conclusions
 MST  Still works are going on
 Boruvka's Algorithm
 Inventor of MST
 Prim’s algorithm “in parallel”
 Huge Number of Applications
 Networking
 Data mining
 Clustering, Classification etc.
Slide 38
Questions or Suggestions
Thank You!

More Related Content

Similar to 8_MST_pptx.pptx

Ram minimum spanning tree
Ram   minimum spanning treeRam   minimum spanning tree
Ram minimum spanning tree
Rama Prasath A
 
17 prims-kruskals (1)
17 prims-kruskals (1)17 prims-kruskals (1)
17 prims-kruskals (1)
MOHAMMADATHARKHAN2
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
B.Kirron Reddi
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
Hanif Durad
 
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
 
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHMDATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
ABIRAMIS87
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
Krish_ver2
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
rohitsingh935398
 
Algorithms explained
Algorithms explainedAlgorithms explained
Algorithms explained
PIYUSH Dubey
 
Data structure
Data structureData structure
Data structure
SangeethaSasi1
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
Madhu Bala
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
Alona Salva
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
sachin varun
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst
SSE_AndyLi
 
Unit3_1.pdf
Unit3_1.pdfUnit3_1.pdf
Unit3_1.pdf
Pratimakumari213460
 
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
 
04 greedyalgorithmsii
04 greedyalgorithmsii04 greedyalgorithmsii
04 greedyalgorithmsii
LENIN Quintero
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
Shareb Ismaeel
 
lecture 16
lecture 16lecture 16
lecture 16
sajinsc
 

Similar to 8_MST_pptx.pptx (20)

Ram minimum spanning tree
Ram   minimum spanning treeRam   minimum spanning tree
Ram minimum spanning tree
 
17 prims-kruskals (1)
17 prims-kruskals (1)17 prims-kruskals (1)
17 prims-kruskals (1)
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
 
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
 
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHMDATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
 
5.1 greedy 03
5.1 greedy 035.1 greedy 03
5.1 greedy 03
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Algorithms explained
Algorithms explainedAlgorithms explained
Algorithms explained
 
Data structure
Data structureData structure
Data structure
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst
 
Unit3_1.pdf
Unit3_1.pdfUnit3_1.pdf
Unit3_1.pdf
 
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
 
04 greedyalgorithmsii
04 greedyalgorithmsii04 greedyalgorithmsii
04 greedyalgorithmsii
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
lecture 16
lecture 16lecture 16
lecture 16
 

Recently uploaded

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 

Recently uploaded (20)

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 

8_MST_pptx.pptx

  • 2.  Introduction  What is Minimal Spanning Tree (MST)  Applications  Where we can use MST  Functions  How to find MST  Prim’s algorithm  Kruskal’s algorithm  Conclusions Overview Slide 2
  • 3.  A Spanning Tree (ST) of a graph is a subgraph that contains all the vertices and is a tree, i.e., no Cycle & Connected.  A graph may have many spanning trees. Introduction 16 ST Slide 3
  • 4.  A Spanning Tree (ST) of a graph is a subgraph that contains all the vertices and is a tree, i.e., no Cycle & Connected.  A graph may have many spanning trees.  Let, the edges were weighted.  Minimal Spanning Tree (MST) is spanning tree with the minimum sum of edges, Introduction Cont … ( , ) ( ) ( , ) u v T w T w u v    Slide 4
  • 5.  Phone network design. Applications of MST Central office The phone company charges different amounts of money to connect different pairs of cities. Expensive Slide 5
  • 6.  Phone network design. Applications of MST Cont … Central office Better Approach The phone company charges different amounts of money to connect different pairs of cities. Slide 6
  • 7.  Electronic circuitry  Set of pins wiring them together.  We want to minimize the total length of the wires.  Minimum Spanning Trees can be used to model this problem. Applications of MST Cont … Slide 7
  • 8. How We Can Find a MST Robert Clay Prim is an American mathematician and computer scientist. During the climax of World War II (1941–1944), Prim worked as an engineer for General Electric. From 1944 until 1949, he was hired by the United States Naval Ordnance Lab as an engineer and later a mathematician. At Bell Laboratories, he served as director of mathematics research from 1958 to 1961. There, Prim implimented the Prim's algorithm. Which is was originally discovered in 1930 by mathematician Vojtech Jarnik and later later rediscovered by Edsger Dijkstra in 1959. Vojtěch Jarník was a Czech mathematician. His main area of work was in number theory and mathematical analysis; he proved a number of results on lattice point problems. He also developed the graph theory algorithm which is now known as Prim's algorithm.  Greedy  Two Most Popular Algorithms  Prime’s Algorithm  Kruskal’s Algorithm Slide 8
  • 9. How We Can Find a MST Cont …  Greedy  Two Most Popular Algorithms  Prime’s Algorithm  Kruskal’s Algorithm Joseph Bernard Kruskal, Jr. is an American mathematician. His best known work is Kruskal's algorithm for computing the minimal spanning tree. The algorithm first orders the edges by weight and then proceeds through the ordered list adding an edge to the partial MST provided that adding the new edge does not create a cycle. Kruskal also applied his work in linguistics, in an experimental lexicostatistical study of Indo-European languages, together with the linguists Isidore Dyen and Paul Black. Slide 9
  • 10. Prime’s Algorithm  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Select a vertex to be a tree-node while (there are non-tree vertices) { if there is no edge connecting a tree node with a non-tree node return “no spanning tree” select an edge of minimum weight between a tree node and a non-tree node add the selected edge and its new vertex to the tree } return tree Slide 10
  • 11. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 11
  • 12. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 12
  • 13. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 13
  • 14. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 14
  • 15. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 15
  • 16. Prime’s Algorithm Cont …  Vertex based algorithm  Grows one tree T, one vertex at a time  Tree-vertices: in the tree constructed so far  Non-tree vertices: rest of vertices  Prim’s Selection rule “Select the minimum weight edge between a tree- node and a non-tree node and add to the tree.” Slide 16 Weight of the Spanning Tree =23+29+31+32+47+54+66 =282
  • 17. More Detail  r : Grow the minimum spanning tree from the root vertex “r”.  Q : is a priority queue, holding all vertices that are not in the tree now.  key[v] : is the minimum weight of any edge connecting v to a vertex in the tree.  p [v] : names the parent of v in the tree.  T[v] – Vertex v is already included in MST if T[v]==1, otherwise, it is not included yet. Prime’s Algorithm Cont … Slide 17
  • 18. a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 V a b c d e f g h i T 1 0 0 0 0 0 0 0 0 Key 0 - - - - - - - - p -1 - - - - - - - - Prime’s Algorithm Cont … Slide 18 root
  • 19. a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 V a b c d e f g h i T 1 0 0 0 0 0 0 0 0 Key 0 4 - - - - - 8 - p -1 a - - - - - a - Prime’s Algorithm Cont … Slide 19 root
  • 20. V a b c d e f g h i T 1 1 0 0 0 0 0 0 0 Key 0 4 8 - - - - 8 - p -1 a b - - - - a - a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Important: Update Key[v] only if T[v]==0 Prime’s Algorithm Cont … Slide 20 root
  • 21. V a b c d e f g h i T 1 1 1 0 0 0 0 0 0 Key 0 4 8 7 - 4 - 8 2 p -1 a b c - c - a c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 21 root
  • 22. V a b c d e f g h i T 1 1 1 0 0 0 0 0 1 Key 0 4 8 7 - 4 6 7 2 p -1 a b c - c i i c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 22 root
  • 23. V a b c d e f g h i T 1 1 1 0 0 1 0 0 1 Key 0 4 8 7 10 4 2 7 2 p -1 a b c f c f i c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 23 root
  • 24. V a b c d e f g h i T 1 1 1 0 0 1 1 0 1 Key 0 4 8 7 10 4 2 1 2 p -1 a b c f c f g c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 24 root
  • 25. V a b c d e f g h i T 1 1 1 0 0 1 1 1 1 Key 0 4 8 7 10 4 2 1 2 p -1 a b c f c f g c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 25 root
  • 26. V a b c d e f g h i T 1 1 1 1 0 1 1 1 1 Key 0 4 8 7 9 4 2 1 2 p -1 a b c d c f g c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 Prime’s Algorithm Cont … Slide 26 root
  • 27. V a b c d e f g h i T 1 1 1 1 1 1 1 1 1 Key 0 4 8 7 9 4 2 1 2 p -1 a b c d c f g c a b h c d e f g i 4 8 7 9 10 14 4 2 2 6 1 7 11 8 All T[v] = 1 So Done Prime’s Algorithm Cont … Slide 27 root
  • 28. Kruskal’s Algorithm Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm  Edge based algorithm  Add the edges one at a time, in increasing weight order  It maintains a forest of trees.  An edge is accepted it if connects vertices of distinct trees Slide 28
  • 29. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 29
  • 30. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 30
  • 31. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 31
  • 32. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 32
  • 33. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 33
  • 34. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 34
  • 35. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Up to this point, we have simply taken the edges in order of their weight. But now we will have to reject an edge since it forms a cycle when added to those already chosen. Slide 35
  • 36. Kruskal’s Algorithm Cont … Basic Terminology  Cut : Partition of V. Ex: (S, V-S)  Cross : Edge (u,v) crosses the cut (S, V-S) if one of its endpoints is in S and the other is in V-S.  Light edge : An edge crossing a cut if its weight is the minimum of any edge crossing the cut.  Kruskal’s Algorithm Slide 36 Weight of the Spanning Tree =23+29+31+32+47+54+66 =282
  • 38. Conclusions  MST  Still works are going on  Boruvka's Algorithm  Inventor of MST  Prim’s algorithm “in parallel”  Huge Number of Applications  Networking  Data mining  Clustering, Classification etc. Slide 38