def graph_search(problem, frontier):
frontier.append(Node(problem.initial))<EOL>explored = set()<EOL>while frontier:<EOL><INDENT>node = frontier.pop()<EOL>if problem.goal_test(node.state):<EOL><INDENT>return node<EOL><DEDENT>explored.add(node.state)<EOL>frontier.extend(child for child in node.expand(problem)<EOL>if child.state not in explored<EOL>and child not in frontier)<EOL><DEDENT>return None<EOL>
Search through the successors of a problem to find a goal.
    The argument frontier should be an empty queue.
    If two paths reach a state, only use the first one. [Fig. 3.7]