implementation of shortest path algo incorporated with javacript