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

Function test_kg_neighbors

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

Source from the content-addressed store, hash-verified

525
526 #[test]
527 fn test_kg_neighbors() {
528 let dir = tempdir().unwrap();
529 let pristine = Pristine::open(dir.path().join("db")).unwrap();
530 let mut txn = pristine.write_txn().unwrap();
531 txn.init_kg().unwrap();
532
533 txn.upsert_kg_node(&KgNode::new("a", "x", "A", "test"))
534 .unwrap();
535 txn.upsert_kg_node(&KgNode::new("b", "x", "B", "test"))
536 .unwrap();
537 txn.upsert_kg_node(&KgNode::new("c", "x", "C", "test"))
538 .unwrap();
539 txn.upsert_kg_edge(&KgEdge::new("a", "b", "LINK")).unwrap();
540 txn.upsert_kg_edge(&KgEdge::new("b", "c", "LINK")).unwrap();
541
542 // Depth 1 from "a"
543 let sg = txn.kg_neighbors("a", 1).unwrap();
544 assert_eq!(sg.nodes.len(), 2); // a, b
545 assert_eq!(sg.edges.len(), 1); // a→b
546
547 // Depth 2 from "a"
548 let sg = txn.kg_neighbors("a", 2).unwrap();
549 assert_eq!(sg.nodes.len(), 3); // a, b, c
550 assert_eq!(sg.edges.len(), 2); // a→b, b→c
551
552 txn.commit().unwrap();
553 }
554
555 #[test]
556 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