Utility method for a depth first search among vertices
def dfs ( g , u , visit ) : NEW_LINE INDENT visit [ u ] = True NEW_LINE for i in range ( len ( g [ u ] ) ) : NEW_LINE INDENT if ( not visit [ g [ u ] [ i ] ] ) : NEW_LINE INDENT dfs ( g , g [ u ] [ i ] , visit ) NEW_LINE DEDENT DEDENT DEDENT