Q2 Shortest Path Part 1a: Generate a random 4 by 4 matrix using https://onlinemathtools.com/generate-random-matrix. Let that matrix represent the adjacency matrix for a graph with 4 nodes V={A,Z,C,D} Draw the graph. Make sure to set the weights between -2 and 2. Part 1b: Run the first 1 iterations of Bellman-Ford on the graph above. Show both d array and pi array. Part 1c: Now change all the negative weights in the graph above to positive weights+3. so if the weight is -2 it becomes 2+3=5. Run Dijstra on the graph showing the Extract min actions and working through the adj. lists of each popped node as we did in class for the first 3 iterations. Show both d array and pi array.

icon
Related questions
Question

Please solve the following shortest path graph problem. Here are the instructions. Show all work step by step. ,note: use c++ psuedo code in this course

Random 4 x 4 matrix:

1 6 3 3
1 0 6 3
5 2 4 5
6 4 1 3
Q2 Shortest Path
Part 1a:
Generate a random 4 by 4 matrix using
https://onlinemathtools.com/generate-random-matrix. Let that
matrix represent the adjacency matrix for a graph with 4 nodes V={A,Z,C,D}
Draw the graph. Make sure to set the weights between -2 and 2.
Part 1b:
Run the first 1 iterations of Bellman-Ford on the graph above. Show both d array and pi array.
Part 1c:
Now change all the negative weights in the graph above to positive weights+3. so if the weight is -2
it becomes 2+3=5.
Run Dijstra on the graph showing the Extract min actions and working through the adj. lists of each
popped node as we did in class for the first 3 iterations. Show both d array and pi array.
Transcribed Image Text:Q2 Shortest Path Part 1a: Generate a random 4 by 4 matrix using https://onlinemathtools.com/generate-random-matrix. Let that matrix represent the adjacency matrix for a graph with 4 nodes V={A,Z,C,D} Draw the graph. Make sure to set the weights between -2 and 2. Part 1b: Run the first 1 iterations of Bellman-Ford on the graph above. Show both d array and pi array. Part 1c: Now change all the negative weights in the graph above to positive weights+3. so if the weight is -2 it becomes 2+3=5. Run Dijstra on the graph showing the Extract min actions and working through the adj. lists of each popped node as we did in class for the first 3 iterations. Show both d array and pi array.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer