Talk:Dijkstra's algorithm

This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 00:19, 26 May 2023 (Archiving 2 discussion(s) to Talk:Dijkstra's algorithm/Archive 2) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 2 years ago by Indicere in topic Proof of correctness is incomprehensible

Is there a typo in the "Invariant hyphothesis" sentence?

It says: "This assumption is only considered if a path not exists," but should it be "This assumption is only considered if a path exists," ?

Pseudocode improvement

In first pseudocode block, on line 15, dist[u] is checked for not being INFINITY. But if it is INFINITY at this point, the code will continue useless looping, because all remaining vertices will also have dist[u]=INFINITY and not influence the result. Maybe move the INFINITY check to line 11 and break out of while block, it would be more human readable too I think --Shrddr (talk) 20:44, 20 August 2022 (UTC)Reply

We should stick to sources rather than commit WP:OR. CLRS has

DIJKSTRA(G, w, s)                 // Graph G, weights w, source vertex s
1 INITIALIZE-SINGLE-SOURCE(G, s)  // lines 3-5 of our algorithm
2 S = 0                           // empty set
3 Q = G.V                         // line 6
4 while Q non empty
5     u = EXTRACT-MIN(Q)          // line 10, 11
6     S = S union {u}
7     for each vertex  v in G:Adj(u)  // slightly different to ours
8        RELAX(u,v,w)

where RELAX is

RELAX(u, v, w)
1    if v.dist > u.dist + w(u, v)
2        v.dist = u.dist + w(u, v)
3        v.prev = u

There is nothing in this algorithm with a test of u.dist being infinity. So I think its safe to remove the condition entirely. --Salix alba (talk): 10:44, 21 August 2022 (UTC)Reply

The text before pseudocode box ends with reference to https://doi.org/10.1007%2F978-3-540-77978-0 which does mention infinity check (see "algorithm" at page 197). But then for some reason it's left out in "pseudocode" at page 198. Shrddr (talk) 12:51, 21 August 2022 (UTC)Reply

Pseudocode is wrong

The pseudocode that uses a priority queue is plain wrong, it produces garbage. I used this instead and can confirm it works okay: https://stackabuse.com/courses/graphs-in-python-theory-and-implementation/lessons/dijkstras-algorithm/ WhyYouAskMe (talk) 11:25, 4 September 2022 (UTC)Reply

Distracting animation

This article contains an infinitely looping animation which is placed right next to the text, and cannot be stopped. This is extremely distracting while reading, and can be a significant problem for some readers. I strongly suggest changing this so that the animation would only run on demand. BarroColorado (talk) 11:33, 22 September 2022 (UTC)Reply

Proof of correctness is incomprehensible

This section is full of grammar issues that make it very difficult to understand. Maybe it should be rewritten. Indicere (talk) 03:10, 28 January 2023 (UTC)Reply