Graphs and Paths
Tools for graphs representing 2-D spatial points and links between them.
Demo
View the demo.
Installation
npm install --save graphs-and-paths
API
View full documentation.
Sample Usage
import Graph from "graphs-and-paths";
const nodes = [
{ id: "A", location: { x: 0, y: 0 } },
{ id: "B", location: { x: 3, y: 0 } },
{ id: "C", location: { x: 0, y: 4 } }
];
const edges = [
{ id: "AB", startNodeId: "A", endNodeId: "B" },
{ id: "BC", startNodeId: "B", endNodeId: "C" },
{ id: "CA", startNodeId: "C", endNodeId: "A" }
];
const graph = Graph.create(nodes, edges);
graph.getNode("A");
graph.getLocation("AB", 2);
graph.getShortestPath(
{ edgeId: "CA", distance: 3 },
{ edgeId: "BC", distance: 1 }
).locations;
Many more methods are available.
View full documentation for details.
Copyright © 2016 David Philipson