SlideShare une entreprise Scribd logo
1  sur  77
By
Mohammad Shahriar Reza
ID : 011132065
A spanning tree of a graph is just a sub graph that contains all the vertices and is a
tree.
A graph may have many spanning trees.
or or or
Some Spanning Trees from Graph AGraph A
All 16 of its Spanning TreesComplete Graph
The Minimum Spanning Tree for a given graph is the Spanning Tree of minimum
weight for that graph.
5
7
2
1
3
4
2
1
3
Complete Graph Minimum Spanning Tree
Kruskal's Algorithm
Prim's Algorithm
Boruvka's Algorithm
• The forest is constructed - with each node in a separate tree.
• The edges are placed in a priority queue.
• Until we've added n-1 edges
Extract the cheapest edge from the queue;
If it forms a cycle, reject it;
Else add it to the forest. Adding it to the forest will join two trees
together.
Every step will have joined two trees in the forest together, so that at the end,
there will only be one tree.
4
1
2 3
2
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Complete Graph
1
4
2
5
2
5
4
3
4
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
A AB D
B B
B
C D
J C
C
E
F
D
D H
J E G
F FG I
G GI J
H J JI
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Sort Edges
(in reality they are placed in a priority
queue - not sorted - but sorting them
makes the algorithm easier to visualize)
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Cycle
Don’t Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Cycle
Don’t Add Edge
2
5
2
5
4
3
4
4
10
1
6
3
3
2
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
B
B
D
J
C
C
E
F
D
D H
J
E G
F
F
G
I
G
G
I
J
H J
JI
1A D
4B C
4A B
Add Edge
4
1
2
2 1
3
32
4
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Minimum Spanning Tree Complete Graph
Pseudo code
KRUSKAL(V, E, w)
{
A = ∅
For each v ∈ G.V
MAKE-SET(v)
sort E into non-decreasing order by w
For each (u, v) ∈ G.E taken from the sorted list
If FIND-SET(u) ≠ FIND-SET(v):
A = A ∪ {(u, v)}
UNION(u, v)
return A
}
Pseudo code Time Complexity
KRUSKAL(V, E, w)
{
A = ∅----------------------------------------------------------------O(1)
For each v ∈ G.V--------------------------------------------------O(V)
MAKE-SET(v)
sort E into non-decreasing order by w----------------------O(E lg E)
For each (u, v) ∈ G.E taken from the sorted list-----------O(E)
If FIND-SET(u) ≠ FIND-SET(v):
A = A ∪ {(u, v)}
UNION(u, v)
return A
}
T = O(1) + 0(V) +
O(E lg E) + O(E)
As
O(V) < O(E) <
O(E lg E)
T = O(E lg E)
• The new graph is constructed - with one node from the old graph.
• While new graph has fewer than n nodes
Find the node from the old graph with the smallest connecting edge to the
new graph;
Add it to the new graph.
Every step will have joined one node, so that at the end we will have one graph
with all the nodes and it will be a minimum spanning tree of the original graph.
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Complete Graph
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
1
2
2 1
3
32
4
A
B C
D
E F
G
H
I
J
Complete Graph Minimum Spanning Tree
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Pseudo code
PRIM(V, E, w, r )
Q = { }
for each u in V
key[u] = ∞
π[u] = NIL
INSERT(Q, u)
DECREASE-KEY(Q, r, 0)
while Q is not empty
u = EXTRACT-MIN(Q)
for each v in Adj[u]
if v in Q and w(u, v) < key[v]
π[v] = u
DECREASE-KEY(Q, v, w(u, v))
Pseudo code Time Complexity
PRIM(V, E, w, r )
Q = { }
for each u in V-----------------------------------------O(V lg V)
key[u] = ∞
π[u] = NIL
INSERT(Q, u)
DECREASE-KEY(Q, r, 0)------------------------------O(lg V)
while Q is not empty--------------------------------O(E lg V)
u = EXTRACT-MIN(Q)
for each v in Adj[u]----------------------------O(E)
if v in Q and w(u, v) < key[v]
π[v] = u
DECREASE-KEY(Q, v, w(u, v))-------O(lg V)
T = 0(V lg V)+
O(lg V)+O(E lg V)
As
O(lg V) < O(V lg
V) < O(E lg V)
T = O(E lg V)
• Make a list of n trees, each containing a single node.
• While list has more than one tree
For each tree in the list, find the node not connected to the
tree with the smallest connecting edge to that tree
Add all the edges found to the new graph, thus creating a
new set of trees
Every step will have joined groups of trees, until only one tree remains.
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Complete Graph
• A
• B
• C
• D
• E
• F
• G
• H
• I
• J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Trees of the Graph at Beginning
of Round 1
List of Trees
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
1
4
A
B
D
Tree A
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
1
4
A
B
D
Edge A-D
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
4
4
10
A
B C
D
J
Round 1 Tree B
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
4
4
4
10
A
B C
D
J
Round 1 Edge B-A
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
4
2 1
B C
E F
Tree C
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
4
2 1
B C
E F
Edge C-F
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
1
5 6
4A
B
D
H
J
Tree D
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
1
5 6
4A
B
D
H
J
Edge D-A
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2
2
C
E
G
Tree E
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2
2
C
E
G
Edge E-C
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
1
5
C
F
G
I
Tree F
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
1
5
C
F
G
I
Edge F-C
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2 3
3
4
E F
G
I
J
Tree G
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2 3
3
4
E F
G
I
J
Edge G-E
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2
5
D
H
J
Tree H
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
2
5
D
H
J
Edge H-J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
5
3
F
G
I
J
Tree I
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
5
3
F
G
I
J
Edge I-G
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
4
2
6
10
B
D
G
H
I
J
Tree J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1
3
4
2
6
10
B
D
G
H
I
J
Edge J-H
• A-D
• B-A
• C-F
• D-A
• E-C
• F-C
• G-E
• H-J
• I-G
• J-H
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 1 Ends -
Add Edges
List of Edges to
Add
• D-A-B
• F-C-E-G-I
• H-J
List of Trees
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Trees of the Graph at Beginning
of Round 2
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2
4
1
2
2 1
3
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Tree D-A-B
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2
4
1
2
2 1
3
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Edge B-C
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2 Tree F-C-E-G-I
4
1
2 3
2 1
3
5
3
4
2
4
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2 Edge I-J
4
1
2 3
2 1
3
5
3
4
2
4
A
B C
D
E F
G
H
I
J
1
2
2 1
3
3
4
2
5 6
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2 Tree H-J
1
2
2 1
3
3
4
2
5 6
4
10
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Round 2 Edge J-I
• B-C
• I-J
• J-I
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
List of Edges to
Add
Round 2 Ends -
Add Edges
4
1
2
2 1
3
32
4
A
B C
D
E F
G
H
I
J
4
1
2 3
2 1
3
5
3
4
2
5 6
4
4
10
A
B C
D
E F
G
H
I
J
Minimum Spanning Tree Complete Graph
Pseudo code Time Complexity
Input: A connected graph G whose edges have distinct weights
Initialize a forest T to be a set of one-vertex trees, one for each
vertex of the graph
While T has more than one component
For each component C of T
Begin with an empty set of edges S
For each vertex v in C
Find the cheapest edge from v to a vertex outside of C
and add it to S
Add the cheapest edge in S to T
Output: T is the minimum spanning tree of G.
If the edges are E
& vertices are V
then
T = O( E lg V )
Kruskal’s and Boruvka’s have better running times if the
number of edges is low, while Prim’s has a better running time
if both the number of edges and the number of nodes are low.
Boruvka’s avoids the complicated data structures needed for
the other two algorithms.
So, of course, the best algorithm depends on the graph and if
we want to bear the cost of complex data structures.
MST_GRAPH

