Neighbors

Trait Neighbors 

Source
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§

Source

type NeighborRef<'a>: NeighborReference<Self::VertexId, Self::EdgeId> where Self: 'a

Reference to a neighbor.

Source

type NeighborsIter<'a>: Iterator<Item = Self::NeighborRef<'a>> where Self: 'a

Iterator over neighbors of a vertex.

Required Methods§

Source

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.

Source

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§

Source

fn degree_undirected(&self, id: &Self::VertexId) -> usize

Returns the total degree of the given vertex.

§Panics

Panics if the vertex does not exist.

Source

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.

Implementations on Foreign Types§

Source§

impl<G> Neighbors for &G
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

fn neighbors_undirected(&self, from: &Self::VertexId) -> Self::NeighborsIter<'_>

Source§

fn neighbors_directed( &self, from: &Self::VertexId, dir: Direction, ) -> Self::NeighborsIter<'_>

Source§

fn degree_undirected(&self, id: &Self::VertexId) -> usize

Source§

fn degree_directed(&self, id: &Self::VertexId, dir: Direction) -> usize

Source§

impl<G> Neighbors for &mut G
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

fn neighbors_undirected(&self, from: &Self::VertexId) -> Self::NeighborsIter<'_>

Source§

fn neighbors_directed( &self, from: &Self::VertexId, dir: Direction, ) -> Self::NeighborsIter<'_>

Source§

fn degree_undirected(&self, id: &Self::VertexId) -> usize

Source§

fn degree_directed(&self, id: &Self::VertexId, dir: Direction) -> usize

Implementors§

Source§

impl<E, G> Neighbors for Complement<E, G>

Source§

type NeighborRef<'a> = NeighborRef<<G as GraphBase>::VertexId, <G as GraphBase>::EdgeId> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<'a, G> where Self: 'a

Source§

impl<G> Neighbors for CastAsDirected<G>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

impl<G> Neighbors for CastAsUndirected<G>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

impl<G> Neighbors for Transpose<G>
where G: Neighbors,

Source§

type NeighborRef<'a> = TransposeRef<<G as Neighbors>::NeighborRef<'a>> where Self: 'a

Source§

type NeighborsIter<'a> = Iter<<G as Neighbors>::NeighborsIter<'a>> where Self: 'a

Source§

impl<G> Neighbors for Undirect<G>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

impl<G> Neighbors for Stable<G>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<'a, G> where Self: 'a

Source§

impl<G, S> Neighbors for Subgraph<G, S>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = SubgraphIter<'a, <G as Neighbors>::NeighborsIter<'a>, <G as Neighbors>::NeighborRef<'a>> where Self: 'a

Source§

impl<V, E, N, F, Ty: EdgeType> Neighbors for Implicit<V, E, N, F, Ty>
where N: IntoIterator<Item = (V, E)>, F: Fn(&V) -> N, ImplicitId<V>: IdType, ImplicitId<E>: IdType,

Source§

type NeighborRef<'a> = NeighborRef<ImplicitId<V>, ImplicitId<E>> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<V, E, <N as IntoIterator>::IntoIter> where Self: 'a

Source§

impl<V, E, Ty: EdgeType, G> Neighbors for Graph<V, E, Ty, G>
where G: Neighbors,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

impl<V, E, Ty: EdgeType, G> Neighbors for Path<V, E, Ty, G>
where G: Neighbors + GraphBase,

Source§

type NeighborRef<'a> = <G as Neighbors>::NeighborRef<'a> where Self: 'a

Source§

type NeighborsIter<'a> = <G as Neighbors>::NeighborsIter<'a> where Self: 'a

Source§

impl<V, E, Ty: EdgeType, Id: IdPair> Neighbors for AdjList<V, E, Ty, Id>

Source§

type NeighborRef<'a> = NeighborRef<<AdjList<V, E, Ty, Id> as GraphBase>::VertexId, <AdjList<V, E, Ty, Id> as GraphBase>::EdgeId> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<'a, Ty, Id> where Self: 'a

Source§

impl<V, E, Ty: EdgeType, Id: IdPair> Neighbors for AdjMatrix<V, E, Ty, Id>

Source§

type NeighborRef<'a> = NeighborRef<<AdjMatrix<V, E, Ty, Id> as GraphBase>::VertexId, <AdjMatrix<V, E, Ty, Id> as GraphBase>::EdgeId> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<'a, Ty, Id> where Self: 'a

Source§

impl<V, E, Ty: EdgeType, Id: IdPair> Neighbors for EdgeList<V, E, Ty, Id>

Source§

type NeighborRef<'a> = NeighborRef<<EdgeList<V, E, Ty, Id> as GraphBase>::VertexId, <EdgeList<V, E, Ty, Id> as GraphBase>::EdgeId> where Self: 'a

Source§

type NeighborsIter<'a> = NeighborsIter<'a, Ty, Id> where Self: 'a