pub trait Axis: Copy + PartialEq {
    type Direction: AxisDirection;

    const COUNT: usize;
    const DIRECTED: bool;
    const UNDIRECTED_COUNT: usize;

    fn to_index(&self) -> usize;
fn from_index(index: usize) -> Option<Self>
    where
        Self: Sized
;
fn foward(self) -> Self::Direction;
fn backward(self) -> Self::Direction;
fn from_direction(dir: Self::Direction) -> Self; unsafe fn from_index_unchecked(index: usize) -> Self { ... }
fn is_forward_direction(dir: &Self::Direction) -> bool { ... } }
Expand description

Axis of the graph. It holds what direction of edge which node has.

Associated Types

For tricks to optimize for undirected graph, and not to regress performance of directed graph. If the axis is DIRECTED, should set Self.

Associated Constants

Number of axis.

Whether it is Directed or not.

Number of direction. If this axis is not directed, it is COUNT * 2, otherwise COUNT.

Required methods

Convert to index.

Convert form index.

To forward direction. It is nop when Axis is DIRECTED.

To backward direction. It reverses when Axis is DIRECTED.

Convert from direction.

Provided methods

Convert form index.

Check the direction is forward for this axis. Returns true if the direction is DIRECTED is true, or the index of the axis and direction matches.

Implementors