SlideShare a Scribd company logo
1 of 16
MINIMUM SPANNING TREE , PRISM
AND KRUSKAL’S ALGORITHM
A.Sangeetha
M.Sc(infoTech)
DEPARTMENTOFCS&IT
NADAR SARASWATHICOLLEGEOFARTS
AND SCIENCE
 A minimum spanning tree (MST) or minimum weight
spanning tree is then a spanning tree with weight less than or
equal to the weight of every other spanning tree.
More generally, any undirected graph (not necessarily
connected) has a minimum spanning forest, which is a union
of minimum spanning trees for its connected components.
A spanning tree for that graph would be a subset of those
paths that has no cycles but still connects to every house.
There might be several spanning trees possible.
MINIMUM SPANNING TREE
A spanning tree is a subset of Graph G, which
has all the vertices covered with minimum
possible number of edges.
A spanning tree does not have cycles and it
cannot be disconnected.
We can draw a conclusion that every connected
and undirected graph G has at least one
spanning tree.
DEFINITON:
A disconnected graph does not have any spanning tree,
as it cannot be spanned to all its vertices.
A
BC
 We found three spanning trees off one complete
graph. A complete undirected graph can have
maximum nn-2 number of spanning trees, where n is
the number of nodes.
SPANNING TREE
A
BC
A
BC
A
BC
 Kruskal’s Algorithm: Add edges in increasing
weight, skipping those whose addition would
create a cycle.
 Theorem. Kruskal’s algorithm produces a
minimum spanning tree.
 Proof. Consider the point when edge e = (u, v)
is added:
Kruskal’s algorithm:
 Kruskal's algorithm to find the minimum
cost spanning tree uses the greedy
approach.
 This algorithm treats the graph as a forest
and every node it has as an individual tree.
 A tree connects to another only and only if,
it has the least cost among all available
options and does not violate MST
properties.
 To understand Kruskal's algorithm let us consider
the following example −
 Step 1 - Remove all loops and Parallel Edges
 Remove all loops and parallel edges from the given graph.
 In case of parallel edges, keep the one which has the least
cost associated and remove all others.
 Step 2 - Arrange all edges in their increasing order of
weight
 The next step is to create a set of edges and weight, and
arrange them in an ascending order of weightage (cost).
 Step 3 - Add the edge which has the least weightage
 Now we start adding edges to the graph beginning from
the one which has the least weight. Throughout, we shall
keep checking that the spanning properties remain intact.
In case, by adding one edge, the spanning tree property
does not hold then we shall consider not to include the edge
in the graph.
 The least cost is 2 and edges involved are B,D and D,T.
We add them. Adding them does not violate spanning tree
properties, so we continue to our next edge selection.
 Next cost is 3, and associated edges are A,C and C,D. We
add them again
 Next cost in the table is 4, and we observe that adding it
will create a circuit in the graph. −

 We ignore it. In the process we shall ignore/avoid all edges
that create a circuit.
 We observe that edges with cost 5 and 6 also create
circuits. We ignore them and move on.

 Now we are left with only one node to be added.
Between the two least cost edges available 7 and 8, we
shall add the edge with cost 7.
 By adding edge S,A we have included all the nodes of
the graph and we now have minimum cost spanning
tree.

More Related Content

What's hot

Lengths
LengthsLengths
LengthsLiAb96
 
Ramos, alexis t. regression
Ramos, alexis t.   regressionRamos, alexis t.   regression
Ramos, alexis t. regressionElaMeow
 
8.1 angles 2
8.1 angles 28.1 angles 2
8.1 angles 2bweldon
 
Engineering Mechanice Lecture 04
Engineering Mechanice Lecture 04Engineering Mechanice Lecture 04
Engineering Mechanice Lecture 04Self-employed
 
Codeforces round #310 Div.1 E. Case of Computer Network
Codeforces round #310 Div.1 E. Case of Computer NetworkCodeforces round #310 Div.1 E. Case of Computer Network
Codeforces round #310 Div.1 E. Case of Computer Networkminsu kim
 
Approximations in drawing π and squaring the circle
Approximations in drawing π and squaring the circleApproximations in drawing π and squaring the circle
Approximations in drawing π and squaring the circleChris De Corte
 
eliodinsulenapier
eliodinsulenapiereliodinsulenapier
eliodinsulenapierElias Dinsa
 
Linear graph[1]edit
Linear graph[1]editLinear graph[1]edit
Linear graph[1]editsmarshall9
 
