Why does Dijkstra fail with negative edges?
Analyze the why does dijkstra fail with negative edges?.
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Consider how Dijkstra's algorithm relies on the greedy property of always selecting the shortest path to a node first, and how negative edges can disrupt this property.
Recall that Dijkstra's algorithm assumes that once a node is processed, its shortest path cannot be improved, which is not true when negative edges exist in the graph.
Examine the relaxation step in Dijkstra's algorithm and how it fails to account for potential improvements in shortest path distances when negative edges are present, unlike the Bellman-Ford algorithm which handles such cases.
Why does Dijkstra fail with negative edges?
Analyze the why does dijkstra fail with negative edges?.