Implement Kruskal's MST algorithm