#![allow(clippy::unwrap_used, clippy::expect_used)]
use issundb_core::Graph;
use serde_json::json;
fn main() {
let path_str = std::env::args()
.nth(1)
.expect("usage: gen_testdata <output_dir>");
let path = std::path::Path::new(&path_str);
std::fs::create_dir_all(path).expect("create output dir");
let g = Graph::open(path, 1).expect("open graph");
let people = [
json!({ "name": "Alice", "age": 30, "bio": "Alice enjoys distributed systems and graph databases." }),
json!({ "name": "Bob", "age": 25, "bio": "Bob is a software engineer interested in search and retrieval." }),
json!({ "name": "Carol", "age": 35, "bio": "Carol researches machine learning and vector embeddings." }),
json!({ "name": "Dave", "age": 28, "bio": "Dave works on full-text indexing and information retrieval." }),
json!({ "name": "Eve", "age": 31, "bio": "Eve specializes in graph algorithms and network analysis." }),
];
let mut person_ids = Vec::with_capacity(5);
for props in &people {
let id = g.add_node("Person", props).expect("add Person node");
person_ids.push(id);
}
let [alice, bob, carol, dave, eve] = person_ids[..] else {
panic!("expected exactly 5 Person nodes");
};
let company_id = g
.add_node(
"Company",
&json!({ "name": "Acme Corp", "industry": "Technology" }),
)
.expect("add Company node");
let no_props = json!({});
let knows_edges = [
(alice, bob),
(bob, carol),
(carol, dave),
(dave, eve),
(alice, carol),
(eve, bob),
];
let mut edge_ids = Vec::with_capacity(8);
for (src, dst) in knows_edges {
let eid = g
.add_edge(src, dst, "KNOWS", &no_props)
.expect("add KNOWS edge");
edge_ids.push(eid);
}
for person in [alice, bob] {
let eid = g
.add_edge(person, company_id, "WORKS_AT", &no_props)
.expect("add WORKS_AT edge");
edge_ids.push(eid);
}
let n_nodes = 6; let n_edges = edge_ids.len();
println!("Generated test data at {:?}", path);
println!(" Nodes: {n_nodes}");
println!(" Edges: {n_edges}");
}