Contenu connexe

En vedette

Indran's Stand Out Roles - Connector & Teacher
Indran's Stand Out Roles - Connector & TeacherIndran's Stand Out Roles - Connector & Teacher
Indran's Stand Out Roles - Connector & TeacherIndran Purushothaman
 
Tema 8. brígida rodríguez palacios
Tema 8. brígida rodríguez palaciosTema 8. brígida rodríguez palacios
Tema 8. brígida rodríguez palaciosbrigida
 
Ship ps4 h - cdc 1422 may 2015
Ship   ps4 h - cdc 1422 may 2015Ship   ps4 h - cdc 1422 may 2015
Ship ps4 h - cdc 1422 may 2015jbergstrand
 
Journalism Trends 2016 - Key findings for communicators
Journalism Trends 2016 - Key findings for communicatorsJournalism Trends 2016 - Key findings for communicators
Journalism Trends 2016 - Key findings for communicatorsMynewsdesk (Asia)
 
Marxist perspectives on print media
Marxist perspectives on print mediaMarxist perspectives on print media
Marxist perspectives on print mediaHGAED
 
Estructura de la sesión de tutoría.
Estructura  de la sesión de tutoría.Estructura  de la sesión de tutoría.
Estructura de la sesión de tutoría.Marly Rodriguez
 

