Relaxation of an edge in Dijkstra's algorithm

Here's a nice description of the Algorithm that also explains the notion of relaxation.

The notion of "relaxation" comes from an analogy between the estimate of the shortest path and the length of a helical tension spring, which is not designed for compression. Initially, the cost of the shortest path is an overestimate, likened to a stretched out spring. As shorter paths are found, the estimated cost is lowered, and the spring is relaxed. Eventually, the shortest path, if one exists, is found and the spring has been relaxed to its resting length.


The relaxation process in Dijkstra's algorithm refers to updating the cost of all vertices connected to a vertex v, if those costs would be improved by including the path via v.


Relaxing an edge, (a concept you can find in other shortest-path algorithms as well) is trying to lower the cost of getting to a vertex by using another vertex.

You are calculating the distances from a beginning vertex, say S, to all the other vertices. At some point, you have intermediate results -- current estimates. The relaxation is the process where you check, for some vertices u and v:

if directly_connected(v, u)
    if est(S, v) > est(S, u) + dist(u,v)
       est(S, v) = est(S, u) + dist(u, v)

where est(S,a) is the current estimate of the distance, and dist(a,b) is the distance between two vertices that are neighbors in the graph.

What you are basically checking in the relaxation process is weather your current estimate from a to b could be improved by "diverting" the path through c (this "diversion" would be the length of a path from a to c and from c to b).