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