function bellman_ford(graph, start):

   distance = {v: infinity for v in graph}
   distance[start] = 0
   for i from 1 to length(graph) - 1: # relax all edges V-1 times
      for u, v, weight in edges(graph):
        if distance[u] + weight < distance[v]:
           distance[v] = distance[u] + weight

   for u, v, weight in edges(graph): # one more pass detects proble
 ms
      if distance[u] + weight < distance[v]:
        report an unsupported case # negative-weight cycle
   return distance                # unlike Dijkstra, handles neg
 ative weights
