Talk:Dijkstra's algorithm: Difference between revisions

Content added Content deleted
(Promotions? Not yet…)
Line 14: Line 14:


I've done some cleaning up of the Java example, making many of the problems in the code much less prominent. (For example, I've reduced the use of effectively-global variables and I've split the I/O from the algorithm.) More work is needed to finish transforming it from something that stank of old-skool [[C]], but it's a long way there. I've not really addressed any of the issues raised in the alertbox (e.g., the arbitrary node limit is still there — not that you'd want to have to type in the distance matrix for anything that large anyway) but they should now be much easier for someone else to address. –[[User:Dkf|Donal Fellows]] 03:22, 9 December 2011 (UTC)
I've done some cleaning up of the Java example, making many of the problems in the code much less prominent. (For example, I've reduced the use of effectively-global variables and I've split the I/O from the algorithm.) More work is needed to finish transforming it from something that stank of old-skool [[C]], but it's a long way there. I've not really addressed any of the issues raised in the alertbox (e.g., the arbitrary node limit is still there — not that you'd want to have to type in the distance matrix for anything that large anyway) but they should now be much easier for someone else to address. –[[User:Dkf|Donal Fellows]] 03:22, 9 December 2011 (UTC)

I think there may be a bug: The java one uses a TreeSet to maintain the unvisited set - but it is doing equality comparisons with compareTo, which is looking at the distance and not the identity of the node. So if two distinct nodes happen to have the same dist value at the same time, then either one could get removed from the unvisited set.


== Floyd–Warshall ==
== Floyd–Warshall ==