use graph_api_lib::{Graph, SupportsVertexLabelIndex};
use graph_api_simplegraph::SimpleGraph;
use graph_api_test::Edge;
use graph_api_test::Project;
use graph_api_test::Vertex;
use graph_api_test::populate_graph;
fn main() {
let mut graph = SimpleGraph::new();
let _refs = populate_graph(&mut graph);
basic_example(&mut graph);
}
fn basic_example<G>(graph: &mut G)
where
G: Graph<Vertex = Vertex, Edge = Edge> + SupportsVertexLabelIndex,
{
let new_project_id = graph.add_vertex(Vertex::Project(Project {
name: "NewProject".to_string(),
}));
let mutations_count = graph
.walk_mut() .vertices(Vertex::person())
.mutate(|graph, person_id, _| {
graph.add_edge(person_id, new_project_id, Edge::Created);
});
assert!(mutations_count >= 2);
println!(
"Created {} edges connecting people to the project",
mutations_count
);
}