Trait Graph

Source
pub trait Graph<N, E> {
    type NodeIdIterator: Iterator<Item = NodeId>;
    type EdgeIdIterator: Iterator<Item = EdgeId>;

    // Required methods
    fn node_len(&self) -> IdType;
    fn edge_len(&self) -> IdType;
    fn node_id_iter(&self) -> Self::NodeIdIterator;
    fn edge_id_iter(&self) -> Self::EdgeIdIterator;
    fn node_data(&self, id: NodeId) -> &N;
    fn edge_data(&self, id: EdgeId) -> &E;
    fn edge(&self, id: EdgeId) -> EdgeRef<'_, E>;
    fn edge_start(&self, id: EdgeId) -> NodeId;
    fn edge_end(&self, id: EdgeId) -> NodeId;
    fn is_node_id_valid(&self, id: NodeId) -> bool;
    fn is_edge_id_valid(&self, id: EdgeId) -> bool;
}
Expand description

A basic graph.

Graphs defining this trait can act as containers for nodes and edges. Their functionality is very limited though, as not even navigation is defined.

Required Associated Types§

Source

type NodeIdIterator: Iterator<Item = NodeId>

An iterator over all node ids of a graph.

Source

type EdgeIdIterator: Iterator<Item = EdgeId>

An iterator over all edge ids of a graph.

Required Methods§

Source

fn node_len(&self) -> IdType

The amount of nodes in the graph.

Source

fn edge_len(&self) -> IdType

The amount of edges in the graph.

Source

fn node_id_iter(&self) -> Self::NodeIdIterator

Returns an iterator over all node ids in the graph.

Source

fn edge_id_iter(&self) -> Self::EdgeIdIterator

Returns an iterator over all edge ids in the graph.

Source

fn node_data(&self, id: NodeId) -> &N

Returns a reference to a nodes data, identified by the given id.

Source

fn edge_data(&self, id: EdgeId) -> &E

Returns a reference to an edges data, identified by the given id.

Source

fn edge(&self, id: EdgeId) -> EdgeRef<'_, E>

Returns an edge instance, identified by the given id.

Source

fn edge_start(&self, id: EdgeId) -> NodeId

Returns the start node of the edge identified by the given id.

Source

fn edge_end(&self, id: EdgeId) -> NodeId

Returns the end node of the edge identified by the given id.

Source

fn is_node_id_valid(&self, id: NodeId) -> bool

Returns true if the given NodeId refers to a node in this graph.

Source

fn is_edge_id_valid(&self, id: EdgeId) -> bool

Returns true if the given EdgeId refers to an edge in this graph.

Implementors§