Vertices are included if the weight of edge is 0
if ( x in g and not g [ x ] [ it ] ) : NEW_LINE INDENT v . append ( it ) ; NEW_LINE DEDENT else : NEW_LINE INDENT ns . add ( it ) ; NEW_LINE DEDENT s = ns ; NEW_LINE for i in v : NEW_LINE dfs ( i ) ; NEW_LINE