private void proceedFirstDFS ( ) { for ( int i = 0 ; i < nbNodes ; i ++ ) { iterator [ i ] = successors [ i ] . iterator ( ) ; } int i = root ; int k = 0 ; father [ k ] = k ; dfsNumberOfNode [ root ] = k ; nodeOfDfsNumber [ k ] = root ; int j ; k ++ ; while ( true ) { if ( iterator [ i ] . hasNext ( ) ) { j = iterator [ i ] . next ( ) ; if ( dfsNumberOfNode [ j ] == - 1 ) { father [ k ] = dfsNumberOfNode [ i ] ; dfsNumberOfNode [ j ] = k ; nodeOfDfsNumber [ k ] = j ; i = j ; k ++ ; } } else { if ( i == root ) { break ; } else { i = nodeOfDfsNumber [ father [ dfsNumberOfNode [ i ] ] ] ; } } } if ( k != nbActives ) { throw new UnsupportedOperationException ( "LCApreprocess did not reach all nodes" ) ; } for ( ; k < nbNodes ; k ++ ) { father [ k ] = - 1 ; } }
perform a dfs in graph to label nodes