| 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() { |