public <V extends Vertex>List<Set<V>> components(Graph graph){
  AdjacencyMatrix<V> y=new AdjacencyMatrix<V>(graph);
  List<TIntArrayList> comps=extractComponents(y);
  List<Set<V>> components=new ArrayList<Set<V>>(comps.size());
  for (  TIntArrayList comp : comps) {
    Set<V> component=new HashSet<V>();
    for (int i=0; i < comp.size(); i++) {
      component.add(y.getVertex(comp.get(i)));
    }
    components.add(component);
  }
  return components;
}

public < V extends Vertex > List < Set < V > > components ( Graph graph ) { AdjacencyMatrix < V > y = new AdjacencyMatrix < V > ( graph ) ; List < TIntArrayList > comps = extractComponents ( y ) ; List < Set < V > > components = new ArrayList < Set < V > > ( comps . size ( ) ) ; for ( TIntArrayList comp : comps ) { Set < V > component = new HashSet < V > ( ) ; for ( int i = 0 ; i < comp . size ( ) ; i ++ ) { component . add ( y . getVertex ( comp . get ( i ) ) ) ; } components . add ( component ) ; } return components ; }
extracts the disconnected components and returns them as a list of vertex sets . the components in the list are descending in size .
