Skip to content

Commit 8162242

Browse files
committed
not adding parent if node in closed set
1 parent 71daa78 commit 8162242

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

PathPlanning/BreadthFirstSearch/breadth_first_search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@ def planning(self, sx, sy, gx, gy):
106106
for i, _ in enumerate(self.motion):
107107
node = self.Node(current.x + self.motion[i][0],
108108
current.y + self.motion[i][1],
109-
current.cost + self.motion[i][2], c_id+1, current)
109+
current.cost + self.motion[i][2], c_id+1, None)
110110
n_id = self.calc_grid_index(node)
111111

112112
# If the node is not safe, do nothing
113113
if not self.verify_node(node):
114114
continue
115115

116116
if n_id not in closed_set:
117+
node.parent = current
117118
closed_set[n_id] = node
118119
open_set[n_id] = node
119120

0 commit comments

Comments
 (0)