Question: 1 . [ Dijkstra ' s single - source shortest paths: programming ] Write a program code to implement the Dijkstra's single - source shortest
Dijkstras singlesource shortest paths: programming Write a program code to implement the Dijkstra's singlesource shortest paths finding algorithm discussed in class and show the trace of the algorithm against the directed graph shown below. Your code should follow the instructions stated below.
Use the node s as the source node.
Use any data structure of your choice eg adjacency list, adjacency matrix, edge list to represent the graph.
Use a minimumoriented priority queue of nodes as studied in class. Feel free to use Java PriorityQueue class, or implement one of your own.
Use the pseudocode discussed in class shown below as the base of your program code; your code should maintain the same code structure as the base code and explicitly include the functions ExtractMin and ChangeKey that implement the two priority queue operations.
The base code does not keep track of the predecessors of each node. Extend the base code to keep track of them.
When executed, your program should display the following information on the console:
i The data structure you used to represent the graph. Example: "Graphs is represented using an adjacency list."
ii Each time a new node is included into the cut S the shortest path ie sequence of node numbers from s to the node included. Example: "Node v included in S with the shortest path length x on the path svvldotsv
Base code keep the program code structure as shown below:
DijkstraG s
Initialize Q of V with pivleftarrowinftymathrm for each node V in V
Sleftarrowpisleftarrow
while Qmathrm is not empty
v ExtractMinQ
Add v to S
for each edge evw such that w
otinS
if pivmp@subsupIepiw
pi w pi v l e
ChangeKeyQ wpiw
endwhile
Graph for algorithm tracing:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
