Kruskal's Algorithm
Summarized notes on Introduction to Algorithms, Chapter 23
- choose the least-weight edge that connecting distinct components
and - implement using disjoint sets where each set represents a tree
- when vertices
and have different representative they belong to different sets - edge
is safe to add to
- when vertices
- optimal time when using union by rank and path compression
Example
Complexity
Running time | |
---|---|
initialize sets -- |
|
sort sets | |
set operations to find and union | |
= Kruskal's algorithm |