Johnsons Algorithm
Johnsons Algorithm
1. Find function h : V -→ R
such that
wh(u,v) = w(u,v) + h(u) – h(v)
>= 0
∀ (u,v) belongs to V
(we do this, so we can use
Dijkstra’s algorithm instead of
Bellman-Ford)
Proof by Contradiction
The claim is that the sum of these
weights is negative.
w(u,v)+h(u)-h(v) >= 0
When we are done all of the
w(u,v)+δ(S,u)-δ(S,v) >= 0 weights will be non-negative
because we had triangle inequality.
δ(S,v) <= δ(S,u)+w(u,v)
And now we can run Dijkstra’s
Algorithm from every vertex.
This is triangle inequality.
We run Bellman-Ford once,
because we know it handles
So, of course we want to compute
negative weights. It also tells us if
shortest paths, because shortest
there are any negative weight
path satisfy triangle inequality.
cycles. That’s why we want this
The whole name of the game in theorm.
shortest path is to find a place
where you do not satisfy triangle
inequality and fix it.
Otherwise, when there is no sma-5503-fall-2005/video-
negative weight cycles, them lectures/lecture-19-shortest-
Bellman-Ford finds valid h. paths-iii-all-pairs-shortest-
paths-matrix-multiplication-
floyd-warshall-johnson/
Then we plug that ‘’h’’ here.
4. https://en.wikipedia.org/wiki/J
ohnson%27s_algorithm
Then we have non negative 5. https://www.javatpoint.com/jo
weights. So in VE time, we have hnsons-algorithm
reduced to the non-negative all pair 6. http://citc.ui.ac.ir/zamani/clrs.
shortest paths. And then, we run pdf
Dijkstra’s Algorithm V times. 7. https://brilliant.org/wiki/johns
ons-algorithm/
8. Introduction to Algorithms 3rd
Then we got almost our answer but Edition by Clifford Stein,
we have to modify them to get back Thomas H. Cormen, Charles
the correct weights on our shortest E. Leiserson, Ronald L.
paths. Rivest
9. https://iq.opengenus.org/johns
on-algorithm/
REFERENCES: 10. https://www.youtube.co
m/watch?v=hLEgT-2t8Ag
11. https://www.youtube.co
1. https://ocw.mit.edu/courses/el m/watch?v=FtN3BYH2Zes
ectrical-engineering-and- 12. https://www.youtube.co
computer-science/6-006- m/watch?v=XB4MIexjvY0
introduction-to-algorithms-fall- 13. Cormen, Thomas H.;
2011/lecture-videos/lecture- Leiserson, Charles E.;
16-dijkstra/ Rivest, Ronald L.; Stein,
2. https://www.youtube.com/wat Clifford (2001), Introduction
ch?v=Sygq1e0xWnM to Algorithms, MIT Press and
McGraw-Hill, ISBN 978-0-
3. https://ocw.mit.edu/courses/el
262-03293-3 . Section 25.3,
ectrical-engineering-and-
"Johnson's algorithm.
computer-science/6-046j-
introduction-to-algorithms-