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

Function graph_split_minimizes_cross_edges

nodedb-cluster/src/shard_split.rs:266–283  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

264
265 #[test]
266 fn graph_split_minimizes_cross_edges() {
267 // Chain: a→b→c→d→e. Splitting at midpoint should produce
268 // fewer cross-edges than random split.
269 let nodes: Vec<String> = vec!["a", "b", "c", "d", "e"]
270 .into_iter()
271 .map(|s| s.to_string())
272 .collect();
273 let edges: Vec<(String, String)> = vec![
274 ("a".into(), "b".into()),
275 ("b".into(), "c".into()),
276 ("c".into(), "d".into()),
277 ("d".into(), "e".into()),
278 ];
279 let plan = plan_graph_split(10, 20, 3, &nodes, &edges);
280 // 5 nodes split: mid = 5/2 = 2, so 3 docs move (5 - 2).
281 assert_eq!(plan.documents_to_move.len(), 3);
282 assert_eq!(plan.strategy, SplitStrategy::GraphCommunity);
283 }
284
285 #[test]
286 fn graph_split_empty() {

Callers

nothing calls this directly

Calls 3

plan_graph_splitFunction · 0.85
collectMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected