hypergraph/core/hyperedges/
get_hyperedge.rs

1use crate::{
2    HyperedgeIndex,
3    HyperedgeTrait,
4    Hypergraph,
5    VertexTrait,
6    errors::HypergraphError,
7};
8
9impl<V, HE> Hypergraph<V, HE>
10where
11    V: VertexTrait,
12    HE: HyperedgeTrait,
13{
14    // Private method to get the HyperedgeIndex matching an internal index.
15    pub(crate) fn get_hyperedge(
16        &self,
17        hyperedge_index: usize,
18    ) -> Result<HyperedgeIndex, HypergraphError<V, HE>> {
19        match self.hyperedges_mapping.left.get(&hyperedge_index) {
20            Some(index) => Ok(*index),
21            None => Err(HypergraphError::InternalHyperedgeIndexNotFound(
22                hyperedge_index,
23            )),
24        }
25    }
26}