hypergraph 3.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,
    VertexIndex,
    VertexTrait,
    core::types::{
        AIndexSet,
        ARandomState,
    },
    errors::HypergraphError,
};

impl<V, HE> Hypergraph<V, HE>
where
    V: VertexTrait,
    HE: HyperedgeTrait,
{
    /// Adds a vertex with a custom weight to the hypergraph.
    /// Returns the index of the vertex.
    ///
    /// Duplicate weights are allowed — vertex identity is the returned
    /// [`VertexIndex`], not the weight value.
    pub fn add_vertex(&mut self, weight: V) -> Result<VertexIndex, HypergraphError<V, HE>> {
        let internal_index = self.vertices.len();
        self.vertices.push((
            weight,
            AIndexSet::with_capacity_and_hasher(0, ARandomState::default()),
        ));
        Ok(self.add_vertex_index(internal_index))
    }
}