DFS is called to generate parent of a node from adjacency list representation
def dfs ( u , parent ) : NEW_LINE INDENT for i in range ( 0 , len ( v [ u ] ) ) : NEW_LINE INDENT j = v [ u ] [ i ] ; NEW_LINE if ( j != parent ) : NEW_LINE INDENT p [ j ] = u ; NEW_LINE dfs ( j , u ) ; NEW_LINE DEDENT DEDENT DEDENT