      "        graph.add_edge(1, 4, 4)\n",
      "        graph.add_edge(2, 1, 6)\n",
      "        graph.add_edge(3, 2, 7)\n",
      "        graph.add_edge(3, 4, 8)\n",
      "        bfs(nodes[0], self.results.add_result)\n",
      "        assert_equal(str(self.results), \"[0, 1, 4, 5, 3, 2]\")\n",
      "\n",
      "        print('Success: test_bfs')\n",
      "\n",
      "\n",
 
</s> remove     "        bfs(nodes[0], self.results.add_result)\n",
 </s> add     "        graph.bfs(nodes[0], self.results.add_result)\n", </s> remove         bfs(nodes[0], self.results.add_result)
 </s> add         graph.bfs(nodes[0], self.results.add_result) </s> remove     "        graph = Graph()\n",
 </s> add     "        graph = GraphBfs()\n", </s> remove     "        graph = Graph()\n",
 </s> add     "        graph = GraphBfs()\n", </s> remove     "def bfs(root, visit_func):\n",
    "    if root is None:\n",
    "        return\n",
    "    queue = deque()\n",
    "    queue.append(root)\n",
    "    root.visit_state = State.visited\n",
    "    while queue:\n",
    "        node = queue.popleft()\n",
    "        visit_func(node)\n",
    "        for adjacent_node in node.adjacent:\n",
    "            if adjacent_node.visit_state == State.unvisited:\n",
    "                queue.append(adjacent_node)\n",
    "                adjacent_node.visit_state = State.visited"
 </s> add     "class GraphBfs(Graph):\n",
    "\n",
    "    def bfs(self, root, visit_func):\n",
    "        if root is None:\n",
    "            return\n",
    "        queue = deque()\n",
    "        queue.append(root)\n",
    "        root.visit_state = State.visited\n",
    "        while queue:\n",
    "            node = queue.popleft()\n",
    "            visit_func(node)\n",
    "            for adjacent_node in node.adj_nodes.values():\n",
    "                if adjacent_node.visit_state == State.unvisited:\n",
    "                    queue.append(adjacent_node)\n",
    "                    adjacent_node.visit_state = State.visited"
    "        graph.bfs(nodes[0], self.results.add_result)\n",
      "        graph.add_edge(1, 4, 4)\n",
      "        graph.add_edge(2, 1, 6)\n",
      "        graph.add_edge(3, 2, 7)\n",
      "        graph.add_edge(3, 4, 8)\n",
    "        graph.bfs(nodes[0], self.results.add_result)\n",
      "        assert_equal(str(self.results), \"[0, 1, 4, 5, 3, 2]\")\n",
      "\n",
      "        print('Success: test_bfs')\n",
      "\n",
      "\n",
keep keep keep keep replace keep keep keep keep keep
 Move graph bfs to a class 
graphs_trees/graph_bfs/bfs_challenge.ipynb