Skip to main content

pathfinding_indexed/
lib.rs

1#![forbid(missing_docs)]
2//! # pathfinding-indexed
3//!
4//! Index-only pathfinding, flow, and graph algorithms with dense `usize` indices.
5//!
6//! The primary API is [`IndexedGraph`] for directed graphs and
7//! [`IndexedUndirectedGraph`] for undirected graphs. Algorithms are exposed as
8//! methods on these types.
9//!
10//! This crate builds on the original [`pathfinding`](https://crates.io/crates/pathfinding)
11//! crate and credits Samuel Tardieu and its contributors for the original
12//! library this indexed-only variant descends from.
13//!
14//! ## Example
15//!
16//! ```rust
17//! use pathfinding_indexed::IndexedGraph;
18//!
19//! let graph = IndexedGraph::from_adjacency(vec![
20//!     vec![(1, 2), (2, 4)],
21//!     vec![(2, 1), (3, 7)],
22//!     vec![(3, 3)],
23//!     vec![],
24//! ]);
25//!
26//! let result = graph.dijkstra(0, |node| node == 3);
27//! assert_eq!(result, Some((vec![0, 1, 2, 3], 6)));
28//! ```
29//!
30//! The minimum supported Rust version (MSRV) is Rust 1.87.0.
31
32mod directed;
33mod noderefs;
34mod undirected;
35
36pub mod indexed_graph;
37
38pub use indexed_graph::{IndexedGraph, IndexedGraphMap, IndexedUndirectedGraph};
39
40use indexmap::{IndexMap, IndexSet};
41use rustc_hash::FxHasher;
42use std::hash::BuildHasherDefault;
43
44type FxIndexMap<K, V> = IndexMap<K, V, BuildHasherDefault<FxHasher>>;
45type FxIndexSet<K> = IndexSet<K, BuildHasherDefault<FxHasher>>;
46
47/// Convenience re-exports for indexed graph types.
48pub mod prelude {
49    pub use crate::indexed_graph::{IndexedGraph, IndexedGraphMap, IndexedUndirectedGraph};
50}