DFS is called to generate parent of a node from adjacency list representation
void dfs ( int u , int parent ) { for ( int i = 0 ; i < v [ u ] . size ( ) ; i ++ ) { int j = v [ u ] [ i ] ; if ( j != parent ) { p [ j ] = u ; dfs ( j , u ) ; } } }