Stop bidirectional A* when either frontier is empty - #15484
Open
dhairyajangir wants to merge 1 commit into
Open
dhairyajangir wants to merge 1 commit into
dhairyajangir wants to merge 1 commit into
Conversation
This was referenced Oct 2, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change
Stop the bidirectional A* loop when either frontier is empty. The previous
orcondition allowed another iteration with one empty list, although that iteration unconditionally pops from both frontiers.For example, with
grid = [[0, 1, 0], [1, 1, 0]], start(0, 0), and goal(0, 2), the forward frontier empties first and the current implementation raisesIndexError: pop from empty list. The change returns the existing start-only no-path result. The mirrored case, where the backward frontier empties first, is fixed as well.This is a one-line guard change. Node matching, heuristics, and the existing return convention are unchanged. Existing doctests are preserved as requested by the contribution guidelines.
Validation on free-threaded CPython 3.15.0rc2:
pre-commit run --all-files --show-diff-on-failurepasses all applicable configured hooks.AI assistance was used to prepare this change; a separate agent review reproduced the failures and verified the fix and unchanged controls.
Checklist
No new file or algorithm is added, and no issue is claimed. The existing class doctests pass; this change adds no doctests or new functions.