hypergraph/core/vertices/
get_vertex_weight.rs1use crate::{
2 HyperedgeTrait,
3 Hypergraph,
4 VertexIndex,
5 VertexTrait,
6 errors::HypergraphError,
7};
8
9impl<V, HE> Hypergraph<V, HE>
10where
11 V: VertexTrait,
12 HE: HyperedgeTrait,
13{
14 pub fn get_vertex_weight(
16 &self,
17 vertex_index: VertexIndex,
18 ) -> Result<&V, HypergraphError<V, HE>> {
19 let internal_index = self.get_internal_vertex(vertex_index)?;
20
21 self.vertices
22 .get_index(internal_index)
23 .map(|(weight, _)| weight)
24 .ok_or(HypergraphError::InternalVertexIndexNotFound(internal_index))
25 }
26}