Skip to main content

Graph

Trait Graph 

Source
pub trait Graph<'a, N: 'a, E> {
    type NodeIterator: Iterator<Item = &'a N>;
    type NeighborIterator: Iterator<Item = &'a N>;
    type EdgeIterator: Iterator<Item = (&'a N, &'a N)>;

    // Required methods
    fn order(&self) -> usize;
    fn size(&self) -> usize;
    fn nodes(&'a self) -> Self::NodeIterator;
    fn has_node(&self, node: &N) -> bool;
    fn neighbors(&'a self, node: &N) -> Result<Self::NeighborIterator, E>;
    fn degree(&self, node: &N) -> Result<usize, E>;
    fn edges(&'a self) -> Self::EdgeIterator;
    fn has_edge(&self, source: &N, target: &N) -> Result<bool, E>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}

Required Associated Types§

Required Methods§

Source

fn order(&self) -> usize

Returns the number of nodes in this graph.

Source

fn size(&self) -> usize

Returns the number of edges in this graph.

Source

fn nodes(&'a self) -> Self::NodeIterator

Iterates the nodes of this graph

Source

fn has_node(&self, node: &N) -> bool

Returns true if node is a member, or false otherwise.

Source

fn neighbors(&'a self, node: &N) -> Result<Self::NeighborIterator, E>

Iterates the neighbors of node.

Source

fn degree(&self, node: &N) -> Result<usize, E>

Returns the number of neighbors connected to node.

Source

fn edges(&'a self) -> Self::EdgeIterator

Iterates the edges of this graph.

Source

fn has_edge(&self, source: &N, target: &N) -> Result<bool, E>

Returns true if an edge exists between source and target.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if there are no nodes, or false otherwise.

Implementors§