pub struct IndexedGraphMap<N, C> { /* private fields */ }Expand description
Helper that maps external node values to dense indices and builds an indexed graph.
Implementations§
Source§impl<N, C> IndexedGraphMap<N, C>
impl<N, C> IndexedGraphMap<N, C>
Sourcepub fn from_nodes_and_successors<I, FN, IN>(nodes: I, successors: FN) -> Self
pub fn from_nodes_and_successors<I, FN, IN>(nodes: I, successors: FN) -> Self
Build a mapped graph from seed nodes and a successor function.
Sourcepub const fn graph(&self) -> &IndexedGraph<C>
pub const fn graph(&self) -> &IndexedGraph<C>
Return the indexed graph.
Sourcepub fn into_graph(self) -> IndexedGraph<C>
pub fn into_graph(self) -> IndexedGraph<C>
Return the indexed graph, consuming the mapping helper.
Sourcepub const fn node_count(&self) -> usize
pub const fn node_count(&self) -> usize
Return the number of nodes in the mapped graph.
Source§impl IndexedGraphMap<(usize, usize), usize>
impl IndexedGraphMap<(usize, usize), usize>
Sourcepub fn from_walkable_matrix_4(
matrix: &[Vec<bool>],
) -> Result<Self, IndexedInputError>
pub fn from_walkable_matrix_4( matrix: &[Vec<bool>], ) -> Result<Self, IndexedInputError>
Build a mapped graph from a boolean matrix with 4-neighbor connectivity.
true cells are walkable and become nodes labeled by (row, column).
§Errors
Returns IndexedInputError::RaggedMatrix if rows have different lengths.
§Example
use pathfinding_indexed::IndexedGraphMap;
let mapped = IndexedGraphMap::from_walkable_matrix_4(&[
vec![true, true, false],
vec![false, true, true],
])
.unwrap();
let start = mapped.index_of(&(0, 0)).unwrap();
let goal = mapped.index_of(&(1, 2)).unwrap();
let result = mapped.graph().dijkstra(start, |node| node == goal);
assert_eq!(result.map(|(_, cost)| cost), Some(3));Sourcepub fn from_walkable_matrix_8(
matrix: &[Vec<bool>],
) -> Result<Self, IndexedInputError>
pub fn from_walkable_matrix_8( matrix: &[Vec<bool>], ) -> Result<Self, IndexedInputError>
Build a mapped graph from a boolean matrix with 8-neighbor connectivity.
true cells are walkable and become nodes labeled by (row, column).
§Errors
Returns IndexedInputError::RaggedMatrix if rows have different lengths.
Sourcepub fn from_walkable_cells_4<F>(
rows: usize,
columns: usize,
walkable: F,
) -> Self
pub fn from_walkable_cells_4<F>( rows: usize, columns: usize, walkable: F, ) -> Self
Build a mapped graph from grid dimensions and a walkability predicate using 4-neighbor connectivity.
Trait Implementations§
Source§impl<N: Clone, C: Clone> Clone for IndexedGraphMap<N, C>
impl<N: Clone, C: Clone> Clone for IndexedGraphMap<N, C>
Source§fn clone(&self) -> IndexedGraphMap<N, C>
fn clone(&self) -> IndexedGraphMap<N, C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more