graph_api_test/index/
edge_label.rs1#[cfg(feature = "edge-label-index")]
2use crate::{assert_elements_eq, populate_graph};
3
4use crate::{Edge, Vertex};
5use graph_api_lib::Graph;
6
7#[cfg(feature = "edge-label-index")]
8pub fn test_index<T>(graph: &mut T)
9where
10 T: Graph<Vertex = Vertex, Edge = Edge> + graph_api_lib::SupportsEdgeLabelIndex,
11{
12 let refs = populate_graph(graph);
13 let collected = graph
14 .walk()
15 .vertices_by_id([refs.bryn])
16 .edges(Edge::knows().outgoing())
17 .collect::<Vec<_>>();
18
19 assert_elements_eq!(graph, collected, vec![refs.bryn_knows_julia])
20}
21
22#[cfg(not(feature = "edge-label-index"))]
23pub fn test_index<T>(_graph: &mut T)
24where
25 T: Graph<Vertex = Vertex, Edge = Edge>,
26{
27}
28
29#[cfg(feature = "edge-label-index")]
30pub fn test_index_limit<T>(graph: &mut T)
31where
32 T: Graph<Vertex = Vertex, Edge = Edge> + graph_api_lib::SupportsEdgeLabelIndex,
33{
34 let refs = populate_graph(graph);
35 let collected = graph
36 .walk()
37 .vertices_by_id([refs.bryn])
38 .edges(Edge::knows().outgoing().with_limit(1))
39 .collect::<Vec<_>>();
40
41 assert_elements_eq!(graph, collected, vec![refs.bryn_knows_julia])
42}
43
44#[cfg(not(feature = "edge-label-index"))]
45pub fn test_index_limit<T>(_graph: &mut T)
46where
47 T: Graph<Vertex = Vertex, Edge = Edge>,
48{
49}