En vedette (9)

Brasil
BrasilBrasil
Brasil
 
Indran's Stand Out Roles - Connector & Teacher
Indran's Stand Out Roles - Connector & TeacherIndran's Stand Out Roles - Connector & Teacher
Indran's Stand Out Roles - Connector & Teacher
 
Tema 8. brígida rodríguez palacios
Tema 8. brígida rodríguez palaciosTema 8. brígida rodríguez palacios
Tema 8. brígida rodríguez palacios
 
Ship ps4 h - cdc 1422 may 2015
Ship   ps4 h - cdc 1422 may 2015Ship   ps4 h - cdc 1422 may 2015
Ship ps4 h - cdc 1422 may 2015
 
Presentation on bcd adder
Presentation on bcd adderPresentation on bcd adder
Presentation on bcd adder
 
Journalism Trends 2016 - Key findings for communicators
Journalism Trends 2016 - Key findings for communicatorsJournalism Trends 2016 - Key findings for communicators
Journalism Trends 2016 - Key findings for communicators
 
Marxist perspectives on print media
Marxist perspectives on print mediaMarxist perspectives on print media
Marxist perspectives on print media
 
Estructura de la sesión de tutoría.
Estructura  de la sesión de tutoría.Estructura  de la sesión de tutoría.
Estructura de la sesión de tutoría.
 
Norsk
NorskNorsk
Norsk
 

Similaire à MST_GRAPH

Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning treeskalyanineve
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmGaurav Kolekar
 
Remote control of electrical equipment(eee499.blogspot.com)
Remote control of electrical equipment(eee499.blogspot.com)Remote control of electrical equipment(eee499.blogspot.com)
Remote control of electrical equipment(eee499.blogspot.com)slmnsvn
 
A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois FieldHazratali Naim
 
prims and Kruskal 1.pdf
prims and Kruskal 1.pdfprims and Kruskal 1.pdf
prims and Kruskal 1.pdfDEEPAK948083
 
Complete binary tree and heap
Complete binary tree and heapComplete binary tree and heap
Complete binary tree and heapNazir Ahmed
 
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdf
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdfnewmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdf
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdfBiswajitPalei2
 
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料VirtualTech Japan Inc.
 
Chim vanh khuyen
Chim vanh khuyenChim vanh khuyen
Chim vanh khuyenSEAMI
 
Safe Reinforcement Learning
Safe Reinforcement LearningSafe Reinforcement Learning
Safe Reinforcement LearningDongmin Lee
 
Tournament fixing
Tournament fixingTournament fixing
Tournament fixingmsramanujan
 
Ciclotron dynamic 12000 h 2ω
Ciclotron   dynamic 12000 h 2ωCiclotron   dynamic 12000 h 2ω
Ciclotron dynamic 12000 h 2ωMuniz Rodrigues
 
Debugging Your CDN - Austin Spires at Fastly Altitude 2015
Debugging Your CDN - Austin Spires at Fastly Altitude 2015Debugging Your CDN - Austin Spires at Fastly Altitude 2015
Debugging Your CDN - Austin Spires at Fastly Altitude 2015Fastly
 
