use graph_api_lib::{EdgeSearch, Graph, VertexSearch};
use graph_api_simplegraph::SimpleGraph;
use graph_api_test::{Edge, Vertex, populate_graph};
fn main() {
let mut graph = SimpleGraph::new();
let refs = populate_graph(&mut graph);
vertex_example(&graph);
edge_example(&graph, refs.bryn);
}
fn vertex_example<G>(graph: &G)
where
G: Graph<Vertex = Vertex, Edge = Edge>,
{
let vertices = graph
.walk()
.vertices(VertexSearch::scan())
.take(2) .collect::<Vec<_>>();
assert!(vertices.len() <= 2);
println!("Retrieved {} vertices (limited to 2)", vertices.len());
}
fn edge_example<G>(graph: &G, start_id: G::VertexId)
where
G: Graph<Vertex = Vertex, Edge = Edge>,
{
let connections = graph
.walk()
.vertices_by_id(vec![start_id])
.edges(EdgeSearch::scan())
.take(3) .collect::<Vec<_>>();
println!("Retrieved {} connections (limited to 3)", connections.len());
}