public boolean isAcyclic ( ) { // Tarjan's algorithm to detect strongly connected componenent of a graph final AbstractJobVertex [ ] reachable = getAllReachableJobVertices ( ) ; final HashMap < AbstractJobVertex , Integer > indexMap = new HashMap < AbstractJobVertex , Integer > ( ) ; final HashMap < AbstractJobVertex , Integer > lowLinkMap = new HashMap < AbstractJobVertex , Integer > ( ) ; final Stack < AbstractJobVertex > stack = new Stack < AbstractJobVertex > ( ) ; final Integer index = Integer . valueOf ( 0 ) ; for ( int i = 0 ; i < reachable . length ; i ++ ) { if ( ! indexMap . containsKey ( reachable [ i ] ) ) { if ( ! tarjan ( reachable [ i ] , index , indexMap , lowLinkMap , stack ) ) { return false ; } } } return true ; }
Checks if the job graph is acyclic .