chevron_leftGraphs All topics

Bellman–Ford

63-4283
A 0
B ∞
C ∞
D ∞
E ∞

Look at the pink edge: C → B costs **−4**. Dijkstra would go badly wrong here — it finalises B early on the cheap-looking direct route and never reconsiders. Bellman–Ford makes no assumptions at all, so it copes.

step 01/17

  • just discovered
  • visited
  • found it
  • visiting now
  • waiting in the queue / stack

Practice

spec · json ↗