Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphs-all

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphs-all

Graph Data Structure Library

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Graphs

This library contain an implementation of graph data structure with various method that can be useful in operations by graphs.

Graphs can directed and undirected, weighted and unweighted. So we have 4 variations and this library can works with them.

Install

npm install graphs-all

Getting Started

Import the library

var graphs = require("graphs-all");
var g = graphs.UndirectedUnweightedGraph();
g.addNode("A");
g.addLink("A", "B");
g.addLink("A", "C");
g.addLink("B", "C");
g.hasNode("C") // true
g.hasLink("B", "A") // true
g.removeLink("C", "A");
g.connectedWith("B") // ["A", "B"]

Create a graph

You can create four variations of graphs with shortcuts functions:

var simpleGraph = graphs.UndirectedUnweightedGraph(), 
    directedGraph = graphs.DirectedUnweightedGraph(),
    weightedGraph = graph.UndirectedWeightedGraph(),
    complexGraph = graph.DirectedWeightedGraph();

Or with Graph class:

new Graph(isDirected, isWeighted)

var simpleGraph = new graphs.Graph(false, false), 
    directedGraph = new graphs.Graph(true, false),
    weightedGraph = new graphs.Graph(false, true),
    complexGraph = new graphs.Graph(true, true);

Add nodes

Graph.addNode(nodeKey)

Add a node in the graph with key nodeKey. If node is exist already, then return false, for successive addition returns true.

simpleGraph.addNode("A")
simpleGraph.hasNode("B") // true
simpleGraph.hasNode("A") // false

Check nodes

Graph.hasNode(nodeKey)

Check is a node with key nodekey in the graph

simpleGraph.hasNode("A") // true
simpleGraph.hasNode("E") // false

#TODO

Keywords

FAQs

Package last updated on 29 Sep 2015

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc