Question: 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

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. You may add any methods as needed for your design.

-----------------------------------------------------------------------------

 import java.util.*; public interface TownGraphManagerInterface { /** * Adds a road with 2 towns and a road name * @param town1 name of town 1 (lastname, firstname) * @param town2 name of town 2 (lastname, firstname) * @param roadName name of road * @return true if the road was added successfully */ public boolean addRoad(String town1, String town2, String roadName); /** * Returns the name of the road that both towns are connected through * @param town1 name of town 1 (lastname, firstname) * @param town2 name of town 2 (lastname, firstname) * @return name of road if town 1 and town2 are in the same road, returns null if not */ public String getRoad(String town1, String town2); /** * Adds a town to the graph * @param v the town's name (lastname, firstname) * @return true if the town was successfully added, false if not */ public boolean addTown(String v); /** * Determines if a town is already in the graph * @param v the town's name (lastname, firstname) * @return true if the town is in the graph, false if not */ public boolean containsTown(String v); /** * Determines if a road is in the graph * @param town1 name of town 1 (lastname, firstname) * @param town2 name of town 2 (lastname, firstname) * @return true if the road is in the graph, false if not */ public boolean containsRoadConnection(String town1, String town2); /** * Creates an arraylist of all road titles in sorted order * @return an arraylist of all road titles in sorted order */ public ArrayList allRoads(); /** * Deletes a road from the graph * @param town1 name of town 1 (lastname, firstname) * @param town2 name of town 2 (lastname, firstname) * @param roadName the road name * @return true if the road was successfully deleted, false if not */ public boolean deleteRoadConnection(String town1, String town2, String road); /** * Deletes a town from the graph * @param v name of town (lastname, firstname) * @return true if the town was successfully deleted, false if not */ public boolean deleteTown(String v); /** * Creates an arraylist of all towns in alphabetical order (last name, first name) * @return an arraylist of all towns in alphabetical order (last name, first name) */ public ArrayList allTowns(); /** * Returns the shortest path from town 1 to town 2 * @param town1 name of town 1 (lastname, firstname) * @param town2 name of town 2 (lastname, firstname) * @return an Arraylist of roads connecting the two towns together, null if the * towns have no path to connect them. */ public ArrayList getPath(String town1, String town2); } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!