Skip to content

Instantly share code, notes, and snippets.

@lion137
Last active August 18, 2017 00:06
Show Gist options
  • Select an option

  • Save lion137/651d537f12ba8ceb9fe9faa502f34ec1 to your computer and use it in GitHub Desktop.

Select an option

Save lion137/651d537f12ba8ceb9fe9faa502f34ec1 to your computer and use it in GitHub Desktop.
Blog
def afs(g, s):
bag = data_structure()
bag.add(s)
while bag is not empty:
tile = bag.pop()
if tile is not marked:
mark(tile)
for x in adj_list(tile):
bag.add(x)
dfs(g, v):
if v not marked:
mark(v)
for w in adj_list(v):
dfs(g, w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment