🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

directed-graph

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directed-graph

node package for weighted directed graphs

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
24
-72.73%
Maintainers
1
Weekly downloads
 
Created
Source

directed-graph

node package for weighted directed graphs

###Installation

npm install directed-graph --save

##Quickstart

var Graph = require('directed-graph');

// Either initialize and fill an empty graph
var graphA = new Graph();
graphA.addVertex('A');
graphA.addVertex('B');
graphA.addVertex('C');
graphA.addEdge('A', 'B');
graphA.addEdge('A', 'C');
graphA.addEdge('B', 'A');
graphA.addEdge('B', 'C');
graphA.addEdge('C', 'A');
graphA.addEdge('C', 'B');

// Or predefine a new graph
var graphB = new Graph({
  'A': ['B', 'C'],
  'B': ['A', 'C'],
  'C': ['A', 'B'],
});

// Both graphA and graphB function the same
graphA.setWeight('A', 'B', 10);
graphA.setWeight('B', 'A', 10);
graphA.addVertex('D');
graphA.addEdge('A', 'D');
console.log(graphA.pathExists('B', 'D'));

##Running Tests Make sure to have mocha installed: npm install -g mocha

In project root directory, run: mocha test

Keywords

directed

FAQs

Package last updated on 14 Dec 2014

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