|
273 | 273 | "initial_node_colors = dict(node_colors)\n", |
274 | 274 | " \n", |
275 | 275 | "# positions for node labels\n", |
276 | | - "node_label_pos = {k:[v[0],v[1]-10] for k,v in romania_locations.items()}\n", |
| 276 | + "node_label_pos = { k:[v[0],v[1]-10] for k,v in romania_locations.items() }\n", |
277 | 277 | "\n", |
278 | 278 | "# use this while labeling edges\n", |
279 | 279 | "edge_labels = dict()\n", |
|
283 | 283 | " connections = romania_map.get(node)\n", |
284 | 284 | " for connection in connections.keys():\n", |
285 | 285 | " distance = connections[connection]\n", |
| 286 | + "\n", |
286 | 287 | " # add edges to the graph\n", |
287 | 288 | " G.add_edge(node, connection)\n", |
288 | 289 | " # add distances to edge_labels\n", |
|
293 | 294 | "cell_type": "markdown", |
294 | 295 | "metadata": {}, |
295 | 296 | "source": [ |
296 | | - "We have completed building our graph based on romania_map and its locations. It's time to display it here in the notebook. This function `show_map(node_colors)` helps us do that. We will be calling this function later on to display the map at each and every interval step while searching using variety of algorithms from the book." |
| 297 | + "We have completed building our graph based on romania_map and its locations. It's time to display it here in the notebook. This function `show_map(node_colors)` helps us do that. We will be calling this function later on to display the map at each and every interval step while searching, using variety of algorithms from the book." |
297 | 298 | ] |
298 | 299 | }, |
299 | 300 | { |
|
438 | 439 | " \n", |
439 | 440 | " for i in range(slider.max + 1):\n", |
440 | 441 | " slider.value = i\n", |
441 | | - " # time.sleep(.5)\n", |
| 442 | + " #time.sleep(.5)\n", |
442 | 443 | " \n", |
443 | 444 | " slider = widgets.IntSlider(min=0, max=1, step=1, value=0)\n", |
444 | 445 | " slider_visual = widgets.interactive(slider_callback, iteration = slider)\n", |
|
530 | 531 | " all_node_colors = []\n", |
531 | 532 | " node_colors = dict(initial_node_colors)\n", |
532 | 533 | " \n", |
| 534 | + " #Adding first node to the queue\n", |
533 | 535 | " frontier.append(Node(problem.initial))\n", |
534 | 536 | " \n", |
535 | 537 | " node_colors[Node(problem.initial).state] = \"orange\"\n", |
536 | 538 | " iterations += 1\n", |
537 | 539 | " all_node_colors.append(dict(node_colors))\n", |
538 | 540 | " \n", |
539 | 541 | " while frontier:\n", |
| 542 | + " #Popping first node of queue\n", |
540 | 543 | " node = frontier.pop()\n", |
541 | 544 | " \n", |
542 | 545 | " # modify the currently searching node to red\n", |
|
0 commit comments