input = Graph graph initialize edges as PriorityQueue, mst as List, nodesInTree as List forEach edge in graph.edges call edges.push(edge, edge.weight) next while mst.length() < graph.vertices.length() edge = edges.pop() if ((nodesInTree.contains(edge.first) = false) or (nodesInTree.contains(edge.second) = false)) = true then call nodesInTree.add(edge.first) call nodesInTree.add(edge.second) call mst.add(edge) endIf endWhile