## DirectedGraph

# Trait DirectedGraph

Source

    pub trait DirectedGraph {
        type Node: Idx;

        // Required method
        fn num_nodes(&self) -> usize;

        // Provided method
        fn iter_nodes(
            &self,
        ) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator { ... }
    }

## Required Associated Types§

Source

#### type Node: Idx

## Required Methods§

Source

#### fn num_nodes(&self) -> usize

Returns the total number of nodes in this graph.

Several graph algorithm implementations assume that every node ID is strictly less than the number of nodes, i.e. nodes are densely numbered. That assumption allows them to use `num_nodes` to allocate per-node data structures, indexed by node.

## Provided Methods§

Source

#### fn iter_nodes( &self, ) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator

Iterates over all nodes of a graph in ascending numeric order.

Assumes that nodes are densely numbered, i.e. every index in `0..num_nodes` is a valid node.

## 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<'graph, G: DirectedGraph> DirectedGraph for &'graph G

Source§

#### type Node = <G as DirectedGraph>::Node

Source§

#### fn num_nodes(&self) -> usize

## Implementors§

Source§

### impl<G: DirectedGraph> DirectedGraph for ReversedGraph<G>

Source§

#### type Node = <G as DirectedGraph>::Node

Source§

### impl<N: Idx, S: Idx + Ord> DirectedGraph for Sccs<N, S>

Source§

#### type Node = S

Source§

### impl<N: Idx, const BR: bool> DirectedGraph for VecGraph<N, BR>

Source§

#### type Node = N