// Returns the MST by Kruskals Algorithm
// Input: A weighted connected graph G = (V, E)
// Output: Set of edges comprising a MST
Algorithm Kruskal(G)
    Sort the edges E by their weights
    T = { }
    while |T | + 1 < |V | do
         e = next edge in E
         if T + {e} does not have a cycle then
            T = T + {e}
    return T