You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This line creates a DijkstraHeap object and puts the starting point in it. We will see later how this can be implemented but the best part is that....This is not part of the algorithm! What is a DijkstraHeap then? This is a **priority queue** that has the following properties:
78
+
This line creates a DijkstraHeap object and puts the starting point in it. We will see later how this can be implemented but the best part is that....This is not part of the algorithm! What is a DijkstraHeap then? This is a **cost queue** that has the following properties:
79
79
80
80
* If we try to insert an already visited element in the queue the DijkstraHeap will do nothing.
81
81
* The DijkstraHeap always pop the element that has the lowest cost and NEVER pops an already visited element.
@@ -110,11 +110,11 @@ for neighbor in graph.neighbors( current_node.point ):
@@ -128,7 +128,7 @@ For each neighbor we calculate the new cost of reaching this neighbor from the c
128
128
129
129
Why this 3rd cost? Because we want to explore first the points that are near the end destination and expend less time in the points that are far from it. So if we artificially give the point a higher cost if the point is far from the destination it will be visited later.
130
130
131
-
When we have calculated this new cost we insert the point in the priority queue.
131
+
When we have calculated this new cost we insert the point in the cost queue.
132
132
133
133
## But what about the MISTERIOUS DijkstraHeap?
134
134
@@ -144,7 +144,7 @@ class DijkstraHeap(list):
144
144
145
145
This class will have three main elements:
146
146
147
-
- A heap that will act as a priority queue (self).
147
+
- A heap that will act as a cost queue (self).
148
148
- A visited dict that will act as a visited set and as a mapping of the form point:came_from
149
149
- A costs dict that will act as a mapping of the form point:cost_so_far
0 commit comments