Traversing for every vertex
var visited = Array ( V + 1 ) . fill ( false ) ; for ( var u = 1 ; u <= V ; u ++ ) { if ( visited [ u ] == false ) { var componentMax = u ; var componentMin = u ; DFSUtil ( u , adj , visited , componentMin , componentMax ) ;