Class ConnectedComponents

java.lang.Object
org.openscience.cdk.graph.ConnectedComponents

public final class ConnectedComponents extends Object
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 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()