Minimum spanning tree
Selecting the n-1 edge in a connected graph with n vertices, constituting a minimum connected subgraph, and minimizing the sum of the weights on the n-1 edge of the connected subgraph, it is called the minimum spanning tree of the connected network.
For example, a connected network, as shown in the above figure G4, can have multiple spanning trees with different weights combined.
Introduction to Kruskal algorithm
Kruskal (Kruskal) algorithm is used to calculate the minimum spanning tree of weighted connected graphs.
Basic idea : According to the weight value from small to large order to select the n-1 edge, and ensure that the n-1 edge does not constitute a circuit.
The concrete approach : first constructs a forest which contains only n vertices, then chooses the edge from the connected network from small to large to join in the forest, and causes the forest to not produce the loop, until the forest becomes a tree.
Kruskal algorithm diagram
The above figure G4 as an example to demonstrate the Kruskal (assuming that the most niche tree result is saved with an array R).
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/