      "        self.results = Results()\n",
      "\n",
      "    def test_dfs(self):\n",
      "        nodes = []\n",
      "        graph = Graph()\n",
      "        for id in range(0, 6):\n",
      "            nodes.append(graph.add_node(id))\n",
      "        graph.add_edge(0, 1, 5)\n",
      "        graph.add_edge(0, 4, 3)\n",
      "        graph.add_edge(0, 5, 2)\n",
 
</s> remove     "        graph = Graph()\n",
 </s> add     "        graph = GraphDfs()\n", </s> remove         graph = Graph()
 </s> add         graph = GraphDfs() </s> remove     "        dfs(nodes[0], self.results.add_result)\n",
 </s> add     "        graph.dfs(nodes[0], self.results.add_result)\n", </s> remove     "        dfs(nodes[0], self.results.add_result)\n",
 </s> add     "        graph.dfs(nodes[0], self.results.add_result)\n", </s> remove     "def dfs(root, visit_func):\n",
    "    if root is None:\n",
    "        return\n",
    "    visit_func(root)\n",
    "    root.visit_state = State.visited\n",
    "    for node in root.adjacent:\n",
    "        if node.visit_state == State.unvisited:\n",
    "            dfs(node, visit_func)"
 </s> add     "class GraphDfs(Graph):\n",
    "\n",
    "    def dfs(self, root, visit_func):\n",
    "        if root is None:\n",
    "            return\n",
    "        visit_func(root)\n",
    "        root.visit_state = State.visited\n",
    "        for node in root.adj_nodes.values():\n",
    "            if node.visit_state == State.unvisited:\n",
    "                self.dfs(node, visit_func)"
    "        graph = GraphDfs()\n",
      "        self.results = Results()\n",
      "\n",
      "    def test_dfs(self):\n",
      "        nodes = []\n",
    "        graph = GraphDfs()\n",
      "        for id in range(0, 6):\n",
      "            nodes.append(graph.add_node(id))\n",
      "        graph.add_edge(0, 1, 5)\n",
      "        graph.add_edge(0, 4, 3)\n",
      "        graph.add_edge(0, 5, 2)\n",
keep keep keep keep replace keep keep keep keep keep
 Move graph dfs to a class 
graphs_trees/graph_dfs/dfs_challenge.ipynb