algograph 0.4.0

A (both directed and undirected) graph and their algorithms implemented in Rust
Documentation
/// ID for vertices, which are essentially `usize`.
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct VertexId(pub usize);

/// A factory to generate `VertexId` uniquely.
#[derive(Clone)]
pub struct VertexIdFactory(usize);

impl Default for VertexIdFactory {
    fn default() -> Self {
        Self::new()
    }
}

impl VertexIdFactory {
    pub fn new() -> Self {
        Self(0)
    }

    pub fn one_more(&mut self) -> VertexId {
        let cur = self.0;
        self.0 += 1;
        VertexId(cur)
    }
}

impl VertexId {
    pub const MIN: VertexId = VertexId(0);
    pub const MAX: VertexId = VertexId(usize::MAX);

    pub fn new(x: usize) -> Self {
        Self(x)
    }

    pub fn to_raw(&self) -> usize {
        self.0
    }

    pub fn next(&self) -> Self {
        Self(self.0 + 1)
    }
}