In this coding assignment, you will be asked to write Java code to read a text f
ID: 3671189 • Letter: I
Question
In this coding assignment, you will be asked to write Java code to read a text file (input.txt) of a graph represented as an adjacency list. Example:
A, 7, B, 9, C
B, 1, C
C, 8, E, 2, F
D, 1, E, 3, G
E, 3, G
F, 3, D, -3, H
H, 6, G
K, 3, H, -1, F
The graph represented by the adjacency list above looks like this:
The graph is a Directed Acyclic Graph (no cycles). You are required to write Java code to find one correct topological sorting for the graph; and after that, you will ask the user for a node (starting node), then you will print the shortest path from that node to all other (following nodes)
Example, after reading the adjacency list above, if the user enters the value 'A' as the starting node, then your program should print the following:
B: A - B (7) \ Essentially, this means that the shortest path from A to B is A - B and its length is 7
C: A - B - C (8) \ Essentially, this means that the shortest path from A to C is A - B - C and its length is 8
D ... \ You will have to list all the shortest paths from A to all other nodes
E ...
F ...
Explanation / Answer
// this is a java program to find the shortest path between source and destination vertex
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.