#NEWLINE# def dfs_iterative( graph , start , seen ) : #NEWLINE# #INDENT# 'DFS, detect connected component, iterative implementation\n\n    :param graph: directed graph in listlist or listdict format\n    :param int node: to start graph exploration\n    :param boolean-table seen: will be set true for the connected component\n          containing node.\n    :complexity: `O(|V|+|E|)`\n    ' #NEWLINE# seen [ start ] = True #NEWLINE# to_visit = [ start ] #NEWLINE# while to_visit : #NEWLINE# #INDENT# node = to_visit . pop ( ) #NEWLINE# for neighbor in graph [ node ] : #NEWLINE# #INDENT# if ( not seen [ neighbor ] ) : #NEWLINE# #INDENT# seen [ neighbor ] = True #NEWLINE# to_visit . append ( neighbor )