From ac1891c07947e4e6f97d10f767e5a3559e2c5b4c Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Tue, 11 Jul 2023 15:33:31 +0100 Subject: [PATCH] fix: Ignore hierarchy elements that are not in the graph when displaying --- src/dot.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dot.rs b/src/dot.rs index 4a45f31..34a9cda 100644 --- a/src/dot.rs +++ b/src/dot.rs @@ -336,17 +336,20 @@ where dot.push_str(&node_str); // Connect the parent to any existing children - forest.children(n).for_each(|child| { - dot.push_str(&{ - let from_node = n; - let to_node = child; - format!( - "{} -> {} [style = \"dashed\"] \n", - hier_node_id(from_node), - hier_node_id(to_node), - ) + forest + .children(n) + .filter(|c| self.graph.contains_node(c)) + .for_each(|child| { + dot.push_str(&{ + let from_node = n; + let to_node = child; + format!( + "{} -> {} [style = \"dashed\"] \n", + hier_node_id(from_node), + hier_node_id(to_node), + ) + }); }); - }); } } }