Minimum Spanning Tree (Kruskal)

medium
Unit 9 · Graphs II0/2 to milestone

Connect all offices with network cable at the lowest total cost. That's a minimum spanning tree. Kruskal's algorithm: sort edges by weight, then add each edge unless it would form a cycle, checked with union-find.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Minimum Spanning Tree (Kruskal) · TechGradify