two common operations vertex initialisation and relax
vertex initialisation -> set key of each vertex to max value; set precedence to null; set key of s (start vertex) to 0;
relax(u,v,w) -> set key of vertex v to lower value u.key + w(u,v) if any. If yes, set v.precedence to u
- Bellman-Ford, O(VE)
- take n-1 rounds of relaxes of each edge.
- can be used to detect negative weight loop which doesn't has shorted path
- topological sort for PERT (Program Execute and Review Technique), O(V + E)
- sort vertices in topological order
- for each vertex, relax on its all adjacent vertices.
- find key path of PERT
- Dijkstra, O((V + E)lgv), only for non-negative weight graph
- sort vertex in non-decreasing order on key of vertex (put vertices in priority queue)
- take vertex from the queue and relax on its all adjacent vertices. order is updated in the queue.
- shortest path on directed graph for System of Difference Constraints
- constraints, xj-xi <= w. (i,j belong to V), the number of constraints should exceed |V|
- n = |V|, is number of vertices for xi.
- w is weight of edge (vi, vj)
- add one more node v0 and edges (v0, vi) with weight of 0
- shortest path (v0, v1), (v0, v2)... is solution of xi.