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

Function harmonic_complete

nodedb/src/engine/graph/algo/harmonic.rs:131–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129
130 #[test]
131 fn harmonic_complete() {
132 // Fully connected 3-node graph: HC = 1.0 for all.
133 let mut csr = CsrIndex::new();
134 for (s, d) in &[
135 ("a", "b"),
136 ("b", "a"),
137 ("b", "c"),
138 ("c", "b"),
139 ("a", "c"),
140 ("c", "a"),
141 ] {
142 csr.add_edge(s, "L", d).unwrap();
143 }
144 csr.compact().expect("no governor, cannot fail");
145
146 let batch = run(&csr);
147 let json = batch.to_json().unwrap();
148 let rows: Vec<serde_json::Value> = serde_json::from_slice(&json).unwrap();
149 for row in &rows {
150 let c = row["centrality"].as_f64().unwrap();
151 assert!((c - 1.0).abs() < 1e-9);
152 }
153 }
154
155 #[test]
156 fn harmonic_empty() {

Callers

nothing calls this directly

Calls 6

add_edgeMethod · 0.80
runFunction · 0.70
expectMethod · 0.45
compactMethod · 0.45
to_jsonMethod · 0.45
as_f64Method · 0.45

Tested by

no test coverage detected