Skip to content

Feature Request: Multi-goal support for all pathfinding algorithms (Dijkstra, A*, BFS, etc.) #690

@Tavi007

Description

@Tavi007

Currently, the crate only supports single-goal search (dijkstra, astar, bfs) or exhaustive search (dijkstra_all, bfs_reach, etc.).

However, some real-world applications require finding paths to a set of known goal nodes, and doing so efficiently — ideally stopping the search as soon as all targets are reached.

Since I'm rather new to Rust, I don't feel like I'm in the position to propose a solution. Asking ChatGPT resulted in this function header

pub fn dijkstra_multi_goal<N, C, FN, IN>(
    start: &N,
    successors: FN,
    goals: &HashSet<N>,
) -> HashMap<N, (Vec<N>, C)>
where
    N: Eq + Hash + Clone,
    C: Zero + Ord + Copy,
    FN: FnMut(&N) -> IN,
    IN: IntoIterator<Item = (N, C)>,

Which doesn't seem to fit your design philosophy (using a success function).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions