SlideShare a Scribd company logo
Lecture 12 Minimum Spanning Tree
Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast All nodes in the network are destinations Multicast Some nodes in the network are destinations Only one copy of the information travels along common edges Message replication along forking points only. 1 2
Spanning Tree We consider undirected graphs here. A tree is a connected graph without a cycle  A spanning tree is a tree which has all vertices of the graph There may be multiple spanning trees We need to choose the minimum weight tree for broadcast.
Blue edge spanning tree is the minimum weight spanning tree 5 4 4 5
Properties of a Tree A tree of V vertices has V-1 edges There exists a unique path between any two vertices of a  tree. Adding any edge to a tree creates a unique cycle. Breaking any edge on this cycle restores a tree.
Minimum Spanning Tree Construction We maintain a set of edges A, which is initially empty. Edges are added to A one at a time such that finally A becomes a minimum spanning tree. Edges are never removed from A. So ``safe’’ edges must be added to A, i.e., at any stage A must be a part of a spanning tree.
Safe Edge Addition Consider a cut in  a graph (a cut consists of 2 sets which partition the vertex set). A cut respects a set of edges I if no edge in the set crosses the cut. A minimum  weight edge crossing a cut is denoted  a light weight edge in the cut {A,B,C}  {D,E,F} constitute a cut. Let I = {edge AB, edge EF}.Cut {A,B,C}, {D,E,F} respects set I Edge CD is a light weight edge in the example cut. A B C D E F 2 1 3 1
Let A be a subset of a MST (minimum weight spanning tree). Let (S, V – S) be any cut that respects A Let edge (u, v) be a light edge crossing the cut Then A    (u, v) is subset of a MST
Assume that all the edge weights are distinct. Let no MST containing A contain edge (u, v). Add the edge (u, v) to T Consider a MST T containing A Since (u, v) is not in T,  T    (u, v)  contains a cycle, and (u, v) is in the cycle. Edge (u, v) are in the opposite sides of the cut. Since any cycle must cross the cut even number of times, there exists at least one other edge (x, y) crossing the cut.  Clearly, w(x, y)  > w(u, v).
The edge (x, y) is not in A because (x, y) crosses the cut, and the cut respects A.  Removing (x, y) from the cycle, breaks the cycle and hence creates a spanning tree, T’, s.t. T’ = T    (u, v)  – (x, y) w(T’) = w(T) + w(u, v) – w(x, y)    w(T)  (as w(u, v)  < w(x, y)) This contradicts the fact that T is a MST.
So we always find a cut that respects A, And add a light edge across the cut to A. Kruskals and Prims algorithms find the cut differently.
Kruskals Algorithm  A =   For each vertex u in V,  Create_Set(u) Sort E in increasing order by weight w For each edge (u,v) in the sorted list If Set(u)  = Set(v) Add (u,v) to A Union Set(u) and Set(v) Return A;
Complexity Analysis The operations create set, testing whether set(u) == set(v), union operations can be done in log V operations, using Union find data structure. Step 1 can be done in Vlog V Step 2 can be done in Elog E Step 3 can be done in Elog V Overall complexity is O(Vlog V + Elog E + Elog V) or O((V + E)log V)
5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7
Prims Algorithm Maintains a set of vertices S already in the spanning tree. Initially, S consists of one vertex r, selected arbitrarily. For every vertex u in V – S, maintain the weight of the lightest edge between u and any vertex in S. If there is no edge between u and S, then this weight associated with u is infinity.
Add the vertex with the least weight to S. This is in effect adding the light weight edge crossing the cut S and V-S. Whenever a vertex is added to S, the weights of all its neighbors are reduced, if necessary.
Pseudo-Code For each u in V, key[u] =   S =   Pred[r] = NULL Key[r] = 0 While V   = S u = Extract_Min(V-S) For each (v in Adj(u)) if (v not in S) key(v) = min(w(u, v), key(v)) and pred(v) = u  Add u in S
For each v in Adj[u]…. can be done in E complexity  Rest of the loop can be done in V 2  complexity So, overall O(V 2 ) Using heaps we can solve in O((V + E)logV)
Example 0 s 7 5 7 2 1 8 5 3 2 5 3 1 s 0 2 8 5 7 2 8 5 s 0 7 3 1 5 2 3 5 8 0 3 2 5 s 7 2 1 8 5 5 3 1 8 5 s 0 7 2 3 1 5 2 3 5 1 3 8 5 s 0 7 2 1 5 2 3 5 1
Ad

