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

Function parse_results

nodedb/src/engine/graph/algo/sssp.rs:132–144  ·  view source on GitHub ↗
(batch: &AlgoResultBatch)

Source from the content-addressed store, hash-verified

130 }
131
132 fn parse_results(batch: &AlgoResultBatch) -> std::collections::HashMap<String, f64> {
133 let json = batch.to_json().unwrap();
134 let rows: Vec<serde_json::Value> = serde_json::from_slice(&json).unwrap();
135 rows.iter()
136 .map(|r| {
137 (
138 r["node_id"].as_str().unwrap().to_string(),
139 // f64::INFINITY serializes as null in JSON.
140 r["distance"].as_f64().unwrap_or(f64::INFINITY),
141 )
142 })
143 .collect()
144 }
145
146 #[test]
147 fn sssp_shortest_via_relay() {

Callers 5

sssp_shortest_via_relayFunction · 0.85
sssp_unreachable_nodeFunction · 0.85
sssp_single_nodeFunction · 0.85
sssp_diamond_graphFunction · 0.85

Calls 6

collectMethod · 0.80
to_stringMethod · 0.80
to_jsonMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45
as_f64Method · 0.45

Tested by 5

sssp_shortest_via_relayFunction · 0.68
sssp_unreachable_nodeFunction · 0.68
sssp_single_nodeFunction · 0.68
sssp_diamond_graphFunction · 0.68