Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
CS 2420 Fall 2010 Program 8 20 points Spanning Trees
 

Summary: CS 2420 Fall 2010
Program 8 20 points Spanning Trees
Objective: to gain familiarity with graph theoretical problems and algorithms
Many problems arising in the real world are best modeled as minimum spanning tree problems. For example,
suppose that you have a large number of communication points and you need to link them so that any site can
communicate with every other site. You are not concerned with how long it takes for the message to be routed
between sites (possibly through other sites). You just need there to be at least one route by which the message
can be sent. Your concern is to minimize the cost of building the links. Not every pair of sites can be feasibly
directly linked. For each pair which can be linked, you know the cost to link them directly.
The best approach is to model this problem with a graph. Each site is represented by a node. If two sites can be
linked, then there is an undirected edge between the two corresponding nodes and that edge has a weight equal
to the cost of building such a link. The cheapest way to build all the links will be represented by a minimum
weight spanning tree of the graph, i.e., a subtree which contains every node and some of the edges such that the
edges have the smallest total weight of all such trees.
Fortunately, there are some very efficient algorithms for solving the minimum spanning tree problem, the two
most common being Kruskal's algorithm and Prim's algorithm.
Your assignment is to implement Prim's and Kruskal's algorithms in C++.
Prim's Algorithm
Prim's algorithm, a greedy algorithm, runs by building a tree one vertex (and connecting edge) at a time. At first
the tree, T, contains only one vertex (it doesn't matter which vertex you start with). At each step it adds a new

  

Source: Allan, Vicki H. - Department of Computer Science, Utah State University

 

Collections: Computer Technologies and Information Sciences