Dijkstra’s Algorithm JavaScript.
Before working with this class you need to download this class that I've found here
https://github.com/lu1s/Directed-Graph/blob/master/DirectedGraph.js
The way you use it is as follows :
var Djik = new Djikstra(graph, "A");
var path = [];
path = Djik.bestPath("A","Q");