petgraph::visit

Trait GetAdjacencyMatrix

Source
pub trait GetAdjacencyMatrix: GraphBase {
    type AdjMatrix;

    // Required methods
    fn adjacency_matrix(&self) -> Self::AdjMatrix;
    fn is_adjacent(
        &self,
        matrix: &Self::AdjMatrix,
        a: Self::NodeId,
        b: Self::NodeId,
    ) -> bool;
}
Expand description

Create or access the adjacency matrix of a graph.

The implementor can either create an adjacency matrix, or it can return a placeholder if it has the needed representation internally.

Required Associated Types§

Source

type AdjMatrix

The associated adjacency matrix type

Required Methods§

Source

fn adjacency_matrix(&self) -> Self::AdjMatrix

Create the adjacency matrix

Source

fn is_adjacent( &self, matrix: &Self::AdjMatrix, a: Self::NodeId, b: Self::NodeId, ) -> bool

Return true if there is an edge from a to b, false otherwise.

Computes in O(1) time.

Implementations on Foreign Types§

Source§

impl<'a, G> GetAdjacencyMatrix for &'a G

Source§

type AdjMatrix = <G as GetAdjacencyMatrix>::AdjMatrix

Source§

fn adjacency_matrix(&self) -> Self::AdjMatrix

Source§

fn is_adjacent( &self, matrix: &Self::AdjMatrix, a: Self::NodeId, b: Self::NodeId, ) -> bool

Implementors§

Source§

impl<'a, G> GetAdjacencyMatrix for Frozen<'a, G>

Source§

impl<'a, N, E, Ty, Ix> GetAdjacencyMatrix for &'a Csr<N, E, Ty, Ix>
where Ix: IndexType, Ty: EdgeType,

The adjacency matrix for Csr is a bitmap that’s computed by .adjacency_matrix().

Source§

impl<E, Ix> GetAdjacencyMatrix for List<E, Ix>
where Ix: IndexType,

The adjacency matrix for List is a bitmap that’s computed by .adjacency_matrix().

Source§

impl<G> GetAdjacencyMatrix for Reversed<G>

Source§

impl<N, E, Ty, Ix> GetAdjacencyMatrix for Graph<N, E, Ty, Ix>
where Ty: EdgeType, Ix: IndexType,

The adjacency matrix for Graph is a bitmap that’s computed by .adjacency_matrix().

Source§

impl<N, E, Ty, Ix> GetAdjacencyMatrix for StableGraph<N, E, Ty, Ix>
where Ty: EdgeType, Ix: IndexType,

The adjacency matrix for Graph is a bitmap that’s computed by .adjacency_matrix().

Source§

impl<N, E, Ty, S> GetAdjacencyMatrix for GraphMap<N, E, Ty, S>
where N: Copy + Ord + Hash, Ty: EdgeType, S: BuildHasher,

The GraphMap keeps an adjacency matrix internally.

Source§

impl<N, E, Ty: EdgeType, Null: Nullable<Wrapped = E>, Ix: IndexType> GetAdjacencyMatrix for MatrixGraph<N, E, Ty, Null, Ix>