bug fixed with dependencies on deleted notes

This commit is contained in:
aaron-jack-manning
2022-09-14 20:37:36 +10:00
parent 182efe568a
commit 1cfd481484
2 changed files with 19 additions and 6 deletions

View File

@@ -48,15 +48,21 @@ impl Graph {
}
}
pub fn remove_node(&mut self, node : Id) -> bool {
/// Returns a boolean indicating if the graph was changed (it contained the node) and a
/// set of all dependents on the removed node.
pub fn remove_node(&mut self, node : Id) -> (bool, HashSet<Id>) {
let mut dependents = HashSet::new();
if self.edges.remove(&node).is_some() {
for outgoing in self.edges.values_mut() {
outgoing.remove(&node);
for (&dependent, outgoing) in &mut self.edges {
if outgoing.remove(&node) {
dependents.insert(dependent);
}
}
true
(true, dependents)
}
else {
false
(false, dependents)
}
}