Comp 2673, Spring 2003
Lab 5
April 29 and May 1

Your second project is to implement Dijkstra's algorithm to find the shortest path. Before you start writing the code for the program to do this, you will need to make some decisions about the design of the program. For example, remember that the program will have to read information about the graph from a file. This file will tell you how many vertices are in the graph, how many edges are in the graph, and the information about each edge. You'll have to store this information. There are many ways the graph can be stored.

The purpose of this lab is to get you thinking about the data structures you want to use to store the graph. Will you use a 2-D array, a vector, classes?

Below are some questions for you to answer about ways that you could store the information for a graph. You can work together to answer these questions. You don't need a computer for this lab.

  1. Think of multiple options for how the data for the graph will be stored. Give at least two, preferably three options. Explain these options in detail (for example, "store the edges in a vector" is not sufficient detail).
  2. Look at an example of Dijkstra's algorithm solved by hand (e.g., notes from class or from the last homework). Consider each step of the algorithm. Which step(s) require you to access the edge information from the graph? For this step(s), what will you have to search for in your graph data structure? For each of the options you gave in question 1, how will you search for the relevant information?
  3. For each of the options you gave in question 1, give an advantage and disadvantage as compared to the others. Include, for example, comparisons in the ease of accessing the information, the memory required, and the speed.