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