JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q50407F
  • License MPL-2.0

a generic directed graph implementation

Package Exports

  • generic-digraph

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (generic-digraph) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

This is a generic directional graph implementation

USAGE

const Digraph = require('generic-digraph')

// to start with the graph is just a single vertex
var vertex = new Digraph()

// now lets add an edge to the vertex named "bob" that points to another vertex with the value "alice"
vertex.set('friend', 'alice')

// if paths have more than one name in them they can arrays
vertex.set(['friend', 'brother'], 'bob')
//now the graph looks like:
// [vertex]---friend--->[alice]---brother-->[bob]

//path names and vertex values can be anything
vertex.set([new Buffer('friend'), 5, false, {}, new Date()], Array())

// edges are stored in a Map
vertex.edges // Map{}

//you can iterate the graph to get all of its vertices
var vertices = [...vertex]

//you can also iterate a path
vertices = [...vertex.iterPath(['friend', 'brother'])]

//getting a vertex works like setting
var friendsBotherVertex = vertex.get(['friend', 'brother'])
friendsBotherVertex.value //"bob"

// delete an edge
vertex.delete('friend')
//now the vertex is empty
vertex.isEmpty()

API

./docs/

LICENSE

MPL-2.0