stacked_linear_algebra_graph/graph/vertex_store/vertex_vector/operations/
indexing.rs

1use graphblas_sparse_linear_algebra::collections::sparse_vector::operations::{
2    is_element, try_is_element,
3};
4
5use crate::error::GraphComputingError;
6use crate::graph::indexing::GetVertexIndexIndex;
7use crate::graph::vertex_store::VertexVector;
8
9pub(crate) trait IsElementInVertexVector {
10    fn is_vertex_element(
11        &self,
12        vertex_index: &impl GetVertexIndexIndex,
13    ) -> Result<bool, GraphComputingError>;
14
15    fn try_is_vertex_element(
16        &self,
17        vertex_index: &impl GetVertexIndexIndex,
18    ) -> Result<(), GraphComputingError>;
19}
20
21impl IsElementInVertexVector for VertexVector {
22    fn is_vertex_element(
23        &self,
24        vertex_index: &impl GetVertexIndexIndex,
25    ) -> Result<bool, GraphComputingError> {
26        Ok(is_element(self, *vertex_index.index_ref())?)
27    }
28
29    fn try_is_vertex_element(
30        &self,
31        vertex_index: &impl GetVertexIndexIndex,
32    ) -> Result<(), GraphComputingError> {
33        Ok(try_is_element(self, *vertex_index.index_ref())?)
34    }
35}