In Dijkstra's shortest path algorithm and others, to examine an edge to see if it offers a better path to a node is referred to as relaxing the edge. Why is it called relaxing?
2 Answers
In general mathematically, relaxation is making a change that reduces constraints. When the Dijkstra algorithm examines an edge, it removes an edge from the pool, thereby reducing the number of constraints.
It's not horribly useful terminology, but think how cool you'll sound saying it.

- 110,348
- 25
- 193
- 263
-
1Could you clarify how the edges in the pool can be seen as constraints? – Eric G May 25 '12 at 00:32
-
2Think about a vertex with a lot of edges coming into it. When you start, you hnow the solution has to include teh weight from the first edge, the second edge, and so on. In effect, for edges a,b,c,d and e, you start saying "the shortest path must include a,b,c,d,e". Then you eliminate e, and now you know is must include just "a,b,c,d". Each step is a *relaxation* because at each step you remove a condition the current solution imposes. – Charlie Martin May 25 '12 at 06:51
-
I guess it is not `coming into it` but `leaving it`? – Jackson Tale Feb 08 '15 at 21:30
-
They're dual, Jackson. It could even be an undirected graph. The point is that relaxation is always removing a constraint. – Charlie Martin Feb 08 '15 at 21:33
-
In some shortest path algorithms relaxation either does not remove the edge from the pool, or removes it while simultaneously adding other edges. So i am not convinced by your explanation. I've heard that *relaxation* is a term from Operations Research, and I've seen [Lagrangian relaxation](https://en.wikipedia.org/wiki/Lagrangian_relaxation) mentioned in the context, but i do not see why edge relaxation in Dijkstra's algorithm would be Lagrangian relaxation. – Alexey Feb 12 '20 at 16:58
-
Well, Google is your friend. https://towardsdatascience.com/algorithm-shortest-paths-1d8fa3f50769 – Charlie Martin Feb 14 '20 at 19:36
I do not think the question is related to the mathematical concept talked about in the current accepted answer. I am basing my answer on the second edition of Cormen's (CLRS) book, specifically on chapter 24 in a section about relaxation.
Context: You are searching for the shortest path between a node s and all the other nodes. Imagine you have two nodes u and v. You already have an intermediate path for them.
relax(u,v) is a function that should be read as "relax v using u". I prefer to understand the function as "shorten v's distance to s using u". You are asking yourself if you should give up on your current path s-v in favor of transforming it into s-u-v. All you have to do to see if the distance of s-u plus the additional cost of the arrow u-v are better than the distance s-v. The picture examplifies the function

- 291
- 2
- 7
-
It's correct. See, eg, https://en.wikipedia.org/wiki/Linear_programming_relaxation https://www.quora.com/What-is-relaxation-in-mathematics https://en.wikipedia.org/wiki/Relaxation_(approximation) – Charlie Martin Dec 17 '18 at 22:14
-
Cormen's book (3rd edition) specifically says in a footnote in Chapter 24 that "relaxation step can be viewed as a relaxation of the constraint." So, they do claim it is about the mathematical concept of relaxing constraints. However, i could not yet find any clear explanation of this. – Alexey Feb 12 '20 at 17:04