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

Function reconstruct

nodedb/src/control/server/graph_dispatch/shortest_path.rs:168–183  ·  view source on GitHub ↗
(parent: &HashMap<String, String>, src: &str, dst: &str)

Source from the content-addressed store, hash-verified

166}
167
168fn reconstruct(parent: &HashMap<String, String>, src: &str, dst: &str) -> Vec<String> {
169 let mut path: Vec<String> = Vec::new();
170 let mut cursor = dst.to_string();
171 path.push(cursor.clone());
172 while cursor != src {
173 match parent.get(&cursor) {
174 Some(p) => {
175 cursor = p.clone();
176 path.push(cursor.clone());
177 }
178 None => break,
179 }
180 }
181 path.reverse();
182 path
183}

Callers 1

cross_core_shortest_pathFunction · 0.85

Calls 4

to_stringMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected