Q6) The diagrams below show two directed graphs. We would like to investigate the effect…
- User
Q6) The diagrams below show two directed graphs. We would like to investigate the effect of negative edge weights when using Dijkstra’s algorithm to find the lowest cost path from A to all other nodes. 30 B -2 A 5 C version 1 B 30 -10 D 20 A 5 version 2 D 20 C Run Dijkstra’s algorithm on both versions and complete their corresponding tables on your answer sheet. In which version do you think the path costs are calculated correctly for all nodes even though one of the edges is negative weighted? Why does a version work properly while another one does not? Your answer should refer to the concept of an invariant. The image shows two versions of a directed, weighted graph with the same nodes (A, B, C, and D) and the same edge structure, but different weights on some edges.
Version 1:
A to B: Weight 30
A to C: Weight 5
B to D: Weight -2
C to D: Weight 20
Version 2:
A to B: Weight 30
A to C: Weight 5
B to D: Weight -10
C to D: Weight 20
The only difference between the two versions is the weight of the edge from B to D. In version 1, it's -2, while in version 2, it's -10. This means traversing from B to D in version 2 has a more negative impact (e.g., lower cost, shorter time, etc.) than in version 1 depending on what the weights represent. ans in :Q6)
codeA B C Diteration 0 1 2 3 4
version 1 [2 marks]
codeA B C Diteration 0 1 2 3 4
version 2 [2 marks]
codeWhich result is correct? (0 version 1)/(0 version 2) [1 mark]. Why? [2 marks].Provide your explanation here...
- Assistant