Trait petgraph::visit::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<N, E, Ty> GetAdjacencyMatrix for GraphMap<N, E, Ty>
where N: Copy + Ord + Hash, Ty: EdgeType,

The GraphMap keeps an adjacency matrix internally.

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, 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().