Right angle theorem
Right angle theoremRight angle theorem
Right angle theoremJeremy
 
divide and conquer algorithms
divide and conquer algorithmsdivide and conquer algorithms
divide and conquer algorithmsSanjeev Goyal
 
Greatest and smallest value 1 copy
Greatest and smallest value 1   copyGreatest and smallest value 1   copy
Greatest and smallest value 1 copyshaminakhan
 
11.4 power point
11.4 power point11.4 power point
11.4 power pointAnnie cox
 
linear equation and gaussian elimination
linear equation and gaussian eliminationlinear equation and gaussian elimination
linear equation and gaussian eliminationAju Thadikulangara
 
Math for Physics Cheat sheet
Math for Physics Cheat sheetMath for Physics Cheat sheet
Math for Physics Cheat sheetTimothy Welsh
 
Laws of exponents
Laws of exponentsLaws of exponents
Laws of exponentsPranshul123
 
Section 1.6 – Solving Linear Inequalities A
Section 1.6 – Solving Linear Inequalities ASection 1.6 – Solving Linear Inequalities A
Section 1.6 – Solving Linear Inequalities ACarol Dobson
 

What's hot (20)

Lengths
LengthsLengths
Lengths
 
Calculus Ppt
Calculus PptCalculus Ppt
Calculus Ppt
 
Ramos, alexis t. regression
Ramos, alexis t.   regressionRamos, alexis t.   regression
Ramos, alexis t. regression
 
Sol9
Sol9Sol9
Sol9
 
8.1 angles 2
8.1 angles 28.1 angles 2
8.1 angles 2
 
Sol24
Sol24Sol24
Sol24
 
Engineering Mechanice Lecture 04
Engineering Mechanice Lecture 04Engineering Mechanice Lecture 04
Engineering Mechanice Lecture 04
 
Codeforces round #310 Div.1 E. Case of Computer Network
Codeforces round #310 Div.1 E. Case of Computer NetworkCodeforces round #310 Div.1 E. Case of Computer Network
Codeforces round #310 Div.1 E. Case of Computer Network
 
Approximations in drawing π and squaring the circle
Approximations in drawing π and squaring the circleApproximations in drawing π and squaring the circle
Approximations in drawing π and squaring the circle
 
eliodinsulenapier
eliodinsulenapiereliodinsulenapier
eliodinsulenapier
 
Linear graph[1]edit
Linear graph[1]editLinear graph[1]edit
Linear graph[1]edit
 
Right angle theorem
Right angle theoremRight angle theorem
Right angle theorem
 
divide and conquer algorithms
divide and conquer algorithmsdivide and conquer algorithms
divide and conquer algorithms
 
Greatest and smallest value 1 copy
Greatest and smallest value 1   copyGreatest and smallest value 1   copy
Greatest and smallest value 1 copy
 
11.4 power point
11.4 power point11.4 power point
11.4 power point
 
linear equation and gaussian elimination
linear equation and gaussian eliminationlinear equation and gaussian elimination
linear equation and gaussian elimination
 
Math for Physics Cheat sheet
Math for Physics Cheat sheetMath for Physics Cheat sheet
Math for Physics Cheat sheet
 
Presntation11
Presntation11Presntation11
Presntation11
 
Laws of exponents
Laws of exponentsLaws of exponents
Laws of exponents
 
Section 1.6 – Solving Linear Inequalities A
Section 1.6 – Solving Linear Inequalities ASection 1.6 – Solving Linear Inequalities A
Section 1.6 – Solving Linear Inequalities A
 

Similar to Data structure

Similar to Data structure (20)

Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
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 in data structures
Graph in data structuresGraph in data structures
Graph in data structures
 
Weighted graphs
Weighted graphsWeighted graphs
Weighted graphs
 
Graph clustering
Graph clusteringGraph clustering
Graph clustering
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
Unit3_1.pdf
Unit3_1.pdfUnit3_1.pdf
Unit3_1.pdf
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
8_MST_pptx.pptx
8_MST_pptx.pptx8_MST_pptx.pptx
8_MST_pptx.pptx
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
 
1 sollins algorithm
1 sollins algorithm1 sollins algorithm
1 sollins algorithm
 
Data structure note
Data structure noteData structure note
Data structure note
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
KRUSKALS'S algorithm from chaitra
KRUSKALS'S algorithm from chaitraKRUSKALS'S algorithm from chaitra
KRUSKALS'S algorithm from chaitra
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Unit V - ppt.pptx
 
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
 
A study on connectivity in graph theory june 18 pdf
A study on connectivity in graph theory  june 18 pdfA study on connectivity in graph theory  june 18 pdf
A study on connectivity in graph theory june 18 pdf
 

More from SangeethaSasi1 (20)

L4 multiplexing & multiple access 16
L4 multiplexing & multiple access 16L4 multiplexing & multiple access 16
L4 multiplexing & multiple access 16
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Mc ppt
Mc pptMc ppt
Mc ppt
 
Mc ppt
Mc pptMc ppt
Mc ppt
 
Dip pppt
Dip ppptDip pppt
Dip pppt
 
Web techh
Web techhWeb techh
Web techh
 
Web tech
Web techWeb tech
Web tech
 
Vani wt
Vani wtVani wt
Vani wt
 
Vani dbms
Vani dbmsVani dbms
Vani dbms
 
Hema wt (1)
Hema wt (1)Hema wt (1)
Hema wt (1)
 
Hema rdbms
Hema rdbmsHema rdbms
Hema rdbms
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
Dbms
DbmsDbms
Dbms
 
Vani
VaniVani
Vani
 
Hema se
Hema seHema se
Hema se
 
Software
SoftwareSoftware
Software
 
Operating system
Operating systemOperating system
Operating system
 
Dataminng
DataminngDataminng
Dataminng
 
System calls
System callsSystem calls
System calls
 

Recently uploaded

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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
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
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Data structure

  • 1. MINIMUM SPANNING TREE , PRISM AND KRUSKAL’S ALGORITHM A.Sangeetha M.Sc(infoTech) DEPARTMENTOFCS&IT NADAR SARASWATHICOLLEGEOFARTS AND SCIENCE
  • 2.  A minimum spanning tree (MST) or minimum weight spanning tree is then a spanning tree with weight less than or equal to the weight of every other spanning tree. More generally, any undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of minimum spanning trees for its connected components. A spanning tree for that graph would be a subset of those paths that has no cycles but still connects to every house. There might be several spanning trees possible. MINIMUM SPANNING TREE
  • 3. A spanning tree is a subset of Graph G, which has all the vertices covered with minimum possible number of edges. A spanning tree does not have cycles and it cannot be disconnected. We can draw a conclusion that every connected and undirected graph G has at least one spanning tree. DEFINITON:
  • 4. A disconnected graph does not have any spanning tree, as it cannot be spanned to all its vertices. A BC
  • 5.  We found three spanning trees off one complete graph. A complete undirected graph can have maximum nn-2 number of spanning trees, where n is the number of nodes. SPANNING TREE A BC A BC A BC
  • 6.  Kruskal’s Algorithm: Add edges in increasing weight, skipping those whose addition would create a cycle.  Theorem. Kruskal’s algorithm produces a minimum spanning tree.  Proof. Consider the point when edge e = (u, v) is added: Kruskal’s algorithm:
  • 7.  Kruskal's algorithm to find the minimum cost spanning tree uses the greedy approach.  This algorithm treats the graph as a forest and every node it has as an individual tree.  A tree connects to another only and only if, it has the least cost among all available options and does not violate MST properties.
  • 8.  To understand Kruskal's algorithm let us consider the following example −
  • 9.  Step 1 - Remove all loops and Parallel Edges  Remove all loops and parallel edges from the given graph.  In case of parallel edges, keep the one which has the least cost associated and remove all others.
  • 10.  Step 2 - Arrange all edges in their increasing order of weight  The next step is to create a set of edges and weight, and arrange them in an ascending order of weightage (cost).
  • 11.  Step 3 - Add the edge which has the least weightage  Now we start adding edges to the graph beginning from the one which has the least weight. Throughout, we shall keep checking that the spanning properties remain intact. In case, by adding one edge, the spanning tree property does not hold then we shall consider not to include the edge in the graph.
  • 12.  The least cost is 2 and edges involved are B,D and D,T. We add them. Adding them does not violate spanning tree properties, so we continue to our next edge selection.  Next cost is 3, and associated edges are A,C and C,D. We add them again
  • 13.  Next cost in the table is 4, and we observe that adding it will create a circuit in the graph. − 
  • 14.  We ignore it. In the process we shall ignore/avoid all edges that create a circuit.
  • 15.  We observe that edges with cost 5 and 6 also create circuits. We ignore them and move on. 
  • 16.  Now we are left with only one node to be added. Between the two least cost edges available 7 and 8, we shall add the edge with cost 7.  By adding edge S,A we have included all the nodes of the graph and we now have minimum cost spanning tree.