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

namastey-adjacency-matrix

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-adjacency-matrix

A JavaScript package implementing the Adjacency Matrix data structure for efficient graph representation and operations.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

namastey-adjacency-matrix

Brief Description

namastey-adjacency-matrix is a JavaScript package that implements an adjacency matrix data structure. It provides methods for adding, removing, and checking edges, as well as retrieving and printing the matrix.

Features

  • addEdge(node1, node2): Adds an edge between two nodes. This method updates the matrix to reflect a connection between the nodes.
  • removeEdge(node1, node2): Removes an edge between two nodes. This method updates the matrix to remove the connection between the nodes.
  • hasEdge(node1, node2): Checks if there is an edge between two nodes. Returns true if an edge exists, otherwise false.
  • getMatrix(): Returns the adjacency matrix as a 2D array.
  • printMatrix(): Prints the adjacency matrix to the console.

Installation

To install namastey-adjacency-matrix, run:

npm install -g namastey-adjacency-matrix

Examples

const AdjacencyMatrix = require('namastey-adjacency-matrix');

// Create a new adjacency matrix with 4 nodes
const graph = new AdjacencyMatrix(4);

// Add edges
graph.addEdge(0, 1);
graph.addEdge(1, 2);

// Check if an edge exists
console.log(graph.hasEdge(0, 1)); // Output: true
console.log(graph.hasEdge(0, 2)); // Output: false

// Print the matrix
graph.printMatrix();

// Get the matrix
console.log(graph.getMatrix());

Keywords

FAQs

Package last updated on 27 Aug 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