Talk:Dijkstra's algorithm

This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 00:17, 31 December 2020 (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: 4 years ago by Enervation in topic Dubious

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," ?

Practical optimizations and infinite graphs

The pseudocode is a sort of Breadth-First Search, not Uniform-Cost Search, as it does not consider edge weight.Elias (talk) 10:49, 9 January 2020 (UTC)Reply

GIF is confusing

The gif of Dijkstra's implementation gives irrelevant information which is misleading and confusing - the values inside the nodes are pointless and contribute nothing to the understanding of the algorithm, while the excessive amount of information is confusing. A new gif with no values inside the nodes should be created. — Preceding unsigned comment added by 2A02:ED0:33B2:6C00:F5D1:308E:202D:179C (talk) 09:14, 10 September 2020 (UTC)Reply

Dubious

In the section "Using a priority queue", we have:

Yet another alternative is to add nodes unconditionally to the priority queue and to instead check after extraction that no shorter connection was found yet. This can be done by additionally extracting the associated priority p from the queue and only processing further if p ≤ dist[u] inside the while Q is not empty loop.

https://cs.stackexchange.com/a/118406/ thinks that this is mistaken and should be replaced with p = dist[u]. Ryoji writes (CC-BY SA 4.0):

You are right. Checking k < d[u] is not sufficient and updating d[u] on the next line is not necessary.
The check prevents proceeding when the source is picked up from the queue (then k = 0 and d[s] = 0). Also, d[u] (u is fixed) is monotonically decreasing as loop proceeds, so even though it is updated after (u, d[u]) is put on the queue, k >= d[u] holds when (u,k) is picked up from the queue. Moreover, if d[u] is strictly smaller than k , the element should simply be ignored since it cannot be the shortest path to u.
You can change the condition to k == d[u] and remove following update to d[u].

Should we replace the condition with k == d[u]? —Enervation (talk) 16:44, 30 December 2020 (UTC)Reply