This is the class header public class TownGraph implements GraphInterfaceTown

This is the class header public class towngraph

This preview shows page 2 - 4 out of 7 pages.

This is the class header: public class TownGraph implements GraphInterface<Town, Road> 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.) You may add any methods as needed for your design. 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: an Town section, an Road section, 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.
Image of page 2
2. Create a JUnit Test – TownGraphTest_STUDENT. Test all the methods of the
Image of page 3
Image of page 4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture