a-star 0.1.0-rc.1

This library provides a generic a-star search algorithm.
Documentation
  • Coverage
  • 78.57%
    11 out of 14 items documented0 out of 0 items with examples
  • Size
  • Source code size: 23.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • nikdeapen/a-star
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nikdeapen

a-star

Crates.io Docs.rs License: MIT

This library provides a generic a-star search algorithm.

a-star = "0.1.0-rc.1"

Overview

A generic, reusable A* pathfinding implementation. The algorithm is parameterized over:

  • Node -- the type of node in the graph
  • Cost -- the type used for edge weights and heuristics
  • Graph -- a trait providing neighbors and heuristic
  • DiscoveredSet -- a trait abstracting the priority queue

Core Types

  • Graph<Node, Cost> -- trait for providing graph structure
  • AStar -- the search algorithm, reusable across multiple searches
  • Path<Node, Cost> -- the result of a search (nodes + total cost)
  • NodeCost<Node, Cost> -- a node with an associated cost
  • DiscoveredSet -- trait for the priority queue
  • MinHeap -- binary min-heap implementation of DiscoveredSet

Example

use a_star::*;

// Implement Graph for your domain.
struct MyGraph;

impl Graph<u32, u32> for MyGraph {
    fn neighbors(&self, node: u32, neighbors: &mut Vec<NodeCost<u32, u32>>) {
        // Add neighbors with their edge costs.
    }

    fn heuristic(&self, node: u32, goal: u32) -> u32 {
        // Return an admissible estimate.
        0
    }
}

let graph: MyGraph = MyGraph;
let discovered: MinHeap<u32, u32> = MinHeap::default ();
let mut search: AStar<u32, u32, MinHeap<u32, u32>, MyGraph> = AStar::new( & graph, discovered);

if let Some(path) = search.search(0, 10) {
println ! ("cost: {}", path.cost());
println ! ("nodes: {:?}", path.nodes());
}