Kruskal's algorithm is a minimum spanning tree algorithm that takes a graph as input and finds the subset of the edges of that graph which •form a tree that includes every vertex •has the minimum sum of weights among all the trees that can be formed from the graph
We are first taking number of nodes and edges as input-(9,14)
then we will be taking 14 lines of input each line consisting of two connecting node ids and weight
Input:
9 14 0 1 4 0 7 8 1 2 8 1 7 11 2 3 7 2 5 4 2 8 2 3 4 9 3 5 14 4 5 10 5 6 2 6 8 6 6 7 1 7 8 7
Output : 37