Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created November 2, 2019 22:20
Show Gist options
  • Select an option

  • Save imedadel/c103ffc5e5b9c5a9ed1cbd5c19f52d73 to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/c103ffc5e5b9c5a9ed1cbd5c19f52d73 to your computer and use it in GitHub Desktop.
from collections import deque
def search(name, graph):
search_queue = deque()
search_queue += graph[name]
searched = []
while search_queue:
person = search_queue.popleft()
if not person in searched:
if person_is_seller(person): # or any other function
print person + " is a mango seller"
return True
else:
search_queue = += graph[person]
searched.append(person)
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment