Repository navigation
perf: use vector-backed bookkeeping for A* search - #468
Open
HarshitR2004 wants to merge 1 commit into
Open
HarshitR2004 wants to merge 1 commit into
HarshitR2004 wants to merge 1 commit into
Conversation
Contributor
|
Hi there! Thank you for creating your first pull-request on the Graaf library :) |
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.
Summary
A* currently maintains two hash maps for discovered vertices, storing the accumulated path cost twice and allocating individual map entries during traversal. This change replaces them with one lazily grown
std::vector<std::optional<path_vertex<WEIGHT_T>>>, indexed by vertex ID.Addresses the A* storage conversion requested in #463.
Implementation
reconstruct_path()helper becausebfs_shortest_pathanddijkstra_shortest_pathstill use it on currentmain.The public API remains unchanged.
Validation
Verified on Linux x86_64 with GCC 13.3.0:
SIZE_MAX.Graaf_perftarget, clang-format 15.0.7 checks, andgit diff --checkpassed.Performance
Median CPU times across five repetitions, with a 0.15-second minimum per repetition. Graph construction is excluded; both versions use identical benchmarks compiled with
-O3 -DNDEBUG.These measurements describe the tested synthetic grids; results may differ for other workloads.
Tradeoff
Vector storage scales with the largest discovered vertex ID plus one. Graphs with many gaps from deleted vertices can therefore require more bookkeeping memory than the previous maps. This follows the graph’s existing dense-storage model.
AI coding assistance was used partially for implementation, testing, and local validation.