Kruskal's Algorithm

In this algorithm, the following data structures are used:

F is a set of edges that is initially empty
E is a set of edges that initially contains all the edges

We also have n sets, each containing exactly one vertex from the graph

We first sort the set E in order by cost, so that we can choose the minimum cost edge from it (a heap is often used for this, so that we can remove the minimum cost edge every time)

while (the problem is not solved)
{
    select next edge from E (this removes the edge from E)

    if (the edge connects vertices in two disjoint sets)
    {
        merge the sets containing the two vertices
        add the edge to F
    }

    if (all vertices are in one set)
        the problem is solved
}