A way of finding a MST by sorting all edges by their weights and adding them to our constructed MST as long as it doesn’t form a cycle with previous edges
Topics
Pseudocode
- Sort all edges by their weights
- For edge in list of sorted edges
- Add to the MST
- If forms a cycle with the MST (this can be done in time by applying the union find problem. Consider each connected tree to be a set and if we find the nodes forming belong to the same set, then a cycle is formed. If not, there is no cycle, and we then union the two connected trees)
- Discard it
- ++
- is the number of edges
- is the number of vertices
- The equality occurs because if or , then the log makes the constant go away