IN JAVA (Find paths) Define a new class named UnweightedGraphWithGetPath that extends UnweightedGraph with a new method for finding a path between two vertices with the following header: public List getPath(int u, int v); The method returns a List that contains all the vertices in a path from u to v in this order. Using the BFS approach, you can obtain the shortest path from u to v. If there isn’t a path from u to v, the method returns null. Write a test program that creates a graph for Figure 28.1. The program prompts the user to enter two cities and displays their paths. Sample Run Enter a starting city: Seattle Enter an ending city: Miami The path is Seattle Denver Kansas City Atlanta Miami Use https://liangpy.pearsoncmg.com/test/Exercise28_05.txt to test your code.
IN JAVA
(Find paths)
Define a new class named UnweightedGraphWithGetPath that extends UnweightedGraph with a new method for finding a path between two vertices with the following header:
public List getPath(int u, int v);
The method returns a List that contains all the vertices in a path from u to v in this order. Using the BFS approach, you can obtain the shortest path from u to v. If there isn’t a path from u to v, the method returns null. Write a test program that creates a graph for Figure 28.1. The program prompts the user to enter two cities and displays their paths.
Sample Run
Enter a starting city: Seattle
Enter an ending city: Miami
The path is Seattle Denver Kansas City Atlanta Miami
Use https://liangpy.pearsoncmg.com/test/Exercise28_05.txt to test your code.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









