graph_api_test/index/
edge_label.rs

1use crate::{Edge, Vertex, assert_elements_eq, populate_graph};
2use graph_api_lib::{Graph, SupportsEdgeLabelIndex};
3
4pub fn test_index<T>(graph: &mut T)
5where
6    T: Graph<Vertex = Vertex, Edge = Edge> + SupportsEdgeLabelIndex,
7{
8    let refs = populate_graph(graph);
9    let collected = graph
10        .walk()
11        .vertices_by_id([refs.bryn])
12        .edges(Edge::knows().outgoing())
13        .collect::<Vec<_>>();
14
15    assert_elements_eq!(graph, collected, vec![refs.bryn_knows_julia])
16}
17
18pub fn test_index_limit<T>(graph: &mut T)
19where
20    T: Graph<Vertex = Vertex, Edge = Edge> + SupportsEdgeLabelIndex,
21{
22    let refs = populate_graph(graph);
23    let collected = graph
24        .walk()
25        .vertices_by_id([refs.bryn])
26        .edges(Edge::knows().outgoing().with_limit(1))
27        .collect::<Vec<_>>();
28
29    assert_elements_eq!(graph, collected, vec![refs.bryn_knows_julia])
30}