Skip to content

Add A* Search Algorithm for Weighted Graph Pathfinding#7374

Open
surajdm123 wants to merge 2 commits intoTheAlgorithms:masterfrom
surajdm123:a-star-algorithm
Open

Add A* Search Algorithm for Weighted Graph Pathfinding#7374
surajdm123 wants to merge 2 commits intoTheAlgorithms:masterfrom
surajdm123:a-star-algorithm

Conversation

@surajdm123
Copy link
Copy Markdown
Contributor

Summary

This PR introduces an implementation of the A* (A-Star) search algorithm for weighted graph pathfinding, added under the existing search algorithms module.

The A* algorithm is a widely used heuristic-based search technique that combines the benefits of Dijkstra’s algorithm and greedy best-first search to efficiently compute optimal paths in weighted graphs.

Why this addition is useful

A* is a foundational algorithm used in:

  • AI Algorithms
  • Navigation systems (e.g., shortest route computation)
  • Game AI pathfinding
  • Robotics and planning systems
  • General graph optimization problems

Adding this algorithm improves the completeness of the search algorithms module by covering heuristic-based informed search techniques, complementing existing BFS, DFS, and uninformed search implementations.

Testing

Screenshot 2026-04-13 at 12 05 25 AM

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.54%. Comparing base (227355e) to head (18a2009).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...ain/java/com/thealgorithms/others/AStarSearch.java 93.18% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7374      +/-   ##
============================================
+ Coverage     79.47%   79.54%   +0.07%     
- Complexity     7090     7152      +62     
============================================
  Files           791      797       +6     
  Lines         23202    23412     +210     
  Branches       4565     4604      +39     
============================================
+ Hits          18439    18624     +185     
- Misses         4024     4050      +26     
+ Partials        739      738       -1     

☔ View full report in Codecov by Sentry.
📢 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.

@surajdm123 surajdm123 marked this pull request as ready for review April 13, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants