Kruskal’s Algorithm is used to find the Maximum Spanning Tree (MST) of a graph

General Algorithm

kruskals-algorithm(G(V,E)) {
	min-heap = sort all edges in E by weight
	edges-included = []
	while (edges-included.size == |V| - 1)
		edge = min-heap.extractMin()
		if (edge NOT forms a cycle) 
			edges-included.add(edge)
	return edges-included
}

General Algorithm With Disjoint Sets Data Structure

kruskals-algorithm(G(V,E)) {
	for each vertex v in V do MAKE-SET(v)
	min-heap = sort all edges in E by weight
	edges-included = []
	while (edges-included.size == |V| - 1)
		edge = min-heap.extractMin()
		if (FIND(edge.v1) != FIND(edge.v2)) 
			edges-included.add(edge)
			UNION(edge.v1, edge.v2)
	return edges-included
}