MST using kruskal with sorting and prim