You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

graphlib

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphlib

A directed and undirected multi-graph library


Version published
Maintainers
2
Created

Package description

What is graphlib?

The graphlib package is a JavaScript library for creating and manipulating directed and undirected graphs. It provides a variety of methods for graph creation, traversal, and analysis, making it a versatile tool for working with graph data structures.

What are graphlib's main functionalities?

Graph Creation

This feature allows you to create a new graph, add nodes, and create edges between nodes. The code sample demonstrates how to create a graph, add two nodes 'a' and 'b', and create an edge from 'a' to 'b'.

const graphlib = require('graphlib');
const g = new graphlib.Graph();
g.setNode('a');
g.setNode('b');
g.setEdge('a', 'b');
console.log(g.nodes()); // ['a', 'b']
console.log(g.edges()); // [{ v: 'a', w: 'b' }]

Graph Traversal

This feature allows you to traverse the graph using depth-first search (DFS). The code sample demonstrates how to perform a DFS starting from node 'a' and prints the traversal order.

const graphlib = require('graphlib');
const g = new graphlib.Graph();
g.setNode('a');
g.setNode('b');
g.setNode('c');
g.setEdge('a', 'b');
g.setEdge('b', 'c');
const dfs = graphlib.alg.dfs(g, ['a']);
console.log(dfs); // [{ v: 'a' }, { v: 'b' }, { v: 'c' }]

Graph Analysis

This feature allows you to analyze the graph for properties such as acyclicity. The code sample demonstrates how to check if the graph contains cycles and prints the result.

const graphlib = require('graphlib');
const g = new graphlib.Graph();
g.setNode('a');
g.setNode('b');
g.setNode('c');
g.setEdge('a', 'b');
g.setEdge('b', 'c');
g.setEdge('c', 'a');
const isAcyclic = graphlib.alg.isAcyclic(g);
console.log(isAcyclic); // false

Other packages similar to graphlib

Readme

Source

Graphlib

Graphlib is a JavaScript library that provides data structures for undirected and directed multi-graphs along with algorithms that can be used with them.

Build Status

To learn more see our Wiki.

License

Graphlib is licensed under the terms of the MIT License. See the LICENSE file for details.

Keywords

FAQs

Package last updated on 03 Dec 2019

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc