🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

graphology-components

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology-components

Connected components for graphology.

1.5.4
latest
Source
npm
Version published
Weekly downloads
28K
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Graphology Components

Connected components for graphology.

Installation

npm install graphology-components

Usage

forEachConnectedComponent

Iterates over the connected components of the given graph using a callback.

import {forEachConnectedComponent} from 'graphology-components';

forEachConnectedComponent(graph, component => {
  console.log(component);
});

forEachConnectedComponentOrder

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.

import {forEachConnectedComponentOrder} from 'graphology-components';

forEachConnectedComponentOrder(graph, order => {
  console.log(order);
});

countConnectedComponents

Returns the number of connected components of the given graph.

import {countConnectedComponents} from 'graphology-components';

const count = countConnectedComponents(graph);

connectedComponents

Returns the list of connected components of the given graph.

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.

largestConnectedComponent

Returns the largest connected component of the given graph.

import {largestConnectedComponent} from 'graphology-components';

const largest = largestConnectedComponent(graph);

largestConnectedComponentSubgraph

Returns a subgraph of the largest connected component of the given graph.

import {largestConnectedComponentSubgraph} from 'graphology-components';

const subgraph = largestConnectedComponentSubgraph(graph);

cropToLargestConnectedComponent

Mutates the given graph to remove nodes and edges that are not part of its largest connected component.

import {cropToLargestConnectedComponent} from 'graphology-components';

cropToLargestConnectedComponent(graph);

stronglyConnectedComponents

Returns the list of strongly connected components of the given graph. (mixed or directed)

import {stronglyConnectedComponents} from 'graphology-components';

const components = stronglyConnectedComponents(graph);

Keywords

graph

FAQs

Package last updated on 21 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts