CSE 373 Data Structures 09wi, Homework 6 & 7

Electronic Turn-in due: 11:59pm Thursday, March 12, 2009.

This assignment will be equal to 1.5 assignments in weight, although it will only have one due date.  In the assignment, you will develop a graph implementation and then use it to implement at least one graph algorithm.  In particular, you will implement (at least) Dijkstra’s algorithm for finding the shortest path.

For this assignment, (if you wish, not required) you may work with one partner for the programming portion of the assignment.  If you plan on working pairs: one partner MUST send email containing the names and email addresses of both partners to Sean by 11:59pm Friday March 6th.

Part I.  Graph Representations (recommended due date Friday 3/6/09)

In this part of the assignment you will implement a graph representation to be used later in Part II.

The assignment has these files provided:

You are to add code to MyGraph.java that implements the Graph.java interface.  Graph.java makes use of the Vertex.java and Edge.java classes provided, although you should feel free to add things to Vertex.java or Edge.java.  Just don’t remove anything that is currently there.  You should not modify Graph.java.  Your code should be efficient and strive for the minimal big-Oh possible for the requested operations.  Although a simple list of vertices and edges is sufficient to store all information about a graph, it may not be the most efficient method for answering questions about the graph (see part II.)

 

Part II.  Graph Algorithms

In this part of the assignment, you will use the graph representation you created in Part I to read a description of a graph and answer questions about it.  In particular, you should use Dijkstra's algorithm to find shortest paths in the graph.  You may assume that graphs you are given will not contain negative cost edges.

What to Do

We have provided a driver program to read in input from the user:

 

The format of the input files are as follows:

You may assume that every node name that appears in a path (edge) also appears in the vertex list.  Note that since data files are expected to represent directed graphs, the existence of an edge from a to b does not guarantee the existence of an edge from b to a (unless both edges exist in the data file), nor does it guarantee that the weight of the edge from a to b is the same as the weight of the edge from b to a.  You may assume that negative weight edges will not be present in input files you are given.

 

Two sample data files are available representing information about airports and the cost of a flight between them.  File vertex.txt contains a list of 3-letter airport codes, each of which represents a vertex in a directed graph.  File edge.txt contains information about the directed edges in the graph. 

 

You should use your graph implementation from Part I as a starting point.  Feel free to add or extend the given vertex, edge, and MyGraphs classes (but don’t take anything out).

Extra Credit

A small amount of extra credit will be awarded for interesting extensions.  Here are a few possibilities:

What to Turn In

You should turn in the following electronically:

In addition, if you worked with a partner, 1) only one partner needs to submit the code electronically.  2) Be sure that both partners’ names are listed in all files.  3) Include in your readme.txt file a description of how you developed and tested your code.  If you divided it into pieces, describe that.  If you worked on everything together, describe the actual process used – how long you talked about what, how long and in what order you wrote and tested the code.  Be sure to describe at least one good thing and one bad thing about the process of working together.