Connected components for graphology.
npm install graphology-componentsConnected components for graphology.
```
npm install graphology-components
- forEachConnectedComponent
- forEachConnectedComponentOrder
- countConnectedComponents
- connectedComponents
- largestConnectedComponent
- largestConnectedComponentSubgraph
- cropToLargestConnectedComponent
- stronglyConnectedComponents
Iterates over the connected components of the given graph using a callback.
`js
import {forEachConnectedComponent} from 'graphology-components';
forEachConnectedComponent(graph, component => {
console.log(component);
});
`
Specialized version of forEachConnectedComponent that iterates over the connected component orders, i.e. the number of nodes they contain.
It consumes less memory than a naive approach mapping the component lengths using forEachConnectedComponent.
`js
import {forEachConnectedComponentOrder} from 'graphology-components';
forEachConnectedComponentOrder(graph, order => {
console.log(order);
});
`
Returns the number of connected components of the given graph.
`js
import {countConnectedComponents} from 'graphology-components';
const count = countConnectedComponents(graph);
`
Returns the list of connected components of the given graph.
`js
import {connectedComponents} from 'graphology-components';
const components = connectedComponents(graph);
`
If your graph is mixed or directed, the result will be what are usually called weakly connected components.
Returns the largest connected component of the given graph.
`js
import {largestConnectedComponent} from 'graphology-components';
const largest = largestConnectedComponent(graph);
`
Returns a subgraph of the largest connected component of the given graph.
`js
import {largestConnectedComponentSubgraph} from 'graphology-components';
const subgraph = largestConnectedComponentSubgraph(graph);
`
Mutates the given graph to remove nodes and edges that are not part of its largest connected component.
`js
import {cropToLargestConnectedComponent} from 'graphology-components';
cropToLargestConnectedComponent(graph);
`
Returns the list of strongly connected components of the given graph. (mixed or directed)
`js
import {stronglyConnectedComponents} from 'graphology-components';
const components = stronglyConnectedComponents(graph);
``