The final step calls for encoding pixel similarity information in edge weights, so that the original image is no longer needed.
In the simplest case, edge weights are computed as the difference of pixel intensities.
Go through E in decreasing order of edge weights.
Dijkstra's algorithm fails if there is a negative edge weight.
In order to use the algorithm, we must assume that all edge weights are positive.
Thus, Bellman-Ford is usually used only when there are negative edge weights.
Given the fixed policy, the edge weights are determined by corresponding states' transition probability.
It allows some of the edge weights to be negative numbers, but no negative-weight cycles may exist.
Put otherwise, the edge weights satisfy the triangle inequality.
A common model is as follows: Given a graph with non-negative edge weights.