pub trait DirectedGraph {
type Node: Idx;
// Required method
fn num_nodes(&self) -> usize;
// Provided method
fn iter_nodes(
&self,
) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator { ... }
}
Required Associated Types§
Required Methods§
Sourcefn num_nodes(&self) -> usize
fn num_nodes(&self) -> usize
Returns the total number of nodes in this graph.
Several graph algorithm implementations assume that every node ID is
strictly less than the number of nodes, i.e. nodes are densely numbered.
That assumption allows them to use num_nodes
to allocate per-node
data structures, indexed by node.
Provided Methods§
Sourcefn iter_nodes(
&self,
) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator
fn iter_nodes( &self, ) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator
Iterates over all nodes of a graph in ascending numeric order.
Assumes that nodes are densely numbered, i.e. every index in
0..num_nodes
is a valid node.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.