Finding shortest / cheapest paths in a dense graph
graph-paths is a small module for finding cheapest (shortest) paths in a dense graph (network).
$ npm install graph-paths
var cheapest_paths = require'graph-paths'cheapest_paths;/** The network is defined by a matrix describing the cost of getting from node i to node j.* If there is no way from node i to node j, then the cost is infinite.*/var costs =01720Infinity0419InfinityInfinity07InfinityInfinityInfinity0;var cheapest_paths_from_0 = cheapest_pathscosts 0;console.log"cheapest paths from node #0 to all other nodes:";consoledircheapest_paths_from_0;console.log"cheapest path from node #0 to node #3:";consoledircheapest_paths_from_03path;