@ Override public void checkGraph ( ) throws AsymmetricException , CycleException , EX { Set < V > vertices = graph . getVertices ( ) ; Map < V , Color > colors = new HashMap <> ( vertices . size ( ) * 4 / 3 + 1 ) ; Map < V , V > predecessors = new HashMap <> ( ) ; // Could this be a simple sequence like TopologicalSorter? Any benefit? for ( V v : vertices ) { if ( ! colors . containsKey ( v ) ) doCheck ( colors , predecessors , v ) ; } }
Test the graph for cycles and makes sure that all connections are consistent with back connections .