Why Shortest path code not calculating distance to node 6?

I have tried code for using Dijkstra's shortest path alg:

https://codepad.remoteinterview.io/DOSZEXAGJM

It seems to work (does with at least with the test graphs I have made so far I mean) if all edges are bidirectional, both listed in test file, but as soon as I make the 6->3 node edge one way it does not give a min distance for 6 even though there is still a pat through 7 to node 6.

Graph and the edges as in the test file, and output from console:

https://i.imgur.com/45f1Nu1.png

I was following the pseudocode here:

https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode

and as far as I can tell I'm doing everything the same and can't figure out what is wrong. This is supposed to work with directed graphs also, correct?
> Graph and the edges as in the test file
¿why do you even consider to post plain text as an image?


you never update the priority queue
I guess because it was late and I was tired and for some reason just putting it there right next to the graph it described seemed like a good idea. :/

Oh. The priority queue DISTANCES. Those don't get... ok.

Thank you so much.
Last edited on
Topic archived. No new replies allowed.