|
Project #4 (Graphs) |
CMSC 132 |
|
Due Date: Friday Mar 23, 6:00 pm |
Object-Oriented Programming II |
|
Type of Homework: Closed |
Spring 2007 |
Objective
The objectives of this project are:
Practice implementation of graphs
Implement Breadth-First Search (BFS) Traversal
Implement Depth-First Search (DFS) Traversal
Implement Dijkstra's algorithm for shortest path
Practice using the Java Collections Framework.
This project is considered a closed project. Make sure you read the open/closed policy before continuing working on this project.
Project Clarifications
Any clarifications or corrections associated with this project will be available at:
http://www.cs.umd.edu/class/spring2007/cmsc132/Projects/p4/clarifications.html
Overview
For this project you will complete the following tasks:
Your project will be graded as follows:
Tests (90 %)
Public JUnit tests (44 %)
Release JUnit tests (46 %)
StudentTests (10 %)
For this project:
Specifications
The TAs have been instructed not to help you debug your code unless you have written a test case that demonstrates that your project is malfunctioning. You should be writing and using your test cases WHILE you are implementing the project, not as an after thought at the very end. Testing and software development go hand-in-hand.
To represent a graph you need to implement three classes:
Vertex class
The Vertex class represents a vertex in the graph. The instance variables associated with this class are:
private LinkedList<Edge<E>> edges; // Represents the neighbors (successors) of the vertex.
private E data; // Represents the vertex's data
private String name; // Name of the vertex
A description of the class methods can be found at project javadoc.
Edge class
The Edge class represents an edge in the graph. The instance variables associated with this class are:
private Vertex<E> startVertex, endVertex;
private int cost: // edge's cost
A description of the class methods can be found at project javadoc.
Graph class
The Graph class can represent both a directed or undirected graph. The instance variable associated with this class is:
TreeMap<String, Vertex<E>> vertexMap; // Keeps track of vertices in the graph. A vertex is identified via its name.
A description of the class methods can be found at project javadoc.
Utilities class
This Utilities class implements the methods computing BFS, DFS, and Dijkstras. You will find in the utilities package an interface named CallBack. A class implementing this interface represents a class that will process a vertex. An example of such a class is PrintCallBack (which you will find in the utilities package). This class is used to generate the string that represents the path we follow when performing a breadth-first search or a depth-first search. Each time we reach a vertex, the implementation of DFS and BFS are expected to call the processVertex method in order to apply whatever processing needs to be done to the vertex. We have implemented PrintCallBack for you (don't modify it). Notice that in this project we will initialize the data component of a vertex to null for simplicity.
A description of the class methods can be found at project javadoc.
Requirements
Submission
Submit your project using the submit project option associated with Eclipse.
Academic Integrity
Please make sure you read the academic integrity section of the syllabus so you understand what is permissible in our programming projects. We want to remind you that we check your project against other students' projects and any case of academic dishonesty will be referred to the University's Office of Judicial Program