Why a negative edge makes Dijkstra answer wrong, and what Bellman-Ford pays to be right.
About this comparison
One directed graph of 5 nodes with one negative edge, C to E at −3. Dijkstra runs first, then Bellman-Ford on the same graph; each counter counts that algorithm's edge checks.
Dijkstra keeps a priority queue ordered by distance. It pops the closest node, treats that distance as final, and relaxes the edges out of it: a neighbour reached more cheaply gets the new distance and joins the queue. It stops when it pops the target.
Bellman-Ford keeps no queue. It relaxes every edge in the list, then does it again, for at most V − 1 passes, 4 here, since a shortest path never needs more edges than that. A pass with no change ends the run, and one more sweep checks for a negative cycle.
Dijkstra trusts that the closest unfinished node cannot get cheaper. That holds only with no negative edge, and it is what makes Dijkstra fast: O((V + E) log V) with a binary heap. Bellman-Ford trusts nothing and rechecks every edge every pass, O(V · E), so it stays right with negative edges and can spot a negative cycle.
Dijkstra pops A at 0, B at 1 and D at 3, and sets E to 3 + 2 = 5. E, at 5, is now closer than C, at 6, so E comes out next: the target. Dijkstra returns 5 after 4 edge checks, with C still queued and its edge worth 6 − 3 = 3. Too late.
Bellman-Ford's pass 1 meets C to E while C is still at infinity, and skips it; then B gets 1, D 3, E 5 and C 6. Pass 2 opens on C to E: 6 − 3 = 3, less than 5, fixed. Pass 3 changes nothing, no negative cycle turns up, and it returns A, C, E at 3: 20 edge checks to Dijkstra's 4, for the right answer.
Use Dijkstra whenever every weight is zero or more: road distances, travel times, network delays. It is far faster on a large graph.
Use Bellman-Ford when a weight can be negative, such as a refund along a route, or to find a negative cycle: a loop of currency trades that ends with more money. With every edge the same cost, plain BFS beats both.