Kruskal algorithm for finding minimum spanning tree in graph