1use nova_boot_graphdb::{GraphEdge, GraphNode, NovaGraphDb};
2use std::collections::HashMap;
3
4#[tokio::main]
5async fn main() {
6 let graph = NovaGraphDb::in_memory();
8
9 let mut props = HashMap::new();
10 props.insert("name".to_string(), serde_json::json!("Alice"));
11 let node = GraphNode {
12 id: "n1".to_string(),
13 labels: vec!["Person".to_string()],
14 properties: props,
15 };
16
17 graph.upsert_node(node).await.unwrap();
18
19 let mut props2 = HashMap::new();
20 props2.insert("name".to_string(), serde_json::json!("Bob"));
21 let node2 = GraphNode {
22 id: "n2".to_string(),
23 labels: vec!["Person".to_string()],
24 properties: props2,
25 };
26
27 graph.upsert_node(node2).await.unwrap();
28
29 let edge = GraphEdge {
30 id: "e1".to_string(),
31 from: "n1".to_string(),
32 to: "n2".to_string(),
33 rel_type: "FRIEND".to_string(),
34 properties: HashMap::new(),
35 };
36
37 graph.upsert_edge(edge).await.unwrap();
38
39 let sub = graph.traverse_json("n1", 2).await.unwrap();
40 println!("subgraph: {}", sub);
41}