More Related Content

What's hot (20)

Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
B.Kirron Reddi
 
Weighted graphs
Weighted graphsWeighted graphs
Weighted graphs
Core Condor
 
Module No. 6
Module No. 6Module No. 6
Module No. 6
Rajput AbdulWaheed Bhatti
 
Pwerhitungan struktur kabel listrick
Pwerhitungan struktur kabel listrick Pwerhitungan struktur kabel listrick
Pwerhitungan struktur kabel listrick
CARLES HUTABARAT
 
Grade 12 Unit1-L1-Kinematic Equations
Grade 12 Unit1-L1-Kinematic EquationsGrade 12 Unit1-L1-Kinematic Equations
Grade 12 Unit1-L1-Kinematic Equations
gruszecki1
 
Simple Pendulum MC Question
Simple Pendulum MC QuestionSimple Pendulum MC Question
Simple Pendulum MC Question
Michael Wu
 
Motion Graph & equations
Motion Graph & equationsMotion Graph & equations
Motion Graph & equations
Nurul Fadhilah
 
Grade 11, U1A-L1, Introduction to Kinematics
Grade 11, U1A-L1, Introduction to KinematicsGrade 11, U1A-L1, Introduction to Kinematics
Grade 11, U1A-L1, Introduction to Kinematics
gruszecki1
 
lecture 22
lecture 22lecture 22
lecture 22
sajinsc
 
Ppt on equations of motion by graphival method made by mudit gupta
Ppt on equations of motion by graphival method made by mudit guptaPpt on equations of motion by graphival method made by mudit gupta
Ppt on equations of motion by graphival method made by mudit gupta
MUDIT GUPTA
 
Motion L1
Motion L1Motion L1
Motion L1
Tom Cull
 
Kinematics displacement velocity graphs
Kinematics   displacement velocity graphsKinematics   displacement velocity graphs
Kinematics displacement velocity graphs
Mohammed Ahmed
 
Introductiontomotion
IntroductiontomotionIntroductiontomotion
Introductiontomotion
Conferat Conferat
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
Younes Sina
 
Lecture03
Lecture03Lecture03
Lecture03
oyunbileg06
 
Scalars and vectors
Scalars and vectorsScalars and vectors
Scalars and vectors
Mandisa Zwane
 
Grade 11, U1A-L5, Add/Sub Vectors in a Plane
Grade 11, U1A-L5, Add/Sub Vectors in a PlaneGrade 11, U1A-L5, Add/Sub Vectors in a Plane
Grade 11, U1A-L5, Add/Sub Vectors in a Plane
gruszecki1
 
Lecture01
Lecture01Lecture01
Lecture01
nomio0703
 
Grade 11, U1A-L2 Motion Graphs
Grade 11, U1A-L2 Motion GraphsGrade 11, U1A-L2 Motion Graphs
Grade 11, U1A-L2 Motion Graphs
gruszecki1
 
14210111030
1421011103014210111030
14210111030
JayRaj Gadhavi
 
Pwerhitungan struktur kabel listrick
Pwerhitungan struktur kabel listrick Pwerhitungan struktur kabel listrick
Pwerhitungan struktur kabel listrick
CARLES HUTABARAT
 
Grade 12 Unit1-L1-Kinematic Equations
Grade 12 Unit1-L1-Kinematic EquationsGrade 12 Unit1-L1-Kinematic Equations
Grade 12 Unit1-L1-Kinematic Equations
gruszecki1
 
Simple Pendulum MC Question
Simple Pendulum MC QuestionSimple Pendulum MC Question
Simple Pendulum MC Question
Michael Wu
 
Motion Graph & equations
Motion Graph & equationsMotion Graph & equations
Motion Graph & equations
Nurul Fadhilah
 
Grade 11, U1A-L1, Introduction to Kinematics
Grade 11, U1A-L1, Introduction to KinematicsGrade 11, U1A-L1, Introduction to Kinematics
Grade 11, U1A-L1, Introduction to Kinematics
gruszecki1
 
lecture 22
lecture 22lecture 22
lecture 22
sajinsc
 
Ppt on equations of motion by graphival method made by mudit gupta
Ppt on equations of motion by graphival method made by mudit guptaPpt on equations of motion by graphival method made by mudit gupta
Ppt on equations of motion by graphival method made by mudit gupta
MUDIT GUPTA
 
Kinematics displacement velocity graphs
Kinematics   displacement velocity graphsKinematics   displacement velocity graphs
Kinematics displacement velocity graphs
Mohammed Ahmed
 
Grade 11, U1A-L5, Add/Sub Vectors in a Plane
Grade 11, U1A-L5, Add/Sub Vectors in a PlaneGrade 11, U1A-L5, Add/Sub Vectors in a Plane
Grade 11, U1A-L5, Add/Sub Vectors in a Plane
gruszecki1
 
Grade 11, U1A-L2 Motion Graphs
Grade 11, U1A-L2 Motion GraphsGrade 11, U1A-L2 Motion Graphs
Grade 11, U1A-L2 Motion Graphs
gruszecki1
 

Similar to lecture 16 (20)

Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9
Traian Rebedea
 
Chapter 24 aoa
Chapter 24 aoaChapter 24 aoa
Chapter 24 aoa
Hanif Durad
 
lec6.pptx
lec6.pptxlec6.pptx
lec6.pptx
nuredinabdellah2
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
sachin varun
 
Graph algorithms
Graph algorithmsGraph algorithms
Graph algorithms
University of Haripur
 
test pre
test pretest pre
test pre
farazch
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
sahilpawar2426
 
Compactrouting
CompactroutingCompactrouting
Compactrouting
Meenakshi Tripathi
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
spanningtreesapplications-120903115339-phpapp02 (1).pdf
spanningtreesapplications-120903115339-phpapp02 (1).pdfspanningtreesapplications-120903115339-phpapp02 (1).pdf
spanningtreesapplications-120903115339-phpapp02 (1).pdf
YasirAli74993
 
chapter23.ppt
chapter23.pptchapter23.ppt
chapter23.ppt
Tareq Hasan
 
Greedy Approach in Design Analysis and Algorithms
Greedy Approach in Design Analysis and AlgorithmsGreedy Approach in Design Analysis and Algorithms
Greedy Approach in Design Analysis and Algorithms
NikunjGoyal20
 
19 Minimum Spanning Trees
19 Minimum Spanning Trees19 Minimum Spanning Trees
19 Minimum Spanning Trees
Andres Mendez-Vazquez
 
graph.ppt
graph.pptgraph.ppt
graph.ppt
RakeshPandey951330
 
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
Sahil Kumar
 
DIGITAL TEXT BOOK
DIGITAL TEXT BOOKDIGITAL TEXT BOOK
DIGITAL TEXT BOOK
shinyvarghese1991
 
Dijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.pptDijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.ppt
RAJASEKARAN G
 
Dijkstra algorithm ds 57612334t4t44.ppt
Dijkstra algorithm  ds 57612334t4t44.pptDijkstra algorithm  ds 57612334t4t44.ppt
Dijkstra algorithm ds 57612334t4t44.ppt
ssuser7b9bda1
 
Graph
GraphGraph
Graph
Daniel Rivera
 
Graph
GraphGraph
Graph
ssnetvnr
 
Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9
Traian Rebedea
 
minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
sachin varun
 
test pre
test pretest pre
test pre
farazch
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
sahilpawar2426
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
spanningtreesapplications-120903115339-phpapp02 (1).pdf
spanningtreesapplications-120903115339-phpapp02 (1).pdfspanningtreesapplications-120903115339-phpapp02 (1).pdf
spanningtreesapplications-120903115339-phpapp02 (1).pdf
YasirAli74993
 
Greedy Approach in Design Analysis and Algorithms
Greedy Approach in Design Analysis and AlgorithmsGreedy Approach in Design Analysis and Algorithms
Greedy Approach in Design Analysis and Algorithms
NikunjGoyal20
 
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
Sahil Kumar
 
Dijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.pptDijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.ppt
RAJASEKARAN G
 
Dijkstra algorithm ds 57612334t4t44.ppt
Dijkstra algorithm  ds 57612334t4t44.pptDijkstra algorithm  ds 57612334t4t44.ppt
Dijkstra algorithm ds 57612334t4t44.ppt
ssuser7b9bda1
 
Ad

More from sajinsc (20)

lecture 30
lecture 30lecture 30
lecture 30
sajinsc
 
lecture 29
lecture 29lecture 29
lecture 29
sajinsc
 
lecture 28
lecture 28lecture 28
lecture 28
sajinsc
 
lecture 27
lecture 27lecture 27
lecture 27
sajinsc
 
lecture 26
lecture 26lecture 26
lecture 26
sajinsc
 
lecture 25
lecture 25lecture 25
lecture 25
sajinsc
 
lecture 24
lecture 24lecture 24
lecture 24
sajinsc
 
lecture 23
lecture 23lecture 23
lecture 23
sajinsc
 
lecture 20
lecture 20lecture 20
lecture 20
sajinsc
 
lecture 19
lecture 19lecture 19
lecture 19
sajinsc
 
lecture 18
lecture 18lecture 18
lecture 18
sajinsc
 
lecture 17
lecture 17lecture 17
lecture 17
sajinsc
 
lecture 15
lecture 15lecture 15
lecture 15
sajinsc
 
lecture 14
lecture 14lecture 14
lecture 14
sajinsc
 
lecture 13
lecture 13lecture 13
lecture 13
sajinsc
 
lecture 12
lecture 12lecture 12
lecture 12
sajinsc
 
lecture 11
lecture 11lecture 11
lecture 11
sajinsc
 
lecture 10
lecture 10lecture 10
lecture 10
sajinsc
 
lecture 9
lecture 9lecture 9
lecture 9
sajinsc
 
lecture 8
lecture 8lecture 8
lecture 8
sajinsc
 
lecture 30
lecture 30lecture 30
lecture 30
sajinsc
 
lecture 29
lecture 29lecture 29
lecture 29
sajinsc
 
lecture 28
lecture 28lecture 28
lecture 28
sajinsc
 
lecture 27
lecture 27lecture 27
lecture 27
sajinsc
 
lecture 26
lecture 26lecture 26
lecture 26
sajinsc
 
lecture 25
lecture 25lecture 25
lecture 25
sajinsc
 
lecture 24
lecture 24lecture 24
lecture 24
sajinsc
 
lecture 23
lecture 23lecture 23
lecture 23
sajinsc
 
lecture 20
lecture 20lecture 20
lecture 20
sajinsc
 
lecture 19
lecture 19lecture 19
lecture 19
sajinsc
 
lecture 18
lecture 18lecture 18
lecture 18
sajinsc
 
lecture 17
lecture 17lecture 17
lecture 17
sajinsc
 
lecture 15
lecture 15lecture 15
lecture 15
sajinsc
 
lecture 14
lecture 14lecture 14
lecture 14
sajinsc
 
lecture 13
lecture 13lecture 13
lecture 13
sajinsc
 
lecture 12
lecture 12lecture 12
lecture 12
sajinsc
 
lecture 11
lecture 11lecture 11
lecture 11
sajinsc
 
lecture 10
lecture 10lecture 10
lecture 10
sajinsc
 
lecture 9
lecture 9lecture 9
lecture 9
sajinsc
 
lecture 8
lecture 8lecture 8
lecture 8
sajinsc
 
Ad

Recently uploaded (20)

Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 

lecture 16

  • 1. Lecture 12 Minimum Spanning Tree
  • 2. Motivating Example: Point to Multipoint Communication Single source, Multiple Destinations Broadcast All nodes in the network are destinations Multicast Some nodes in the network are destinations Only one copy of the information travels along common edges Message replication along forking points only. 1 2
  • 3. Spanning Tree We consider undirected graphs here. A tree is a connected graph without a cycle A spanning tree is a tree which has all vertices of the graph There may be multiple spanning trees We need to choose the minimum weight tree for broadcast.
  • 4. Blue edge spanning tree is the minimum weight spanning tree 5 4 4 5
  • 5. Properties of a Tree A tree of V vertices has V-1 edges There exists a unique path between any two vertices of a tree. Adding any edge to a tree creates a unique cycle. Breaking any edge on this cycle restores a tree.
  • 6. Minimum Spanning Tree Construction We maintain a set of edges A, which is initially empty. Edges are added to A one at a time such that finally A becomes a minimum spanning tree. Edges are never removed from A. So ``safe’’ edges must be added to A, i.e., at any stage A must be a part of a spanning tree.
  • 7. Safe Edge Addition Consider a cut in a graph (a cut consists of 2 sets which partition the vertex set). A cut respects a set of edges I if no edge in the set crosses the cut. A minimum weight edge crossing a cut is denoted a light weight edge in the cut {A,B,C} {D,E,F} constitute a cut. Let I = {edge AB, edge EF}.Cut {A,B,C}, {D,E,F} respects set I Edge CD is a light weight edge in the example cut. A B C D E F 2 1 3 1
  • 8. Let A be a subset of a MST (minimum weight spanning tree). Let (S, V – S) be any cut that respects A Let edge (u, v) be a light edge crossing the cut Then A  (u, v) is subset of a MST
  • 9. Assume that all the edge weights are distinct. Let no MST containing A contain edge (u, v). Add the edge (u, v) to T Consider a MST T containing A Since (u, v) is not in T, T  (u, v) contains a cycle, and (u, v) is in the cycle. Edge (u, v) are in the opposite sides of the cut. Since any cycle must cross the cut even number of times, there exists at least one other edge (x, y) crossing the cut. Clearly, w(x, y) > w(u, v).
  • 10. The edge (x, y) is not in A because (x, y) crosses the cut, and the cut respects A. Removing (x, y) from the cycle, breaks the cycle and hence creates a spanning tree, T’, s.t. T’ = T  (u, v) – (x, y) w(T’) = w(T) + w(u, v) – w(x, y)  w(T) (as w(u, v) < w(x, y)) This contradicts the fact that T is a MST.
  • 11. So we always find a cut that respects A, And add a light edge across the cut to A. Kruskals and Prims algorithms find the cut differently.
  • 12. Kruskals Algorithm A =  For each vertex u in V, Create_Set(u) Sort E in increasing order by weight w For each edge (u,v) in the sorted list If Set(u)  = Set(v) Add (u,v) to A Union Set(u) and Set(v) Return A;
  • 13. Complexity Analysis The operations create set, testing whether set(u) == set(v), union operations can be done in log V operations, using Union find data structure. Step 1 can be done in Vlog V Step 2 can be done in Elog E Step 3 can be done in Elog V Overall complexity is O(Vlog V + Elog E + Elog V) or O((V + E)log V)
  • 14. 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7 5 1 0 2 2 8 5 7
  • 15. Prims Algorithm Maintains a set of vertices S already in the spanning tree. Initially, S consists of one vertex r, selected arbitrarily. For every vertex u in V – S, maintain the weight of the lightest edge between u and any vertex in S. If there is no edge between u and S, then this weight associated with u is infinity.
  • 16. Add the vertex with the least weight to S. This is in effect adding the light weight edge crossing the cut S and V-S. Whenever a vertex is added to S, the weights of all its neighbors are reduced, if necessary.
  • 17. Pseudo-Code For each u in V, key[u] =  S =  Pred[r] = NULL Key[r] = 0 While V  = S u = Extract_Min(V-S) For each (v in Adj(u)) if (v not in S) key(v) = min(w(u, v), key(v)) and pred(v) = u Add u in S
  • 18. For each v in Adj[u]…. can be done in E complexity Rest of the loop can be done in V 2 complexity So, overall O(V 2 ) Using heaps we can solve in O((V + E)logV)
  • 19. Example 0 s 7 5 7 2 1 8 5 3 2 5 3 1 s 0 2 8 5 7 2 8 5 s 0 7 3 1 5 2 3 5 8 0 3 2 5 s 7 2 1 8 5 5 3 1 8 5 s 0 7 2 3 1 5 2 3 5 1 3 8 5 s 0 7 2 1 5 2 3 5 1