Package org.openscience.cdk.graph
Class ConnectedComponents
java.lang.Object
org.openscience.cdk.graph.ConnectedComponents
Compute the connected components of an adjacency list.
int[][] g = GraphUtil.toAdjList(container); ConnectedComponents cc = new ConnectedComponents(g); int[] components = cc.components(); for (int v = 0; v < g.length; v++) components[v];
- Author:
- John May
- Source code:
- main
- Belongs to CDK module:
- core
-
Constructor Summary
ConstructorsConstructorDescriptionConnectedComponents
(int[][] g) Compute the connected components of an adjacency list,g
. -
Method Summary
Modifier and TypeMethodDescriptionint[]
Access the components each vertex belongs to.int
-
Constructor Details
-
ConnectedComponents
public ConnectedComponents(int[][] g) Compute the connected components of an adjacency list,g
.- Parameters:
g
- graph (adjacency list representation)
-
-
Method Details
-
components
public int[] components()Access the components each vertex belongs to.- Returns:
- component labels
-
nComponents
public int nComponents()
-