1 of 6

Minimum Spanning Trees

Joshua Pan

2 of 6

Graph Crash Course

Graph: a set of vertices and set of edges joining different pairs of distinct vertices�Subgraph: a graph formed by a subset of vertices and edges of the original graph�Path: a sequence of vertices such that each pair of consecutive vertices are joined by an edge�Cycle: a path that starts and ends at the same vertex�Connected Graph: there is a path between any pair of distinct vertices�Tree: a connected graph with no cycles�Weighted Graph: a graph with weights assigned to �each edge

3 of 6

So what are (minimum) spanning trees?

Spanning tree: a subgraph that contains all vertices of the vertices of the original graph and is a tree�Minimum spanning tree: a spanning tree of a weighted graph for which the sum of all the weights of its edges is minimal

4 of 6

Algorithms for finding MSTs

Boruvka’s AlgorithmPrim’s (Jarnik’s) Algorithm (Jarnik 1930; Prim 1957)Kruskal’s Algorithm�Reverse-delete Algorithm�etc…

For regular spanning trees:�simple DFS or BFS will work

Fun Fact: Stigler’s law states that no scientific discovery is named after its original discoverer.

Looks like Prim took all the credit. Jarnik….

Question: What did Prim say when he couldn’t get his algorithm to work?

5 of 6

General greedy algorithm for MSTs

Forest: a graph containing one or more trees�Given a connected graph G with n vertices, we construct subgraphs T0, T1, … Tn-1 where each Tk is a forest of n-k trees and Tn-1 is MST for G. The algorithm follows:�Step 0 (initialize): T0 is a forest of n trees, where each tree consists of a single vertex of G. (T0 has no edges).�Step k: Given Tk-1, select one of the trees T’ and find the minimal unused edge ek in G coming out of T’ such that adding ek to Tk-1 will not create a circuit. Let Tk be the union of Tk-1 and ek.�Tn-1 will be a forest of one tree, which is clearly a spanning tree for G.

But how do you pick that one tree T’?�That is where each algorithm differs from each other.

6 of 6

The beauty in the tree

Boruvka’s Algorithm: At the beginning of the algorithm, enqueue all the trees in T0. At each step select the next tree.

Prim’s Algorithm: Choose a single tree in the beginning of the algorithm and always use that tree.

Kruskal’s Algorithm: Choose the tree for which ek would be minimal.

--------------------------------------------------�Reverse-delete Algorithm: Get rid of the largest weighted�edge, which still keeps the graph connected,�until you are left with n-1 edges.