documentationfor yFiles for HTML 2.6

ConnectedComponents

Determines the connected components of a given graph.

Inheritance Hierarchy
ConnectedComponents

Remarks

A graph G is called connected if there exists an undirected path of edges between every pair of nodes.

The connected components of a graph are the maximal connected subgraphs of which the graph consists.

Other Graph Connectivity Algorithms

yFiles for HTML supports a number of other analysis algorithms that partition the graph into components, based on various criteria.

  • StronglyConnectedComponents – Determines components defined by the existence of a directed path between nodes
  • BiconnectedComponents – Determines components defined by the existence of at least two separate undirected paths between all nodes
  • Bipartition – Divides a graph into two partitions where all edges have their source and target in different partitions
  • IndependentSets – Divides a graph into partitions where no nodes are connected within a partition
  • KCoreComponents – Calculates the k-cores of an undirected input graph. The k-core of an undirected input graph consists of the subgraph components where each node has at least degree k.

Examples

Calculating connected components on a graph
// prepare the connected components algorithm
const algorithm = new ConnectedComponents()
// run the algorithm
const result = algorithm.run(graph)

// highlight the nodes of the connected components with different styles
for (const node of graph.nodes) {
  const componentId = result.nodeComponentIds.get(node)
  graph.setStyle(node, componentStyles.get(componentId))
}// prepare the connected components algorithm
const algorithm = new ConnectedComponents()
// run the algorithm
const result = algorithm.run(graph)

// highlight the nodes of the connected components with different styles
for (const node of graph.nodes) {
  const componentId = result.nodeComponentIds.get(node)
  graph.setStyle(node, componentStyles.get(componentId)!)
}

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.analysis.ConnectedComponents

See Also

Constructors

Properties

Methods