Socket
Socket
Sign inDemoInstall

tiny-graph

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tiny-graph

Tiny graph data structure for Client or Server


Version published
Weekly downloads
9
decreased by-35.71%
Maintainers
1
Install size
13.0 kB
Created
Weekly downloads
 

Readme

Source

tiny-graph

build status

Tiny graph data structure for Client or Server

Example

const graph = require('tiny-graph'),
    g = graph();

g.setNodeValue('f', 3);
g.setNodeValue('h', 21);
g.add('f', 'h');
g.setEdgeValue('f', 'h', 100);

console.log(g.adjacent('f', 'h')); // true
console.log(g.neighbors('f')); // ['h']
console.log(g.getEdgeValue('f', 'h')); // 100

How can I use tiny-graph?

tiny-graph can be installed from npm & bower, and supports AMD loaders or script tags (window.graph).

API

add(x, y)

Adds the edge from x to y, if it is not there

adjacent(x, y)

Tests whether there is an edge from node x to node y

del(x, y)

Removes the edge from x to y, if it is there

delNode(x)

Removes node x from the graph, if it is there

fromJSON(arg)

Deserializes arg as the graph

getEdgeValue(x, y)

Returns the value associated to the edge (x, y)

getNodeValue(x)

Returns the value associated with the node x

neighbors(x)

Lists all nodes y such that there is an edge from x to y

setEdgeValue(x, y, v)

Sets the value associated to the edge (x, y) to v

setNodeValue(x, v)

Sets the value associated with the node x to v

toJSON()

Serializes the graph as JSON

License

Copyright (c) 2018 Jason Mulligan Licensed under the BSD-3 license

Keywords

FAQs

Last updated on 05 May 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc