hypergraph 4.0.0

Hypergraph is data structure library to create a directed hypergraph in which an hyperedge can join any number of vertices.
Documentation
use crate::{
    HyperedgeTrait,
    Hypergraph,
    VertexTrait,
};

impl<V, HE> Hypergraph<V, HE>
where
    V: VertexTrait,
    HE: HyperedgeTrait,
{
    /// Returns the number of hyperedges in the hypergraph.
    #[must_use]
    pub fn count_hyperedges(&self) -> usize {
        self.hyperedges.len()
    }
}

#[cfg(test)]
mod tests {
    use crate::{
        Hypergraph,
        core::test_support::{
            E,
            W,
        },
    };

    #[test]
    fn empty_graph_is_zero() {
        let g: Hypergraph<W, E> = Hypergraph::new();
        assert_eq!(g.count_hyperedges(), 0);
    }

    #[test]
    fn after_additions() {
        let mut g: Hypergraph<W, E> = Hypergraph::new();
        let v = g.add_vertex(W(0)).unwrap();
        g.add_hyperedge(vec![v], E(1)).unwrap();
        g.add_hyperedge(vec![v], E(2)).unwrap();
        assert_eq!(g.count_hyperedges(), 2);
    }
}