pub struct Lattice { /* private fields */ }Expand description
A directed acyclic lattice with one start node and one end node.
Nodes are addressed by zero-based indices. Arcs must move from lower to higher node indices so distance algorithms can process the lattice in topological order.
Implementations§
Source§impl Lattice
impl Lattice
Sourcepub fn from_edges(
node_count: usize,
start: usize,
end: usize,
arcs: Vec<Arc>,
) -> Result<Self, LatticeError>
pub fn from_edges( node_count: usize, start: usize, end: usize, arcs: Vec<Arc>, ) -> Result<Self, LatticeError>
Builds a lattice from explicit nodes and arcs.
start and end must be valid node indices with start <= end.
Every arc must reference valid nodes and satisfy src < dst.
Sourcepub fn from_paths<I, S>(paths: I) -> Self
pub fn from_paths<I, S>(paths: I) -> Self
Builds a lattice from UTF-8 string paths.
§Panics
Panics when paths is empty or when empty and non-empty paths are
mixed. Use Lattice::try_from_paths to handle those cases as input
errors.
Sourcepub fn try_from_paths<I, S>(paths: I) -> Result<Self, LatticeError>
pub fn try_from_paths<I, S>(paths: I) -> Result<Self, LatticeError>
Builds a lattice from UTF-8 string paths.
Sourcepub fn from_symbol_paths<I, P>(paths: I) -> Self
pub fn from_symbol_paths<I, P>(paths: I) -> Self
Builds a lattice from symbol paths.
§Panics
Panics when paths is empty or when empty and non-empty paths are
mixed. Use Lattice::try_from_symbol_paths to handle those cases as
input errors.
Sourcepub fn try_from_symbol_paths<I, P>(paths: I) -> Result<Self, LatticeError>
pub fn try_from_symbol_paths<I, P>(paths: I) -> Result<Self, LatticeError>
Builds a lattice from symbol paths.
Sourcepub fn from_symbol_paths_compact<I, P>(paths: I) -> Self
pub fn from_symbol_paths_compact<I, P>(paths: I) -> Self
Builds a compact lattice from symbol paths by sharing common suffixes.
§Panics
Panics when paths is empty or when empty and non-empty paths are
mixed. Use Lattice::try_from_symbol_paths_compact to handle those
cases as input errors.
Sourcepub fn try_from_symbol_paths_compact<I, P>(
paths: I,
) -> Result<Self, LatticeError>
pub fn try_from_symbol_paths_compact<I, P>( paths: I, ) -> Result<Self, LatticeError>
Builds a compact lattice from symbol paths by sharing common suffixes.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes in the lattice.
Sourcepub fn try_incoming_arcs(
&self,
node: usize,
) -> Option<impl Iterator<Item = &Arc>>
pub fn try_incoming_arcs( &self, node: usize, ) -> Option<impl Iterator<Item = &Arc>>
Returns incoming arcs for node, or None when the node index is out
of range.