dijkstrajs
dijkstrajs copied to clipboard
Implement priority queue with min-heap
I adopted the priority queue implementation with a min-heap data structure for better performance. I write the code in ES5 for backward compatibility with the previous version and for being upgradable.
The previous current version is using queue.sort()
for insertion with complexity of n*log(n)
. With min-heap, the complexity will be log(n)
.