Trait FiniteGraph

Source
pub trait FiniteGraph: GraphType {
    type NodeIt<'a>: GraphIterator<Self, Item = Self::Node<'a>>
       where Self: 'a;
    type EdgeIt<'a>: GraphIterator<Self, Item = Self::Edge<'a>>
       where Self: 'a;

    // Required methods
    fn num_nodes(&self) -> usize;
    fn num_edges(&self) -> usize;
    fn nodes_iter(&self) -> Self::NodeIt<'_>;
    fn edges_iter(&self) -> Self::EdgeIt<'_>;
    fn enodes(&self, e: Self::Edge<'_>) -> (Self::Node<'_>, Self::Node<'_>);

    // Provided methods
    fn nodes(&self) -> NodeIterator<'_, Self>
       where Self: Sized { ... }
    fn edges(&self) -> EdgeIterator<'_, Self>
       where Self: Sized { ... }
}
Expand description

A (finite) graph with a known number of nodes and edges.

Finite graphs also provide access to the list of all nodes and edges.

Required Associated Types§

Source

type NodeIt<'a>: GraphIterator<Self, Item = Self::Node<'a>> where Self: 'a

Type of an iterator over all nodes.

Source

type EdgeIt<'a>: GraphIterator<Self, Item = Self::Edge<'a>> where Self: 'a

Type of an iterator over all edges.

Required Methods§

Source

fn num_nodes(&self) -> usize

Return the number of nodes in the graph.

Source

fn num_edges(&self) -> usize

Return the number of edges in the graph.

Source

fn nodes_iter(&self) -> Self::NodeIt<'_>

Return a graph iterator over all nodes.

Source

fn edges_iter(&self) -> Self::EdgeIt<'_>

Return a graph iterator over all edges.

This iterator traverses only the forward edges.

Source

fn enodes(&self, e: Self::Edge<'_>) -> (Self::Node<'_>, Self::Node<'_>)

Return the nodes connected by an edge.

The order of the nodes is undefined.

Provided Methods§

Source

fn nodes(&self) -> NodeIterator<'_, Self>
where Self: Sized,

Return an iterator over all nodes.

Source

fn edges(&self) -> EdgeIterator<'_, Self>
where Self: Sized,

Return an iterator over all edges.

This iterator traverses only the forward edges.

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, G> FiniteGraph for &'g G
where G: FiniteGraph,

Source§

type NodeIt<'a> = WrapIt<<G as FiniteGraph>::NodeIt<'a>> where G: 'a, 'g: 'a

Source§

type EdgeIt<'a> = WrapIt<<G as FiniteGraph>::EdgeIt<'a>> where G: 'a, 'g: 'a

Source§

fn num_nodes(&self) -> usize

Source§

fn nodes_iter(&self) -> Self::NodeIt<'_>

Source§

fn num_edges(&self) -> usize

Source§

fn edges_iter(&self) -> Self::EdgeIt<'_>

Source§

fn enodes(&self, e: Self::Edge<'_>) -> (Self::Node<'_>, Self::Node<'_>)

Source§

impl<G> FiniteGraph for Rc<G>
where G: FiniteGraph,

Source§

type NodeIt<'a> = WrapIt<<G as FiniteGraph>::NodeIt<'a>> where G: 'a

Source§

type EdgeIt<'a> = WrapIt<<G as FiniteGraph>::EdgeIt<'a>> where G: 'a

Source§

fn num_nodes(&self) -> usize

Source§

fn nodes_iter(&self) -> Self::NodeIt<'_>

Source§

fn num_edges(&self) -> usize

Source§

fn edges_iter(&self) -> Self::EdgeIt<'_>

Source§

fn enodes(&self, e: Self::Edge<'_>) -> (Self::Node<'_>, Self::Node<'_>)

Implementors§

Source§

impl<'g, G> FiniteGraph for Network<'g, G>
where G: FiniteGraph,

Source§

type NodeIt<'a> = NetworkNodeIt<<G as FiniteGraph>::NodeIt<'a>> where G: 'a, 'g: 'a

Source§

type EdgeIt<'a> = NetworkEdgeIt<G, <G as FiniteGraph>::EdgeIt<'a>> where G: 'a, 'g: 'a

Source§

impl<'g, G> FiniteGraph for ReverseDigraph<'g, G>
where G: FiniteGraph,

Source§

type NodeIt<'a> = ReverseWrapIt<<G as FiniteGraph>::NodeIt<'a>> where G: 'a, 'g: 'a

Source§

type EdgeIt<'a> = ReverseWrapIt<<G as FiniteGraph>::EdgeIt<'a>> where G: 'a, 'g: 'a

Source§

impl<ID> FiniteGraph for VecGraph<ID>
where ID: PrimInt + Unsigned,

Source§

type NodeIt<'a> = NodeIt<ID> where ID: 'a

Source§

type EdgeIt<'a> = EdgeIt<ID> where ID: 'a

Source§

impl<ID, N, E> FiniteGraph for LinkedListGraph<ID, N, E>
where ID: PrimInt + Unsigned + 'static,

Source§

type NodeIt<'a> = NodeIt<ID> where N: 'a, E: 'a

Source§

type EdgeIt<'a> = EdgeIt<ID> where N: 'a, E: 'a