hypergraph/core/vertices/
get_vertex_degree_in.rs

1use crate::{
2    HyperedgeTrait,
3    Hypergraph,
4    VertexIndex,
5    VertexTrait,
6    core::shared::Connection,
7    errors::HypergraphError,
8};
9
10impl<V, HE> Hypergraph<V, HE>
11where
12    V: VertexTrait,
13    HE: HyperedgeTrait,
14{
15    /// Gets the in-degree of a vertex.
16    /// <https://en.wikipedia.org/wiki/Directed_graph#Indegree_and_outdegree>
17    pub fn get_vertex_degree_in(&self, to: VertexIndex) -> Result<usize, HypergraphError<V, HE>> {
18        let results = self.get_connections(&Connection::Out(to))?;
19
20        Ok(results.len())
21    }
22}