Created
November 2, 2019 22:20
-
-
Save imedadel/c103ffc5e5b9c5a9ed1cbd5c19f52d73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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