Graph
Graph implementation in JavaScript
Installation & Usage :
npm install js-graph-ds
const { Graph, WeightedGraph } = require("js-graph-ds"); //Graphlet graph = new Graph();graph.addVertex(vertex); // Adds vertex to the graphgraph.addEdge(vertex1, vertex2); //Adds edge between two vertexgraph.removeEdge(vertex1, vertex2); //Removes edge between two vertexgraph.removeVertex(vertex); //Removes vertex and all the edges which includes given vertexgraph.deapthFirstSearch(startVertex, endVertex); //Traverse the graph using depth first traversal and returns all the nodes which it visitsgraph.breadthFirstSearch(startVertex, endVertex); //Traverse the graph using breadth first traversal and returns all the nodes which it visits//Weighted Graphlet weightedGraph = new WeightedGraph();weightedGraph.addVertex(vertex); // Adds vertex to the graphweightedGraph.addEdge(vertex1, vertex2, weight); //Adds edge between two vertex with the given weightweightedGraph.sortestPath(vertex1, vertex2);//Returns sortest path between two nodes using Dijkstra's algorithm