algorithm Kruskal's Algorithm Simple, high level implementation


Example

Sort the edges by value and add each one to the MST in sorted order, if it doesn't create a cycle.

algorithm kruskalMST(G: a graph)
    sort G's edges by their value
    MST = an empty graph
    for each edge e in G:
        if adding e to MST does not create a cycle:
            add e to MST

    return MST