previous | start | next

Optimality Conditions

A necessary and sufficient condition for distTo[u] to be the shortest distance from s to u for every vertex u is

For every vertex v and every edge e

 distTo[w] <= distTo[v] + e.weight()   (where v = e.from() and w = e.to())
   


previous | start | next