Nosey Party Murderer

# npm

## js-graph-algorithms

1.0.18 • Public • Published

# js-graph-algorithms

Package provides javascript implementation of algorithms for graph processing

# Features

• Depth First Search (Link: HTML DEMO)
• Connected Components for undirected graph (Link: HTML DEMO)
• Topoloical Sort (Link: HTML DEMO)
• Strongly Connected Components for directed graph (Link: HTML DEMO)
• Minimum Spanning Tree for weighted graph (Kruskal, Prim Lazy, Prim Eager) (Link: HTML DEMO)
• Shortest Paths (Dijkstra, Bellman-Ford, Topological Sort on DAG) (Link: HTML DEMO)
• MaxFlow-MinCut (Ford-Fulkerson) (Link: HTML DEMO)

# Usage

### Create an undirected unweighted graph

The sample code below shows how to create a undirected and unweighted graph (Link: HTML DEMO):

### Create directed unweighted graph

The sample code below shows how to create a direted and unweighted graph (Link: HTML DEMO):

### Create undirected weighted graph

The sample code below shows show to create undirected weighted graph (Link: HTML DEMO):

### Create directed weighted graph

The sample code below shows show to create directed weighted graph (Link: HTML DEMO):

### Depth First Search

The sample code below show how to perform depth first search of an undirected graph (Link: HTML DEMO):

### Connected Components

The sample code below show how to obtain the number of connected components in an undirected graph (Link: HTML DEMO):

### Topological Sort

The sample code below show how to obtain the reverse post order of a topological sort in a directed acyclic graph (Link: HTML DEMO):

### Strongly Connected Components for Directed Graph

The sample code below show how to obtain the strongly connected components from a directed graph (Link: HTML DEMO):

### Use Kruskal algorithm to find the minimum spanning tree of a weighted graph

The sample code below show how to obtain the minimum spanning tree from a weighted graph using Kruskal algorithm (Link: HTML DEMO):

### Use Lazy Prim algorithm to find the minimum spanning tree of a weighted graph

The sample code below show how to obtain the minimum spanning tree from a weighted graph using Lazy Prim algorithm (Link: HTML DEMO):

### Use Eager Prim algorithm to find the minimum spanning tree of a weighted graph

The sample code below show how to obtain the minimum spanning tree from a weighted graph using Eager Prim algorithm (Link: HTML DEMO):

### Find the shortest paths using Dijkstra

The sample code below show how to obtain the shortest paths from a starting point 0 on a weighted directed graph using Dijkstra (Link: HTML DEMO):

### Find the shortest paths using Bellman-Ford

The sample code below show how to obtain the shortest paths from a starting point 0 on a weighted directed graph using Bellman-Ford:

### Find the shortest paths using Topological Sort Shortest Paths

The sample code below show how to obtain the shortest paths from a starting point 0 on a weighted directed acylic graph using Topological Sort:

### Find the MaxFlow-MinCut using Ford-Fulkerson algorithm

The sample code below show how to obtain the MaxFlow-MinCut of a directed weighted graph using ford-fulkerson algorithm (Link: HTML DEMO):

### Install

`npm i js-graph-algorithms`

### Repository

github.com/chen0040/js-graph-algorithms

19,542

1.0.18