Construct counterexample where Dijkstra fails with negative weights
Analyze the construct counterexample where dijkstra fails with negative weights.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Recall that Dijkstra's algorithm assumes non-negative edge weights to guarantee correctness. What happens when this assumption is violated?
Consider a graph with a negative weight edge that creates a shorter path when traversed multiple times. How does this affect Dijkstra's greedy selection of the next node?
Construct a minimal graph with three nodes where Dijkstra's algorithm fails to find the shortest path due to a negative weight edge. What is the shortest path in this graph, and what path does Dijkstra's algorithm incorrectly return?
Construct counterexample where Dijkstra fails with negative weights
Analyze the construct counterexample where dijkstra fails with negative weights.