npm.io
1.0.1 • Published 8 years ago

thegraph.io

Licence
MIT
Version
1.0.1
Deps
0
Size
14 kB
Vulns
0
Weekly
0

theGraph.io

A simple, minimalistic, no-nonsense graph library for Node.js.

Installation

  npm install thegraph.io

Usage

const Graph = require('thegraph.io');
var graph = new Graph();

// Add vertices.
graph.addVertices(['a', 'b', 'c', 'd']);

// Add vertices with associated objects.
graph.addVertex('f', {type: 'Character'});

// Add edges between nodes.
graph.addEdge('a', 'b');

// Edges an have associated objects (e.g. weight)
graph.addEdge('b', 'c', {weight: 20});

graph.addEdge('c', 'd', {relationship: 'Consecutive'});

// Find shortest path between nodes.
var path = graph.getShortestPath('a', 'd');

Made with & from

Keywords