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

Function diameter_path

nodedb/src/engine/graph/algo/diameter.rs:157–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155
156 #[test]
157 fn diameter_path() {
158 // a - b - c - d (path of length 3).
159 let mut csr = CsrIndex::new();
160 csr.add_edge("a", "L", "b").unwrap();
161 csr.add_edge("b", "L", "c").unwrap();
162 csr.add_edge("c", "L", "d").unwrap();
163 csr.compact().expect("no governor, cannot fail");
164
165 let batch = run(
166 &csr,
167 &AlgoParams {
168 mode: Some("EXACT".into()),
169 ..Default::default()
170 },
171 );
172 let json = batch.to_json().unwrap();
173 let rows: Vec<serde_json::Value> = serde_json::from_slice(&json).unwrap();
174
175 assert_eq!(rows[0]["diameter"].as_i64().unwrap(), 3);
176 assert_eq!(rows[0]["radius"].as_i64().unwrap(), 2);
177 }
178
179 #[test]
180 fn diameter_triangle() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected