Talk:Dijkstra's algorithm: Difference between revisions

No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 265:
The line:
 
int i = h->index[v] || ++h->len;
 
Does not evaluate correctly the expression. If h->index[v] == 0 then ++h->len is not assigned to i, instead 1 is assigned. In theory the compiler should assign the right side expression to i but is not working with gcc. For example, the graph:
Line 286:
Will output '5 agde' and is wrong because path '4 abcde' is shorter. Next line fixes the problem:
 
int i = h->index[v] ? h->index[v] : ++h->len;
 
 
== Directed vs undirected graphs ==
Line 311 ⟶ 310:
 
Must specify explicitly that the python snippet solution should be at least in python 2.7 due to the dictionary comprehension feature used. And also, must replace the 'pushleft' with 'appendleft'.
 
Updated 'queue' to 'deque' and re-updated 'pushleft' to 'appendleft' and tested running in python 2.7 and python 3.5 on 1/19/2017
 
== Javascript version ==
Line 372 ⟶ 373:
return path.length > 0 ? path : null;
}
 
== Perl version faulty ==
 
The push_priority() function of the perl implementation is faulty. This can most clearly be seen by adding an edge from 'b' to 'e' of weight 1 making s-b-e the shortest path. Yet this new path is not picked up. The vertices appears to be dequeued from the function in their inserted order, rather than by priority. In the function the binary search comparison appears to be comparing hash addresses.
 
:Fixed. [[User:Trizen|Trizen]] ([[User talk:Trizen|talk]])
Anonymous user