Given a source node and a weighted graph, returns the shortest path from the source to all the other vertices in the given graph, where the graph can contain negative weights. It solves the single source shortest path with negative weights problem.

Restrictions

  • must be a weighted graph
  • must not contain a negative weight cycle
    • however, the Bellman-Ford algorithm can detect if it does contain one!
    • minimum distance does not make sense in graphs with negative weight cycles, as one could traverse the cycle an infinite amount of times, and there would be no lower bound on the weight

Abstract

Efficiency

  • Time complexity:

Implementation

Proof

Let represent the shortest distance from node to node that the algorithm has found so far. Let represent the actual shortest distance from node to node . Let be the statement that Bellman-Ford gives the correct shortest path for a graph with nodes, given no negative cycles. Let be starting node.

Prove

Let there be a graph with only node .

Assume

Prove

Proof for ability to find negative cycle