diff --git a/graphs_trees/graph_bfs/bfs_solution.ipynb b/graphs_trees/graph_bfs/bfs_solution.ipynb index 1825f0b..4f1090f 100644 --- a/graphs_trees/graph_bfs/bfs_solution.ipynb +++ b/graphs_trees/graph_bfs/bfs_solution.ipynb @@ -116,14 +116,14 @@ " return\n", " queue = deque()\n", " queue.append(root)\n", - " root.visited = True\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 not adjacent_node.visited:\n", + " if adjacent_node.visit_state == State.unvisited:\n", " queue.append(adjacent_node)\n", - " adjacent_node.visited = True" + " adjacent_node.visit_state = State.visited" ] }, { diff --git a/graphs_trees/graph_dfs/dfs_solution.ipynb b/graphs_trees/graph_dfs/dfs_solution.ipynb index 3f7f59b..3f50459 100644 --- a/graphs_trees/graph_dfs/dfs_solution.ipynb +++ b/graphs_trees/graph_dfs/dfs_solution.ipynb @@ -110,9 +110,9 @@ " if root is None:\n", " return\n", " visit_func(root)\n", - " root.visited = True\n", + " root.visit_state = State.visited\n", " for node in root.adjacent:\n", - " if not node.visited:\n", + " if node.visit_state == State.unvisited:\n", " dfs(node, visit_func)" ] }, diff --git a/graphs_trees/graph_path_exists/path_exists_solution.ipynb b/graphs_trees/graph_path_exists/path_exists_solution.ipynb index 2610c72..378d046 100644 --- a/graphs_trees/graph_path_exists/path_exists_solution.ipynb +++ b/graphs_trees/graph_path_exists/path_exists_solution.ipynb @@ -127,7 +127,7 @@ " return True\n", " queue = deque()\n", " queue.append(start)\n", - " start.visited = True\n", + " start.visit_state = State.visited\n", " while queue:\n", " node = queue.popleft()\n", " if node is None:\n", @@ -135,9 +135,9 @@ " if node is end:\n", " return True\n", " for adj_node in node.adjacent:\n", - " if not adj_node.visited:\n", + " if adj_node.visit_state == State.unvisited:\n", " queue.append(adj_node)\n", - " adj_node.visited = True\n", + " adj_node.visit_state = State.visited\n", " return False" ] },