Skip to content

feat: add AStar search algorithm - #2038

Open
Youssef-Atef-20 wants to merge 1 commit into
TheAlgorithms:masterfrom
Youssef-Atef-20:feat/add-a-star-search
Open

Youssef-Atef-20 wants to merge 1 commit into
TheAlgorithms:masterfrom
Youssef-Atef-20:feat/add-a-star-search

Conversation

@Youssef-Atef-20

@Youssef-Atef-20 Youssef-Atef-20 commented Nov 26, 2026 •

Copy link
Copy Markdown

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Adds A* search algorithm to Graphs. Implements aStar(graph, start, goals, heuristic) using f = g + h. Supports a single goal or multiple goals, returns the shortest path or null when no path exists, and throws RangeError for an unknown start node.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new JavaScript files are placed inside an existing directory.
  • All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames.
  • All new algorithms have a URL in their comments that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.93671% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.95%. Comparing base (5c39e87) to head (aaa13c2).

Files with missing lines Patch % Lines
Graphs/AStar.js 94.93% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2038      +/-   ##
==========================================
+ Coverage   85.91%   85.95%   +0.03%     
==========================================
  Files         379      380       +1     
  Lines       19778    19857      +79     
  Branches     3016     3037      +21     
==========================================
+ Hits        16993    17068      +75     
- Misses       2785     2789       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@Youssef-Atef-20

Copy link
Copy Markdown
Author

Hi, I want to be transparent: I used AI to write the code for this A* implementation.

I reviewed it, I understand how it works, and I tested it — 3 tests passing.

Happy to make any changes you request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants