Concept:
• Dijkstra's algorithm is a greedy algorithm used to find the shortest path from a single source to all other vertices in a weighted graph.
• It functions by maintaining a set of "visited" nodes and repeatedly picking the unvisited node with the smallest tentative distance.
• The core assumption of Dijkstra's is that once a node is added to the "visited" set, its shortest path has been found and will not be improved by any other path.
Step 1: Evaluate the impact of negative weights
Dijkstra's algorithm assumes that adding an edge to a path can only increase (or keep the same) its total weight.
If negative edge weights are present, a path that looks longer currently could eventually become shorter by including a negative edge.
Because Dijkstra's "locks in" the shortest distance greedily, it fails to reconsider nodes and thus produces incorrect results in the presence of negative edges.
Step 2: Verify other options
• Directed Acyclic Graph (DAG): While Dijkstra's works on DAGs, it is not required. It works perfectly fine on graphs with cycles as long as weights are non-negative.
• Equal weights: If all weights are equal, Dijkstra's effectively becomes Breadth-First Search (BFS). This is a special case, not a requirement.
• Complete graph: Dijkstra's works on both sparse and dense (complete) graphs.