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

graphlib

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphlib

A directed multi-graph library

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-6.96%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 24 Aug 2013

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