graph_api_test/steps/
detour.rs

1use crate::{Edge, Vertex, populate_graph};
2use graph_api_lib::{EdgeSearch, Graph};
3
4pub fn test_vertices_detour<T>(graph: &mut T)
5where
6    T: Graph<Vertex = Vertex, Edge = Edge>,
7{
8    let refs = populate_graph(graph);
9    let collected = graph
10        .walk()
11        .vertices_by_id(vec![refs.bryn, refs.julia])
12        .detour(|w| {
13            w.edges(EdgeSearch::scan().outgoing())
14                .push_default_context()
15                .head()
16                .push_default_context()
17        })
18        .push_default_context()
19        .map(|_, c| {
20            (
21                *c.vertex_id(),
22                *c.parent().parent().edge_id(),
23                *c.parent().vertex_id(),
24            )
25        })
26        .collect::<Vec<_>>();
27    assert_eq!(collected.len(), 3);
28    assert!(collected.contains(&(refs.bryn, refs.bryn_knows_julia, refs.julia)));
29    assert!(collected.contains(&(refs.julia, refs.julia_knows_bryn, refs.bryn)));
30    assert!(collected.contains(&(refs.bryn, refs.bryn_created_graph_api, refs.graph_api)));
31}