Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/connected-components
Find all connected components in an undirected graph
https://github.com/mikolalysenko/connected-components
Last synced: about 2 months ago
JSON representation
Find all connected components in an undirected graph
- Host: GitHub
- URL: https://github.com/mikolalysenko/connected-components
- Owner: mikolalysenko
- License: mit
- Created: 2014-04-21T06:17:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-29T01:19:06.000Z (over 10 years ago)
- Last Synced: 2024-10-19T00:19:16.023Z (2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
connected-components
====================
Enumerate all connected components in an undirected graph.# Example
```javascript
var cc = require("connected-components")var adjList = [
[],
[2],
[1],
[4, 5],
[3],
[3]
]console.log(cc(adjList))
```Output:
```javascript
[ [0], [1, 2], [3, 4, 5] ]
```# Install
```
npm install connected-components
```# API
#### `require("connected-components")(adjacencyList)`
Returns a list of connected components for the given graph.* `adjacencyList` is an adjacency list representation of a graph
**Returns** A list of connected components in the graph
# Credits
(c) 2014 Mikola Lysenko. MIT License