Function to add edge into the graph
static void addEdge ( ArrayList < ArrayList < Integer > > adj , int u , int v ) { adj . get ( u ) . add ( v ) ; adj . get ( v ) . add ( u ) ; } static void DFSUtil ( int u , ArrayList < ArrayList < Integer > > adj , boolean [ ] visited , int componentMin , int componentMax ) { visited [ u ] = true ;