Finding the maximum and minimum values in each component
componentMax = Math . max ( componentMax , u ) ; componentMin = Math . min ( componentMin , u ) ; for ( int i = 0 ; i < adj . get ( u ) . size ( ) ; i ++ ) if ( visited [ adj . get ( u ) . get ( i ) ] == false ) DFSUtil ( adj . get ( u ) . get ( i ) , adj , visited , componentMin , componentMax ) ; }