MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_kg_neighbors

Function test_kg_neighbors

atomic-core/src/pristine/txn/write/triples.rs:393–419  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

391
392 #[test]
393 fn test_kg_neighbors() {
394 let dir = tempdir().unwrap();
395 let pristine = Pristine::open(dir.path().join("db")).unwrap();
396 let mut txn = pristine.write_txn().unwrap();
397 txn.init_kg().unwrap();
398
399 txn.upsert_kg_node(&KgNode::new("a", "x", "A", "test"))
400 .unwrap();
401 txn.upsert_kg_node(&KgNode::new("b", "x", "B", "test"))
402 .unwrap();
403 txn.upsert_kg_node(&KgNode::new("c", "x", "C", "test"))
404 .unwrap();
405 txn.upsert_kg_edge(&KgEdge::new("a", "b", "LINK")).unwrap();
406 txn.upsert_kg_edge(&KgEdge::new("b", "c", "LINK")).unwrap();
407
408 // Depth 1 from "a"
409 let sg = txn.kg_neighbors("a", 1).unwrap();
410 assert_eq!(sg.nodes.len(), 2); // a, b
411 assert_eq!(sg.edges.len(), 1); // a→b
412
413 // Depth 2 from "a"
414 let sg = txn.kg_neighbors("a", 2).unwrap();
415 assert_eq!(sg.nodes.len(), 3); // a, b, c
416 assert_eq!(sg.edges.len(), 2); // a→b, b→c
417
418 txn.commit().unwrap();
419 }
420
421 #[test]
422 fn test_kg_fts_search() {

Callers

nothing calls this directly

Calls 8

write_txnMethod · 0.80
upsert_kg_nodeMethod · 0.80
upsert_kg_edgeMethod · 0.80
kg_neighborsMethod · 0.80
commitMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
init_kgMethod · 0.45

Tested by

no test coverage detected