batgirl

Better Approach To Getting Interconnected Relation Lists


Keywords
graph, routing, connection, distance, small, world, six, degrees, shortest, path
License
Unlicense
Install
npm install batgirl@0.0.6

Documentation

Better Approach To Getting Interconnected Relation Lists

Find the shortest path(s) in a network of nodes. Somewhat inspired by Batman.

Install

npm install batgirl

API

batgirl(edges);

Create an instance of batgirl. edges is an array containing edges defined as pairs of nodes:

[
	[nodeid, nodeid], // edge
	[nodeid, nodeid],
	...
]

batgirl.find(a, b, function(err, result){})

Find all shortest paths between nodes a and b. result is a (possibly empty) array containing lists of nodes.

batgirl.add(a, b, function(err){})

Add edge with nodes a and b.

batgirl.remove(a, b, function(err){})

Remove edge with nodes a and b.

Example

var batgirl = require("batgirl");

batgirl([[1,2],[1,3],[3,4],[2,5],[6,7],[1,9],[9,5]]).find(1,5, console.log);