Modul linus numerasi tahun 3
Modul linus numerasi tahun 3Modul linus numerasi tahun 3
Modul linus numerasi tahun 3Habibah Yusoff
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmAcad
 
Cómo abrir archivos .HLP WinHelp en Windows 10.pdf
Cómo abrir archivos .HLP WinHelp en Windows 10.pdfCómo abrir archivos .HLP WinHelp en Windows 10.pdf
Cómo abrir archivos .HLP WinHelp en Windows 10.pdfManuelAndrino2
 

Similaire à MST_GRAPH (20)

Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning trees
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
MST2.ppt
MST2.pptMST2.ppt
MST2.ppt
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
Remote control of electrical equipment(eee499.blogspot.com)
Remote control of electrical equipment(eee499.blogspot.com)Remote control of electrical equipment(eee499.blogspot.com)
Remote control of electrical equipment(eee499.blogspot.com)
 
A Short Study of Galois Field
A Short Study of Galois FieldA Short Study of Galois Field
A Short Study of Galois Field
 
prims and Kruskal 1.pdf
prims and Kruskal 1.pdfprims and Kruskal 1.pdf
prims and Kruskal 1.pdf
 
Complete binary tree and heap
Complete binary tree and heapComplete binary tree and heap
Complete binary tree and heap
 
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdf
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdfnewmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdf
newmicrosoftofficepowerpointpresentation-150826055944-lva1-app6891.pdf
 
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料
OpenStack Summit & KubeConからみるコンテナ技術の最新トレンド (更新版) - OpenStack Day Tokyo 2018講演資料
 
Chim vanh khuyen
Chim vanh khuyenChim vanh khuyen
Chim vanh khuyen
 
Safe Reinforcement Learning
Safe Reinforcement LearningSafe Reinforcement Learning
Safe Reinforcement Learning
 
Cocktail namta sudtai
Cocktail namta sudtaiCocktail namta sudtai
Cocktail namta sudtai
 
Tournament fixing
Tournament fixingTournament fixing
Tournament fixing
 
Ciclotron dynamic 12000 h 2ω
Ciclotron   dynamic 12000 h 2ωCiclotron   dynamic 12000 h 2ω
Ciclotron dynamic 12000 h 2ω
 
SAT Practice Tests
SAT Practice TestsSAT Practice Tests
SAT Practice Tests
 
Debugging Your CDN - Austin Spires at Fastly Altitude 2015
Debugging Your CDN - Austin Spires at Fastly Altitude 2015Debugging Your CDN - Austin Spires at Fastly Altitude 2015
Debugging Your CDN - Austin Spires at Fastly Altitude 2015
 
Modul linus numerasi tahun 3
Modul linus numerasi tahun 3Modul linus numerasi tahun 3
Modul linus numerasi tahun 3
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
 
Cómo abrir archivos .HLP WinHelp en Windows 10.pdf
Cómo abrir archivos .HLP WinHelp en Windows 10.pdfCómo abrir archivos .HLP WinHelp en Windows 10.pdf
Cómo abrir archivos .HLP WinHelp en Windows 10.pdf
 

Plus de United International University (9)

Parking allocation system
Parking allocation systemParking allocation system
Parking allocation system
 
Portable Banking System
Portable Banking SystemPortable Banking System
Portable Banking System
 
Bus Travelling Community
Bus Travelling CommunityBus Travelling Community
Bus Travelling Community
 
Project management tools
Project management toolsProject management tools
Project management tools
 
Jit compilation
Jit compilationJit compilation
Jit compilation
 
Flashback 2K14
Flashback 2K14Flashback 2K14
Flashback 2K14
 
Battle in the city
Battle in the cityBattle in the city
Battle in the city
 
Arduino Automated Parking Lot System
Arduino Automated Parking Lot SystemArduino Automated Parking Lot System
Arduino Automated Parking Lot System
 
MST
MSTMST
MST
 

