Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/strongly-connected-components
Computes the strongly connected components of a directed graph
https://github.com/mikolalysenko/strongly-connected-components
Last synced: about 2 months ago
JSON representation
Computes the strongly connected components of a directed graph
- Host: GitHub
- URL: https://github.com/mikolalysenko/strongly-connected-components
- Owner: mikolalysenko
- License: mit
- Created: 2013-10-31T14:22:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-04-28T02:21:12.000Z (over 8 years ago)
- Last Synced: 2024-10-20T14:27:14.323Z (2 months ago)
- Language: JavaScript
- Size: 176 KB
- Stars: 27
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
strongly-connected-components
=============================
Given a directed graph, splits it into [strongly connected components](http://en.wikipedia.org/wiki/Strongly_connected_component).## Example
```javascript
var scc = require("strongly-connected-components")var adjacencyList = [
[4], // 0
[0,2], // 1
[1,3], // 2
[2], // 3
[1], // 4
[4,6], // 5
[5,2], // 6
[7,6,3], // 7
]console.log(scc(adjacencyList))
```## Install
npm install strongly-connected-components
## API
### `require("strongly-connected-components")(adjacencyList)`
Computes the strongly connected components of a graph using Tarjan's algorithm.* `adjacencyList` is an array of lists representing the directed edges of the graph
**Returns** An object containing:
* `components`: an array of arrays representing the partitioning of the vertices in the graph into connected components.
* `adjacencyList`: an array lists representing the directed edges of the directed acyclic graph between the strongly connected components## Credits
(c) 2013 Mikola Lysenko. MIT License. Based on the [implementation of Tarjan's algorithm on Wikipedia.](http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm)