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

Method reconstruct_path

nodedb-graph/src/traversal.rs:262–296  ·  view source on GitHub ↗
(
        &self,
        meeting: u32,
        fwd_parent: &HashMap<u32, u32>,
        bwd_parent: &HashMap<u32, u32>,
    )

Source from the content-addressed store, hash-verified

260 }
261
262 fn reconstruct_path(
263 &self,
264 meeting: u32,
265 fwd_parent: &HashMap<u32, u32>,
266 bwd_parent: &HashMap<u32, u32>,
267 ) -> Vec<String> {
268 let mut fwd_path = Vec::new();
269 let mut current = meeting;
270 loop {
271 fwd_path.push(current);
272 let parent = fwd_parent[&current];
273 if parent == current {
274 break;
275 }
276 current = parent;
277 }
278 fwd_path.reverse();
279
280 current = bwd_parent[&meeting];
281 if current != meeting {
282 loop {
283 fwd_path.push(current);
284 let parent = bwd_parent[&current];
285 if parent == current {
286 break;
287 }
288 current = parent;
289 }
290 }
291
292 fwd_path
293 .into_iter()
294 .map(|id| self.id_to_node[id as usize].clone())
295 .collect()
296 }
297
298 /// Materialize a subgraph as edge tuples within max_depth.
299 ///

Callers 1

shortest_pathMethod · 0.80

Calls 3

collectMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected