Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

1. What is nonverbal communication?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

What is Indian Polity and Governance ?

Answered: 1 week ago

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago