Function traversing the graph using DFS approach and updating the set of nodes
def dfs ( visit , src ) : NEW_LINE INDENT visit [ src ] = True NEW_LINE node . add ( src ) NEW_LINE llen = len ( Graph [ src ] ) NEW_LINE for i in range ( llen ) : NEW_LINE INDENT if ( not visit [ Graph [ src ] [ i ] ] ) : NEW_LINE INDENT dfs ( visit , Graph [ src ] [ i ] ) NEW_LINE DEDENT DEDENT DEDENT