Simple implementation of Dijkstra using heap in Go.
What is Dijkstra?
MEGA SHORT DESCRIPTION: Dijkstra's algorithm to find ...
For further actions, you may consider blocking this person and/or reporting abuse
I don't see the definition of
wasVisited. However, it seems like you should use amap[string]boolinstead of[]stringfor yourvisitedset so that you don't have to walk over the list.If you're walking over the list of visited nodes for every edge, your implementation runs in time proportional to $O(|V|*|E|)$! (which defeats the point of using a heap)
You can also simplify your
getPathimplementation. There's no reason to treat the source node specially. You can instead initialize thevisitedset to empty and the heap with just the source, to be visited first. (Notice how the beginning of the function duplicates the contents of the loop!)for this reason I love to share because is good for me, to improve and learn, at the moment that I wrote the code I was focus in other things and ignore other, thanks master you are 1000% right. <3
Checkout this algorithm using min priority queue, please follow me on medium if u like
medium.com/@rishabhmishra131/golan...
this is still over my head :(