Single Source Shortest Path


A single source shortest path algorithm discovers the shortest paths between a single node and all the other nodes. There are three algorithms that can do this, depending on the situation.

  • Unweighted graphs use BFS
  • Weighted graphs with no negative edges use Dijkstra’s algorithm
  • Weighted graphs with negative edges use the Bellman Ford algorithm.


  • Competitive Programming 4, section 4.4