storing the dfs traversal in the array e
static void dfs ( int src ) { e . add ( src ) ; visited [ src ] = true ; for ( int i = 0 ; i < ( g [ src ] ) . size ( ) ; i ++ ) { int des = g [ src ] . get ( i ) ; if ( ! visited [ des ] ) { dfs ( des ) ; e . add ( src ) ; } } }