Get Instant Help From 5000+ Experts For

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Maintaining a Network of Towns and Roads with Shortest Path Algorithm using Dijkstra's Algorithm

In this project you will be creating an application to maintain a network of towns and the roads connecting them. The application will use Dijkstraâ€™s Shortest Path algorithm to find the shortest distance between any two towns.

Implement Graph Interface

Use Graph to maintain a network of Vertices

Implement Shortest Path Algorithm

Data Element â€“ Town (Vertex)
Create a Town class that holds the name of the town and a list of adjacent towns, and other fields as desired, and the traditional methods (constructors, getters/setters, toString, etc.).Â  It will implement the Comparable interface.Â  This is the class header:

public class Town implements Comparable

Two towns will be considered the same if their name is the same.

Create a class Road that can represent the edges of a Graph of Towns.Â  The class must implement Comparable.Â  The class stores references to the two vertices(Town endpoints), the distance between vertices, and a name, and the traditional methods (constructors, getters/setters, toString, etc.), and a compareTo, which compares two Road objects. Since this is a undirected graph, an edge from A to B is equal to an edge from B to A. This is the class header:

Â public class Road implements Comparable

Data Structure â€“ TownGraph, implements GraphInterface

Create a TownGraph class that implements the GraphInterface given you.Â  For Graph,Â  V is the vertex type (a Town), E is the edge type (a Road).Â  You will need to decide how to store the graph, use an adjacent matrix or an adjacency list.Â  This is the class header:

public class TownGraph implements GraphInterface
Within the Graph interface is a method shortestPath, which finds the shortest path from a given source Town to a destination Town. Since there is a unique shortest path from every vertex to the source, there is a back-pointer to the previous vertex.Â  The method shortestPath calls dijkstraShortestPath which finds the shortest path from the source to every other vertex in the graph.Â  You will be coding the Dijkstraâ€™s Shortest Path algorithm.Â  You will then be able to find the connections between two towns through the roads that connect them.

You may use the adjacency matrix approach found in the text book, or you may use a set of Towns and a set of Roads. The ShortestPath algorithm typically uses a weighted graph which means that the edges have a weight, and this is used to determine the shortest path.Â  For this implementation, each weight will be the distance of the road in miles.
Data Manager â€“ implements TownGraphManagerInterface

Your TownGraphManager will hold an object of your Graph. Implement the TownGraphManagerInterface. There are methods to populate the graph (reading from a text file), add a town (vertices), add a road (edge), list all towns and all roads, and list towns adjacent to a given town.Â  Â
Your solution will find the shortest path from a start town to a destination town.Â  It will account for the possibility of a disjoint graph (i.e., not all vertices can be reached from all other vertices.)

Exception Classes

IOException â€“ created and thrown when user selects an input file that cannot be read (check out the methods of File).

GUI Driver (provided for you)
The GUI will have three sections: a Town section, a Road section, and a Find Connection section.

Testing
1.Create a JUnit Test - TownGraphManagerTest_STUDENT. Test all the methods of the TownGraphManager with a different set of data than the TownGraphManagerTest provided for you.
2.Create a JUnit Test â€“ TownGraphTest_STUDENT. Test all the methods of the TownGraph with a different set of data than the TownGraphTest provided for you.
4.Create a Junit test â€“ TownTest_STUDENT. Test all the methods of your Town class.

Populating the Data Structure

You will be reading from a data file.Â  You are provided with two sample files: MD Towns.txt and US Towns.txt along with two PowerPoint slides showing these graphs.