Comp 2673
Spring 2003
Project 2
Assigned April 23, 2003
Due May 14, 2003

In this project, you will implement Dijkstra's algorithm to find the shortest path between two nodes in a graph. See the course notes or solutions to homework for a description of this algorithm and examples. If you choose to, you may work with another person on this assignment.

The data for the graphs will be stored in files. Your program should ask the user for the name of the graph file they want to use. The format of the graph files is as follows. The first line contains an integer giving the number of vertices (v). The vertices are assumed to be numbered from 1 to v. The second line contains an integer giving the number of edges (e). Each subsequent line gives the data for an edge. There should be e such lines in the file. Each of the lines describing an edge has 3 numbers. The first two are the vertices that the edge connects (of course these should be integers from 1 to v) and the third is the weight of the edge, a non-negative floating point number. Your program should do error checking on the files, rather than risk crashing.

Look on the link graph_examples for a few examples to test your program, but you should also create at least a couple of test files yourself and submit these along with your program.

After reading the graph file, the program should tell the user how many vertices are in the graph, and ask the user for two vertices. It should determine the shortest path between these two vertices, and print out the path along with the length of the path. If you'd like to, you may also give the user the option of seeing the shortest paths from the first vertex to all the remaining vertices, but this is not required. If you do allow this option, then think about saving the data to a file, since there may be a large number of vertices.

In this project, you'll have to make a number of design decisions, such as how to store the data for the graph, and how to store the data you collect as part of the algorithm. There is not a single choice of how to solve this problem - there are very many possibilities for excellent solutions. This will continue to be true for future programs in this course and in others. Because of this, your program must be well-documented. Pay attention to this. DO NOT wait until the program is complete to add your comments - the quality invariable suffers. A one-page overall explanation may dramatically improve your doumentation. You can put this as a long comment at the beginning of your program or as a separate document.

On or before the due date, submit an electronic copy of your source code, a make file, and your test files by mailing to comp2673@cs.du.edu. Also, it's a common tradition to also send a file called README that explains what is being attached, how to build the program, and how to use it. Please tar and zip your files before sending.