Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graph-paths

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-paths

Finding shortest / cheapest paths in a dense graph

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

graph-paths is a small module for finding cheapest (shortest) paths in a dense graph (network).

Installation

$ npm install graph-paths

Example

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 = [
    [0,1,7,20],
    [Infinity,0,4,19],
    [Infinity,Infinity,0,7],
    [Infinity,Infinity,Infinity,0],
];

var cheapest_paths_from_0 = cheapest_paths(costs, 0);
console.log("cheapest paths from node #0 to all other nodes:");
console.dir(cheapest_paths_from_0); 

console.log("cheapest path from node #0 to node #3:");
console.dir(cheapest_paths_from_0[3].path); 

Keywords

FAQs

Package last updated on 28 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc