Skip to content

Commit 4e9af2f

Browse files
Stop bidirectional A* when either frontier is empty
1 parent 84b73d0 commit 4e9af2f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎graphs/bidirectional_a_star.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __init__(self, start: TPosition, goal: TPosition) -> None:
187187
self.reached = False
188188

189189
def search(self) -> list[TPosition]:
190-
while self.fwd_astar.open_nodes or self.bwd_astar.open_nodes:
190+
while self.fwd_astar.open_nodes and self.bwd_astar.open_nodes:
191191
self.fwd_astar.open_nodes.sort()
192192
self.bwd_astar.open_nodes.sort()
193193
current_fwd_node = self.fwd_astar.open_nodes.pop(0)

0 commit comments

Comments
 (0)