COMS 482: unofficial class blog


Lecture 4: Minimum Spanning Trees

Posted in Class Notes by Elliott Back on January 31st, 2005. [Del.icio.us]

Minimum Spanning Tree (MST):

Given a connected graph G=(V,E), a spanning tree is a connected subgraph on V. A minimal spanning tree is a spanning tree with the minimal number of edges.

“A spanning tree is a tree.”

To not be a tree, it must (a) be not connected or (b) have a cycle. By definition, (a) is false, because an MST is defined as a connected subgraph. For (b), if a cycle exists we can erase any edge in the cycle and still maintain connectedness.

Each edge has a cost. The minimum spanning tree is a least total cost tree. For example:

A mimimal spanning tree example

MST Algorithm:

  • Choose all edges, dropping expensive edges until you have a complete tree
  • Choose least cost edges that do not make a cycle (Kruskal’s)
  • Build a single tree, always adding least cost edges (Prim’s)

Kruskal’s Algorithm:

Sort edges by cost
T = {}
for e in edges do
    if e does not create a cycle then
        add e to T
    endif
endfor

Prim’s Algorithm:

Choose a start vertex s
T = {s}
While there is a vertex not in T do
    choose least cost edge from T to some vertex not in T
    add this edge to T
endwhile

“Kruskal’s algorithm produces an MST”

Let k1, … , kn-1 be edges added by Kruskal’s algorithm in the order added. Assume k1, … , kn-1 is not an MST. Then let ki be the first edge added that makes it impossible to extend k1, … , ki to an MST. Consider a true MST that uses k1, … , ki-1. Let k1, … , ki-1,mi, …, mn-1 be the true MST. If we add ki to k1, … , ki-1,mi, …, mn-1 (true MST) then we get a cycle. This cycle contains some edge mj where j >= i. The cycle cannot be all k’s because Kruskal’s algorithm would not have added k.

Consider the graph from adding ki and removing mj in k1, … , ki-1,mi, …, mn-1. We still have a spanning tree, with three cases:

  1. |ki| < |mj| => Contradiction, because the new tree has less cost than the true MST
  2. |ki| > |mj| => Contradiction, because mj would have been chosen by Kruskal's algorithm before ki.
  3. |ki| = |mj| => Contradiction, because now both trees are MST and have the same cost, but ki was chosen to not be in an MST with k1, … , ki.

This entry was posted on Monday, January 31st, 2005 at 2:10 pm and is tagged with , , , , , , , , , , , , , . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

2 Responses to 'Lecture 4: Minimum Spanning Trees'

  1. […] All of these MST algorithms can be implemented in O(m log n) time. Lecture 4 contains a proof that Kruskal’s algorithm produces an MST, lecture […]

  2. 89da44ca5bd5 said:

    on May 10th, 2008 at 2:26 pm

    89da44ca5bd5…

    89da44ca5bd5116ff73e…

Leave a Reply

I'm the fair Wordpress Anti-Spam Plugin?

Please take time to enjoy the archives: May 2005 (1) April 2005 (11) March 2005 (11) February 2005 (15) January 2005 (7)

Fresh, related resources:

Supplied by Google Blog Search
  • Machine Learning and Artificial Intelligence Video Lectures
    ... partitional, minimum spanning tree, aghc, kohonen maps, k-means, fuzzy k-means, competitive learning; bayes rule, heuristic algorithms, tree based algorithms, optimization algorithms, neural networks, training methods, perceptons, ...
  • LECTURE SERIES FOR DATA STRUTURE
    Different spanning trees have different weights, the minimum spanning tree is the spanning tree with the minimum weight. Example: weights added to the graph above spanning tree S1 has weight 3+2+4 = 9 spanning tree S2 has weight 2+4+1 = ......
  • history of computer science
    for the minimum spanning tree in order to minimize the wiring needed for the X1 computer. (Dijkstra is famous for his caustic, opinionated memos. For example, see his opinions of some programming languages). ...
  • Graphs (Part 4)
    Minimum Spanning Trees, Here We Come! L17.pdf L17.ppt.