In this recipe, we will learn how to make a minimum spanning tree using Kruskal's algorithm.
A minimum/minimal spanning tree of an undirected graph is a tree that is formed from graph edges that connect all of the vertices of the graph at the lowest total cost. A minimum spanning tree can exist if, and only if, the graph is connected. A graph is said to be connected if there exists a path between any two vertices.
Here, the nodes of the graph are initially considered as n distinct partial trees with one node each. At each step of the algorithm, two distinct partial trees are connected into a single partial tree by an edge of the graph. When only one partial tree exists (for instance, after n-1 such steps), it is a minimum spanning tree.
The connecting arc of minimum cost is used to connect two distinct...