The goal of this project is to implement the two major algorithms to compute a minimum spanning tree for weighted graphs: Kruskal's Algorithm and Prim's Algorithm. You will also compare them using a simple experiment.
This project is also useful in that it allows you to see how other ADTs and data structures support algorithms and affect their running time.
This project appears in the book as Project 4.1, pg 320.
Copy the give code from ~tvandrun/Public/cs345/mst
and make an Eclipse project for it.
You will find five packages: in addition to adt
,
impl
, and
test
, which have their usual purpose,
we also have alg
for (externally implemented) algorithms
over graphs and exper
for an experiment.
Before going on, familiarize yourself with the structure of the various
classes and interfaces and packages, since it is more complicated
than in previous projects and I am giving you less guidance
(although I will talk or have talked about it in class).
Specifically understand how the two MST algorithms are encapsulated
in classes that implement the MinSpanTree
interface.
Note that you will need some code from your solutions to
earlier projects, specifically Sorts
from
the linear sorting project and Heap
and
HeapPriorityQueue
from the heap project.
Do parts a-c, testing as you go.
Now do part d.
Read through expr.MSTExperiment
to see how
the
experiment is set up.
Run it (without assertions enabled.)
What do you observe?
You are encouraged to modify the experiment for further learning.
Copy the files you modified
(Heap
,
HeapPriorityQueue
,
KruskalMinSpanTree
,
PrimMinSpanTree
,
and Sorts
to your turn-in folder
/cslab/class/cs345/(your id)/mst
.
To keep up with the course, this should be finished by Feb 26.