Professional Documents
Culture Documents
ADA Lect5
ADA Lect5
Analysis
Lecture 5: Minimum Spanning Tree
Minimum Spanning Tree
• Then, place all of the nodes that are select a starting node
connected to this initial one into the build the initial fringe from nodes connected to the
starting node
fringe category. while there are nodes left do
• Loop through the process of picking choose the edge to the fringe of the smallest
weight
the smallest weighted edge connecting add the associated node to the tree
a tree node with a fringe node, adding update the fringe by:
adding nodes to the fringe connected to
the new node to the tree, and then the new node
updating the nodes in the fringe updating the edges to the fringe so that
category. they are the smallest
end while
• When all the nodes have been added to
the tree, we are done.
Minimum Spanning Tree: The Dijkstra-Prim
Algorithm
Minimum Spanning Tree: The Dijkstra-Prim
Algorithm
• Where the Dijkstra-Prim algorithm began at a particular node and built the
minimum spanning tree outward, Kruskal’s algorithm concentrates instead on the
edges of the graph.
• In this algorithm, we begin with an empty spanning tree and add edges in order of
increasing weight until all nodes are connected to the graph.
• If we run out of edges before all of the nodes are connected, the original graph
wasn’t connected, and the result we have generated is the MSTs of each of the
connected components of the original graph.
Minimum Spanning Tree: The Kruskal Algorithm
two nodes that are connected by the next edge edgeCount = edgeCount + 1
we are considering. end while
Minimum Spanning Tree: The Kruskal Algorithm