Dijkstra - finding path in HTML 5 Canvas