Path finding library
Beginner in Rust - Feedback highly appreciated!
This library will contain standard path finding algorithms and return the resulting path or graph object
Table of contents generated with markdown-toc
Currently supported:
- Construct graphs
- Create Minimum Spanning Tree (MST) from a graph
- Find path with Depth-First Search (DFS)
- Find path with Breadth-First Search (BFS)
- Find path with Bidirectional Breadth-First Search (BBFS)
- Find path with the Dijkstra algorithm
- Find path with the A* algorithm, with heuristic:
- Euclidean distance
- Manhattan distance
- TBC: Find path with a Hierarchical Path-Finding A* (HPA*), with heuristic:
- Euclidean distance
- Manhattan distance
Download the crate: https://crates.io/crates/path-finding
How to use
At the moment, we have three major concepts:
- Edge
- Node
- Graph
- Position
You only need to pass edges to the graph. The nodes are generated automatically. Each pathfinding method will accept a graph, and return a graph that only contains the edges and nodes of the result.
Alternatively, you can also create a graph if you provide an adjacency matrix. Edges and nodes will be generated automatically.
If you want to use the A* path-finding algorithm, please make sure to provide positional information for each node.
Create Graph
- Create Edge
- Create Graph from edges
- Create Graph from adjacency matrix
Graph operations
You may want to get some information or mutate the graph in some way. Therefore, the graph currently supports three functions for convenience operations or to provide data for a heuristic function.
sorted_by_weight_asc
offer_positions
Minimum spanning tree
Depth-first search
Breadth-first search
Bidirectional breadth-first search
Dijkstra path search
A* path search
You can use the A* path-finding algorithm by providing either an existing heuristic function as shown below. Or you provide your own heuristic function. In case you use an existing heuristic function, make sure to provide the positional information for the nodes.
TBC: Hierarchical A* path search
Similar to the A* path-finding algorithm, you can provide either an existing heuristic function as shown in the previous section. Or you provide your own heuristic function. In case you use an existing heuristic function, make sure to provide the positional information for the nodes.
In addition to the functionality of A*, this algorithm will require you to pass the graph to the Hierarchical A* instance. The reason is simple, the algorithm will divide the graph into segments on creation and cache information required in the subsequent path-finding process.