Question: The below program is functional however, the getCheapestPath is not returning the true cheapest path, can you fix that and also implement a readFromFile method

The below program is functional however, the getCheapestPath is not returning the true cheapest path, can you fix that and also implement a readFromFile method which reads a .txt file and creates a weighted directed graph from it. The txt file will be of the form:

map.txt

city 1 Tokyo

city 2 New_York

city 3 Honk_Kong

road 1 2 30

road 1 3 15

road 3 2 8

The program should be anble to be implemented as follows in the terminal:

javac Driver.java

java Driver fromCity toCity

Where it then prints out the Cheapest path and distance.

I was unable to fit the source code here because chegg wouldn't allow it, however here is a dl link to a .txt with all the source code.

https://file.town/download/keb4z4guge84y41ihtmvbuzkv

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!