Minimum Spanning Tree Algorithms
Interactive visualization of Kruskal's and Prim's algorithms
Controls
Graph Visualization
Step: 0 / 0
All Edges
MST Edges (0)
Kruskal's Algorithm
Greedy approach: Sort all edges by weight and add them one by one to the MST.
Union-Find: Use disjoint set data structure to detect cycles.
Time Complexity: O(E log E) where E is the number of edges.
- Sort all edges in ascending order by weight
- For each edge, check if it creates a cycle using Union-Find
- If no cycle, add edge to MST
- If cycle detected, skip the edge
- Continue until MST has V-1 edges