We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Minimum Spanning Tree
Stephen M. Reaves
::
2025-02-17
Greedy algorithms to find minimum spanning tree
Summary
We found a greedy algorithm to construct MSTs by partitioning graphs and using
cut edges
Contents
MST Problem
Given: Undirected graph G, with weights w for e in E.
Goal: Find minimal size, connected subgraph with min weight
Tree Properties
Tree
connected, acyclic graph
Basic properties:
- n vertices = n-1 edges
- exactly 1 path between every pair of vertices
- if there are 0 paths, tree is not connected
- if there are 2 or more, there is a cycle
- Any connected is a tree
Kruskal’s Algorithm
Sort edges by lowest weight, iterate over edges, add them to the tree if you can
We cannot add the edge of weight 6 since it would create a cycle
It takes O(mlogn) time to sort edges by weight
It takes O(logn) time to find if adding an edge creates a cycle
- Using
Union-Find
data structure
- Searches to see if nodes are in same component
Kruskal’s Correctness
Assume by induction tree X is correct so far
where T is MST
If for some edge e, we don’t add e to x, x is still MST.
If for some edge e, we do add e to x, where T’ is a MST
We know T’ is minimum becuase e is of minimum (remaining) weight
Cuts
Cut
S set of edges that partition the vertices into two sets
Cut Property
For an undirected Graph G
- Take where for an MST T
- Take where no edge is in the
- Look at all edges of G in
- Let be a minimum weight edge in cut
Then where T’ is an MST
If we start with disjoint subsets and only consider minimal edges going between
them adding the edge will create a new MST