Spanning Trees
Spanning Tree
A spanning tree for a weighted graph is a tree in which each vertex is connected and . It is any sub-graph of that connects all nodes without any cycles.
Link to original
Minimum Spanning Tree
For all spanning trees, there must be one where the sum of all weights is minimal, this is called a minimum spanning tree (MST).
Link to originalIn this example, .
Kruskal’s Spanning Tree Algorithm
Kruskal's Spanning Tree Algorithm
:
Link to original
- Sort the edge list by weight (shortest first)
- Initialise a set
- While sorted list is not empty:
- Dequeue the shortest edge from
- If is acyclic:
- Update
- Return tree
Theorem: Termination time for Kruskal’s is .
- For step 1, we need to sort which can be done using merge-sort or some equivalently efficient sorting algorithm. Time to sort by weight .
- Steps 3.1 and 3.2.1 are primitive and take steps for each iteration . The total time for these is
- Step 3.2 requires checking whether and are already connected since a second connection would create a cycle. Here, we use an algorithm called quick-union find. Total time to check , where is a very slow growing function. (see Cormen et al. 21.3)
- Hence the total worst-case termination time is:

In this example,