Fix break_cycles and add kruskal's algorithm