Simple high level implementation

suggest change

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

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents