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

namastey-undirected-graph

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

namastey-undirected-graph

A JavaScript package that implements the Undirected Graph data structure with various important methods.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

namastey-undirected-graph

Brief Description

namastey-undirected-graph is a JavaScript package that provides an implementation of an undirected graph data structure. It supports various methods for manipulating and querying the graph.

Features

  • addVertex(vertex): Adds a new vertex to the graph. If the vertex already exists, it does nothing.
  • addEdge(vertex1, vertex2): Adds an undirected edge between vertex1 and vertex2. Creates vertices if they do not exist.
  • removeVertex(vertex): Removes a vertex and all its edges from the graph.
  • removeEdge(vertex1, vertex2): Removes the undirected edge between vertex1 and vertex2.
  • hasEdge(vertex1, vertex2): Checks if an edge exists between vertex1 and vertex2.
  • printGraph(): Prints the adjacency list representation of the graph.

Installations

You can install namastey-undirected-graph globally using npm:

npm install -g namastey-undirected-graph

Examples

const Graph = require('namastey-undirected-graph');

const graph = new Graph();

graph.addVertex('A');
graph.addVertex('B');
graph.addEdge('A', 'B');
graph.printGraph(); // Output: A -> B\nB -> A

console.log(graph.hasEdge('A', 'B')); // Output: true

graph.removeEdge('A', 'B');
console.log(graph.hasEdge('A', 'B')); // Output: false

graph.removeVertex('A');
graph.printGraph(); // Output: B -> null

Keywords

FAQs

Package last updated on 06 Sep 2024

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