Using Kruskal's Algorithm here is a trap—generating and sorting every possible edge creates massive memory overhead. Instead, I implemented an optimized version of Prim’s Algorithm. By growing the ...