Kruskal's algorithm is a [[greedy algorithm]] for calculating a [[minimal spanning tree]]. Sort the edges in ascending order. Build a tree for all edges of the lowest weight. For each increasing weight, add edges only if they connect two different trees (including the trivial tree of one single node). If adding the connection would create a cycle, then the node is already a part of the tree and should be skipped. The [[union-find data structure ]]is used to check that a node is part of a different tree.