Open
Description
AttributeError: 'NQueensProblem' object has no attribute 'graph' in cell [70] of search.ipynb:
%%timeit
depth_first_tree_search(nqp)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[70], line 1
----> 1 get_ipython().run_cell_magic('timeit', '', 'depth_first_tree_search(nqp)\n')
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py:2543, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2541 with self.builtin_trap:
2542 args = (magic_arg_s, cell)
-> 2543 result = fn(*args, **kwargs)
2545 # The code below prevents the output from being displayed
2546 # when using magics with decorator @output_can_be_silenced
2547 # when the last Python token in the expression is a ';'.
2548 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\magics\execution.py:1209, in ExecutionMagics.timeit(self, line, cell, local_ns)
1207 for index in range(0, 10):
1208 number = 10 ** index
-> 1209 time_number = timer.timeit(number)
1210 if time_number >= 0.2:
1211 break
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\magics\execution.py:173, in Timer.timeit(self, number)
171 gc.disable()
172 try:
--> 173 timing = self.inner(it, self.timer)
174 finally:
175 if gcold:
File <magic-timeit>:1, in inner(_it, _timer)
Cell In[16], line 50, in depth_first_tree_search(problem)
48 def depth_first_tree_search(problem):
49 "Search the deepest nodes in the search tree first."
---> 50 iterations, all_node_colors, node = tree_depth_search_for_vis(problem)
51 return(iterations, all_node_colors, node)
Cell In[16], line 9, in tree_depth_search_for_vis(problem)
7 iterations = 0
8 all_node_colors = []
----> 9 node_colors = {k : 'white' for k in problem.graph.nodes()}
11 #Adding first node to the stack
12 frontier = [Node(problem.initial)]
AttributeError: 'NQueensProblem' object has no attribute 'graph'
Metadata
Metadata
Assignees
Labels
No labels