Welcome, guest | Sign In | My Account | Store | Cart
def DFS (G, v):
    yield v
    visited = set ([v])
    S = neighbors (v)
    while S:
        w = S.pop()
	if w not in visited:
	    yield w
	    visited.add (w)
	    S.extend (neighbors (w))

History

  • revision 7 (14 years ago)
  • previous revisions are not available