Kruskal Algorithm: Straightforward implementation (detecting loops with BFS)