      "collapsed": false
     },
     "outputs": [],
     "source": [
      "def path_exists(start, end):\n",
      "    # TODO: Implement me\n",
      "    pass"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
 
</s> remove     "        for adj_node in node.adjacent:\n",
    "            if adj_node.visit_state == State.unvisited:\n",
    "                queue.append(adj_node)\n",
    "                adj_node.visit_state = State.visited\n",
    "    return False"
 </s> add     "        queue = deque()\n",
    "        queue.append(start)\n",
    "        start.visit_state = State.visited\n",
    "        while queue:\n",
    "            node = queue.popleft()\n",
    "            if node is end:\n",
    "                return True\n",
    "            for adj_node in node.adj_nodes.values():\n",
    "                if adj_node.visit_state == State.unvisited:\n",
    "                    queue.append(adj_node)\n",
    "                    adj_node.visit_state = State.visited\n",
    "        return False" </s> remove     "def path_exists(start, end):\n",
    "    if start is None or end is None:\n",
    "        return False\n",
    "    if start is end:\n",
    "        return True\n",
    "    queue = deque()\n",
    "    queue.append(start)\n",
    "    start.visit_state = State.visited\n",
    "    while queue:\n",
    "        node = queue.popleft()\n",
    "        if node is end:\n",
 </s> add     "class GraphPathExists(Graph):\n",
    "\n",
    "    def path_exists(self, start, end):\n",
    "        if start is None or end is None:\n",
    "            return False\n",
    "        if start is end:\n", </s> remove     "        assert_equal(path_exists(nodes[0], nodes[2]), True)\n",
    "        assert_equal(path_exists(nodes[0], nodes[0]), True)\n",
    "        assert_equal(path_exists(nodes[4], nodes[5]), False)\n",
 </s> add     "        assert_equal(graph.path_exists(nodes[0], nodes[2]), True)\n",
    "        assert_equal(graph.path_exists(nodes[0], nodes[0]), True)\n",
    "        assert_equal(graph.path_exists(nodes[4], nodes[5]), False)\n", </s> remove     "        assert_equal(path_exists(nodes[0], nodes[2]), True)\n",
    "        assert_equal(path_exists(nodes[0], nodes[0]), True)\n",
    "        assert_equal(path_exists(nodes[4], nodes[5]), False)\n",
 </s> add     "        assert_equal(graph.path_exists(nodes[0], nodes[2]), True)\n",
    "        assert_equal(graph.path_exists(nodes[0], nodes[0]), True)\n",
    "        assert_equal(graph.path_exists(nodes[4], nodes[5]), False)\n", </s> remove     "        graph = Graph()\n",
 </s> add     "        graph = GraphPathExists()\n",
    "class GraphPathExists(Graph):\n",
    "\n",
    "    def path_exists(self, start, end):\n",
    "        # TODO: Implement me\n",
    "        pass"
      "collapsed": false
     },
     "outputs": [],
     "source": [
    "class GraphPathExists(Graph):\n",
    "\n",
    "    def path_exists(self, start, end):\n",
    "        # TODO: Implement me\n",
    "        pass"
    "class GraphPathExists(Graph):\n",
    "\n",
    "    def path_exists(self, start, end):\n",
    "        # TODO: Implement me\n",
    "        pass"
    "class GraphPathExists(Graph):\n",
    "\n",
    "    def path_exists(self, start, end):\n",
    "        # TODO: Implement me\n",
    "        pass"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
keep keep keep keep replace replace replace keep keep keep keep keep
 Move graph path exists to a class 
graphs_trees/graph_path_exists/path_exists_challenge.ipynb