Dernier

Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一F sss
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一F La
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...ttt fff
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 

Dernier (20)

Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 

MST_GRAPH

  • 2. A spanning tree of a graph is just a sub graph that contains all the vertices and is a tree. A graph may have many spanning trees. or or or Some Spanning Trees from Graph AGraph A
  • 3. All 16 of its Spanning TreesComplete Graph
  • 4. The Minimum Spanning Tree for a given graph is the Spanning Tree of minimum weight for that graph. 5 7 2 1 3 4 2 1 3 Complete Graph Minimum Spanning Tree
  • 6.
  • 7. • The forest is constructed - with each node in a separate tree. • The edges are placed in a priority queue. • Until we've added n-1 edges Extract the cheapest edge from the queue; If it forms a cycle, reject it; Else add it to the forest. Adding it to the forest will join two trees together. Every step will have joined two trees in the forest together, so that at the end, there will only be one tree.
  • 8. 4 1 2 3 2 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Complete Graph
  • 9. 1 4 2 5 2 5 4 3 4 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J A AB D B B B C D J C C E F D D H J E G F FG I G GI J H J JI
  • 10. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Sort Edges (in reality they are placed in a priority queue - not sorted - but sorting them makes the algorithm easier to visualize)
  • 11. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 12. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 13. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 14. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 15. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 16. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Cycle Don’t Add Edge
  • 17. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 18. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 19. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 20. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Cycle Don’t Add Edge
  • 21. 2 5 2 5 4 3 4 4 10 1 6 3 3 2 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J B B D J C C E F D D H J E G F F G I G G I J H J JI 1A D 4B C 4A B Add Edge
  • 22. 4 1 2 2 1 3 32 4 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Minimum Spanning Tree Complete Graph
  • 23. Pseudo code KRUSKAL(V, E, w) { A = ∅ For each v ∈ G.V MAKE-SET(v) sort E into non-decreasing order by w For each (u, v) ∈ G.E taken from the sorted list If FIND-SET(u) ≠ FIND-SET(v): A = A ∪ {(u, v)} UNION(u, v) return A }
  • 24. Pseudo code Time Complexity KRUSKAL(V, E, w) { A = ∅----------------------------------------------------------------O(1) For each v ∈ G.V--------------------------------------------------O(V) MAKE-SET(v) sort E into non-decreasing order by w----------------------O(E lg E) For each (u, v) ∈ G.E taken from the sorted list-----------O(E) If FIND-SET(u) ≠ FIND-SET(v): A = A ∪ {(u, v)} UNION(u, v) return A } T = O(1) + 0(V) + O(E lg E) + O(E) As O(V) < O(E) < O(E lg E) T = O(E lg E)
  • 25.
  • 26. • The new graph is constructed - with one node from the old graph. • While new graph has fewer than n nodes Find the node from the old graph with the smallest connecting edge to the new graph; Add it to the new graph. Every step will have joined one node, so that at the end we will have one graph with all the nodes and it will be a minimum spanning tree of the original graph.
  • 27. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Complete Graph
  • 28. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 29. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 30. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 31. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 32. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 33. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 34. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 35. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 36. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 37. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 38. 4 1 2 2 1 3 32 4 A B C D E F G H I J Complete Graph Minimum Spanning Tree 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J
  • 39. Pseudo code PRIM(V, E, w, r ) Q = { } for each u in V key[u] = ∞ π[u] = NIL INSERT(Q, u) DECREASE-KEY(Q, r, 0) while Q is not empty u = EXTRACT-MIN(Q) for each v in Adj[u] if v in Q and w(u, v) < key[v] π[v] = u DECREASE-KEY(Q, v, w(u, v))
  • 40. Pseudo code Time Complexity PRIM(V, E, w, r ) Q = { } for each u in V-----------------------------------------O(V lg V) key[u] = ∞ π[u] = NIL INSERT(Q, u) DECREASE-KEY(Q, r, 0)------------------------------O(lg V) while Q is not empty--------------------------------O(E lg V) u = EXTRACT-MIN(Q) for each v in Adj[u]----------------------------O(E) if v in Q and w(u, v) < key[v] π[v] = u DECREASE-KEY(Q, v, w(u, v))-------O(lg V) T = 0(V lg V)+ O(lg V)+O(E lg V) As O(lg V) < O(V lg V) < O(E lg V) T = O(E lg V)
  • 41.
  • 42. • Make a list of n trees, each containing a single node. • While list has more than one tree For each tree in the list, find the node not connected to the tree with the smallest connecting edge to that tree Add all the edges found to the new graph, thus creating a new set of trees Every step will have joined groups of trees, until only one tree remains.
  • 43. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Complete Graph
  • 44. • A • B • C • D • E • F • G • H • I • J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Trees of the Graph at Beginning of Round 1 List of Trees
  • 45. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 1 4 A B D Tree A
  • 46. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 1 4 A B D Edge A-D
  • 47. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 4 4 10 A B C D J Round 1 Tree B
  • 48. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J 4 4 4 10 A B C D J Round 1 Edge B-A
  • 49. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 4 2 1 B C E F Tree C
  • 50. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 4 2 1 B C E F Edge C-F
  • 51. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 1 5 6 4A B D H J Tree D
  • 52. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 1 5 6 4A B D H J Edge D-A
  • 53. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 2 C E G Tree E
  • 54. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 2 C E G Edge E-C
  • 55. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 1 5 C F G I Tree F
  • 56. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 1 5 C F G I Edge F-C
  • 57. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 3 3 4 E F G I J Tree G
  • 58. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 3 3 4 E F G I J Edge G-E
  • 59. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 5 D H J Tree H
  • 60. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 2 5 D H J Edge H-J
  • 61. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 5 3 F G I J Tree I
  • 62. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 5 3 F G I J Edge I-G
  • 63. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 4 2 6 10 B D G H I J Tree J
  • 64. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 3 4 2 6 10 B D G H I J Edge J-H
  • 65. • A-D • B-A • C-F • D-A • E-C • F-C • G-E • H-J • I-G • J-H 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 1 Ends - Add Edges List of Edges to Add
  • 66. • D-A-B • F-C-E-G-I • H-J List of Trees 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Trees of the Graph at Beginning of Round 2
  • 67. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 4 1 2 2 1 3 2 5 6 4 4 10 A B C D E F G H I J Tree D-A-B
  • 68. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 4 1 2 2 1 3 2 5 6 4 4 10 A B C D E F G H I J Edge B-C
  • 69. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 Tree F-C-E-G-I 4 1 2 3 2 1 3 5 3 4 2 4 A B C D E F G H I J
  • 70. 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 Edge I-J 4 1 2 3 2 1 3 5 3 4 2 4 A B C D E F G H I J
  • 71. 1 2 2 1 3 3 4 2 5 6 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 Tree H-J
  • 72. 1 2 2 1 3 3 4 2 5 6 4 10 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Round 2 Edge J-I
  • 73. • B-C • I-J • J-I 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J List of Edges to Add Round 2 Ends - Add Edges
  • 74. 4 1 2 2 1 3 32 4 A B C D E F G H I J 4 1 2 3 2 1 3 5 3 4 2 5 6 4 4 10 A B C D E F G H I J Minimum Spanning Tree Complete Graph
  • 75. Pseudo code Time Complexity Input: A connected graph G whose edges have distinct weights Initialize a forest T to be a set of one-vertex trees, one for each vertex of the graph While T has more than one component For each component C of T Begin with an empty set of edges S For each vertex v in C Find the cheapest edge from v to a vertex outside of C and add it to S Add the cheapest edge in S to T Output: T is the minimum spanning tree of G. If the edges are E & vertices are V then T = O( E lg V )
  • 76. Kruskal’s and Boruvka’s have better running times if the number of edges is low, while Prim’s has a better running time if both the number of edges and the number of nodes are low. Boruvka’s avoids the complicated data structures needed for the other two algorithms. So, of course, the best algorithm depends on the graph and if we want to bear the cost of complex data structures.