Find all connected components in an undirected graph
MIT License
Enumerate all connected components in an undirected graph.
var cc = require("connected-components")
var adjList = [
[],
[2],
[1],
[4, 5],
[3],
[3]
]
console.log(cc(adjList))
Output:
[ [0], [1, 2], [3, 4, 5] ]
npm install connected-components
require("connected-components")(adjacencyList)
Returns a list of connected components for the given graph.
adjacencyList
is an adjacency list representation of a graphReturns A list of connected components in the graph
(c) 2014 Mikola Lysenko. MIT License