Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def graph_search(problem, queue_type):
- frontier = util.Queue()
- explored = set()
- start_state = problem.getStartState()
- frontier.push(start_state)
- while True:
- if frontier.isEmpty(): return None
- node = frontier.pop()
- if problem.isGoalState(node): return node
- explored.add(node)
- for s in problem.getSuccessors(node):
- if s not in explored:
- frontier.push(s)
Add Comment
Please, Sign In to add comment