KruskalMST(G):
| Input graph G with n nodes
| Output a minimum spanning tree of G
|
| MST=empty graph
| sort edges(G) by weight
| for each e∈sortedEdgeList do
| | MST = MST ∪ {e}
| | if MST has a cyle then
| | MST = MST \ {e}
| | end if
| | if MST has n-1 edges then
| | return MST
| | end if
| end for
|