https://github.com/thinkphp/node-dijkstra
Algorithm's Dijkstra Shortest Finder for NodeJS
https://github.com/thinkphp/node-dijkstra
Last synced: 3 months ago
JSON representation
Algorithm's Dijkstra Shortest Finder for NodeJS
- Host: GitHub
- URL: https://github.com/thinkphp/node-dijkstra
- Owner: thinkphp
- License: mit
- Created: 2014-09-10T20:08:49.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-13T08:06:51.000Z (over 11 years ago)
- Last Synced: 2025-02-06T17:43:53.616Z (12 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.org/package/dijkstra-edsger
- Size: 148 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-dijkstra
Dijkstra's algorithm, conceived by computer scientist Edsger Dijkstra, is a graph search algorithm that solves in single-source
shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree.

## Installation
```
$ npm install node-dijkstra
```
```
$ mkdir myApp
$ cd myApp
$ npm install dijkstra-edsger
$ touch app.js
```
## Sample Code
```
var Dijkstra = require('dijkstra-edsger');
var road = [[1, 2, 1],
[1, 3, 9],
[1, 5, 3],
[2, 4, 3],
[2, 3, 7],
[4, 3, 2],
[4, 1, 1],
[5, 2, 4],
[5, 4, 2]]
var start = 1,
end = 3;
var dij = new Dijkstra(start, end, road );
console.log("Cost = " + dij.getCost() )
console.log("Shortest path from the node "+ start + " to "+ end + " -> "+ dij.getShortestPath() )
```
## References
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
## License
MIT