January 2018
Intermediate to advanced
332 pages
7h 36m
English
The problem at hand now has boiled down to the following—connect all the nodes of our graph with least weight edges and no cycles. To achieve this, first, we will need to isolate all our edges and sort by weight in an increasing order. Then, we employ a technique called union by rank to get the final list of the edges, which can be used to create the MST:
SORT all edges by weight in increasing orderDIVIDE all nodes into their own subsets whose parent is the node iteselfWHILE more edges are required EXTRACT the first edge from the list of edges FIND the parent nodes of the from and to nodes of that edge IF start and end nodes do not have same parent ADD edge to results GET parent of from node and to node IF parent nodes of from ...
Read now
Unlock full access