Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALGO] A Star Search #69

Closed
6 tasks
bobluppes opened this issue Aug 13, 2023 · 2 comments
Closed
6 tasks

[ALGO] A Star Search #69

bobluppes opened this issue Aug 13, 2023 · 2 comments
Assignees
Labels
enhancement New feature good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bobluppes
Copy link
Owner

bobluppes commented Aug 13, 2023

A Star Search

The A Star algorithm (or A*) is an informed search algorithm which finds the shortest path between a start vertex and a target vertex. The search is guided by a heuristic, which prioritizes the traversal order of the candidate paths.

See the wikipedia entry for more details.

Syntax

The algorithm should have the following syntax:

/**
 * @brief Finds the shortest path between a start_vertex and target_vertex
 *        using the A* search algorithm.
 *
 * @param graph The graph to search in.
 * @param start_vertex The starting vertex for the search.
 * @param target_vertex The target vertex to reach.
 * @param heuristic A heuristic function estimating the cost from a vertex to the target.
 * @return An optional containing the shortest path if found, or std::nullopt if no path exists.
 */
template <typename V, typename E, graph_type T, typename HEURISTIC_T, typename WEIGHT_T = decltype(get_weight(std::declval<E>()))>
  requires std::is_invocable_r_v<WEIGHT_T, HEURISTIC_T&, vertex_id_t>
std::optional<graph_path<WEIGHT_T>> a_star_search(
    const graph<V, E, T> &graph, vertex_id_t start_vertex, vertex_id_t target_vertex,
    const HEURISTIC_T &heuristic);

This should live in the graaf::algorithm namespace under include/graaflib/algorithm/shortest_path.h.

Definition of Done

This issue is done when:

  • The algorithm is implemented
  • The new function has a javadoc-style comment explaining the interface
  • Appropriate tests are added under test/graaflib/algorithm/shortest_path_test.cpp
  • A test coverage of at least 95% is reached
  • A documentation entry is added under docs/docs/algorithms under the appropriate category
    • Just adding a short description and the algorithm syntax here is fine
    • See the wiki on how to build the documentation locally
  • The algorithm is added to the list of algorithms in README.md
@bobluppes bobluppes added enhancement New feature help wanted Extra attention is needed good first issue Good for newcomers labels Aug 13, 2023
@bobluppes bobluppes pinned this issue Aug 13, 2023
@ndcroos
Copy link
Contributor

ndcroos commented Aug 14, 2023

I would like to work on this.

@bobluppes
Copy link
Owner Author

Hi @ndcroos, super happy to hear that! Assigning this to you ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants