pub trait Neighbors: GraphBase {
type NeighborRef<'a>: NeighborReference<Self::VertexId, Self::EdgeId>
where Self: 'a;
type NeighborsIter<'a>: Iterator<Item = Self::NeighborRef<'a>>
where Self: 'a;
// Required methods
fn neighbors_undirected(
&self,
from: &Self::VertexId,
) -> Self::NeighborsIter<'_>;
fn neighbors_directed(
&self,
from: &Self::VertexId,
dir: Direction,
) -> Self::NeighborsIter<'_>;
// Provided methods
fn degree_undirected(&self, id: &Self::VertexId) -> usize { ... }
fn degree_directed(&self, id: &Self::VertexId, dir: Direction) -> usize { ... }
}Expand description
Trait for traversing vertex neighbors in a graph.
§Implementation notes
Required Associated Types§
Sourcetype NeighborRef<'a>: NeighborReference<Self::VertexId, Self::EdgeId>
where
Self: 'a
type NeighborRef<'a>: NeighborReference<Self::VertexId, Self::EdgeId> where Self: 'a
Reference to a neighbor.
Sourcetype NeighborsIter<'a>: Iterator<Item = Self::NeighborRef<'a>>
where
Self: 'a
type NeighborsIter<'a>: Iterator<Item = Self::NeighborRef<'a>> where Self: 'a
Iterator over neighbors of a vertex.
Required Methods§
Sourcefn neighbors_undirected(&self, from: &Self::VertexId) -> Self::NeighborsIter<'_>
fn neighbors_undirected(&self, from: &Self::VertexId) -> Self::NeighborsIter<'_>
Returns all neighbors of the given vertex, regardless of edge direction.
In directed graphs, this means outgoing as well as incoming edges.
§Panics
Panics if the vertex does not exist.
Sourcefn neighbors_directed(
&self,
from: &Self::VertexId,
dir: Direction,
) -> Self::NeighborsIter<'_>
fn neighbors_directed( &self, from: &Self::VertexId, dir: Direction, ) -> Self::NeighborsIter<'_>
Returns all neighbors of the given vertex in the given direction.
In undirected graphs the edge direction is ignored and the returned items are the same as from neighbors_undirected.
§Panics
Panics if the vertex does not exist.
Provided Methods§
Sourcefn degree_undirected(&self, id: &Self::VertexId) -> usize
fn degree_undirected(&self, id: &Self::VertexId) -> usize
Sourcefn degree_directed(&self, id: &Self::VertexId, dir: Direction) -> usize
fn degree_directed(&self, id: &Self::VertexId, dir: Direction) -> usize
Returns the out or in degree of the given vertex, depending on the edge direction argument.
In undirected graphs the direction is ignored and the returned value is the same as from degree_undirected.
§Panics
Panics if the vertex does not exist.
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.