Chapter: 42 Dijkstra Algo

As in Book we have OR check in Dikstra Algo, while creating hash of preferred edges and we are not maintaining VISITED NODE, So i guess this will work even for negative weights also. Downside is that it will loop over all the edges of each vertex as here we are not check for visited node.

I think we should track visited vertex also. Else for a single negaive cycle program is going in a loop.

if paths[edge.destination] == nil ||
       distance(to: vertex, with: paths) + weight <
       distance(to: edge.destination, with: paths)