# pathfinding
[](https://crates.io/crates/pathfinding)
[](https://docs.rs/pathfinding)
[](#license)
This crate implements several pathfinding, flow, and graph algorithms in [Rust][Rust]. The algorithms are generic over their arguments. See [the documentation](https://docs.rs/pathfinding) for more information about the various algorithms.
## Using this crate
In your `Cargo.toml`, put:
``` ini
[dependencies]
pathfinding = "4.10.0"
```
You can then pull your preferred algorithm (BFS in this example) using:
``` rust
use pathfinding::prelude::bfs;
```
## Example
We will search the shortest path on a chess board to go from (1, 1) to (4, 6) doing only knight
moves.
``` rust
use pathfinding::prelude::bfs;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
struct Pos(i32, i32);
impl Pos {
fn successors(&self) -> Vec<Pos> {
let &Pos(x, y) = self;
vec![Pos(x+1,y+2), Pos(x+1,y-2), Pos(x-1,y+2), Pos(x-1,y-2),
Pos(x+2,y+1), Pos(x+2,y-1), Pos(x-2,y+1), Pos(x-2,y-1)]
}
}
static GOAL: Pos = Pos(4, 6);
- feat(matrix): add `Matrix::transpose()`
- fix(tests): remove unused imports
If a pull-request should automatically close an open issue, please
include "Fix #xxx# or "Close #xxx" in the pull-request cover-letter.