MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / large_graph_bfs

Function large_graph_bfs

nodedb-graph/src/traversal.rs:454–476  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

452
453 #[test]
454 fn large_graph_bfs() {
455 let mut csr = CsrIndex::new();
456 for i in 0..999 {
457 csr.add_edge(&format!("n{i}"), "NEXT", &format!("n{}", i + 1))
458 .unwrap();
459 }
460 csr.compact().expect("no governor, cannot fail");
461
462 let result = csr.traverse_bfs(
463 &["n0"],
464 Some("NEXT"),
465 Direction::Out,
466 100,
467 DEFAULT_MAX_VISITED,
468 None,
469 );
470 assert_eq!(result.len(), 101);
471
472 let path = csr
473 .shortest_path("n0", "n50", Some("NEXT"), 100, DEFAULT_MAX_VISITED, None)
474 .unwrap();
475 assert_eq!(path.len(), 51);
476 }
477
478 /// BFS with a frontier bitmap that includes only "b". Starting from "a",
479 /// "b" is reachable but "c" is blocked (its surrogate is not in the bitmap).

Callers

nothing calls this directly

Calls 5

add_edgeMethod · 0.80
traverse_bfsMethod · 0.80
shortest_pathMethod · 0.80
expectMethod · 0.45
compactMethod · 0.45

Tested by

no test coverage detected