diff --git a/src/algorithms.rs b/src/algorithms.rs index 6864d67..0ba382d 100644 --- a/src/algorithms.rs +++ b/src/algorithms.rs @@ -12,4 +12,4 @@ pub use post_order::{postorder, postorder_filtered, PostOrder}; pub use toposort::{toposort, toposort_filtered, TopoSort}; // We will make it public once an efficient implementation is available. -pub(crate) use lca::{lca, LCA}; +pub(crate) use lca::{lca, LowestCommonAncestor}; diff --git a/src/algorithms/lca.rs b/src/algorithms/lca.rs index 3c46f8f..a540e3d 100644 --- a/src/algorithms/lca.rs +++ b/src/algorithms/lca.rs @@ -5,8 +5,8 @@ use std::collections::HashSet; use crate::{Hierarchy, NodeIndex}; /// Constructs a new lowest common ancestor data structure. -pub fn lca(hierarchy: &Hierarchy) -> LCA { - LCA { +pub fn lca(hierarchy: &Hierarchy) -> LowestCommonAncestor { + LowestCommonAncestor { hierarchy: hierarchy.clone(), } } @@ -14,11 +14,11 @@ pub fn lca(hierarchy: &Hierarchy) -> LCA { /// A precomputed data structure for lowest common ancestor queries between /// nodes in a hierarchy. #[derive(Debug, Clone)] -pub struct LCA { +pub struct LowestCommonAncestor { hierarchy: Hierarchy, } -impl LCA { +impl LowestCommonAncestor { /// Returns the lowest common ancestor of two nodes. pub fn lca(&self, a: NodeIndex, b: NodeIndex) -> Option<NodeIndex> { // Placeholder slow implementation. diff --git a/src/render/mermaid.rs b/src/render/mermaid.rs index ade0cec..619a0f3 100644 --- a/src/render/mermaid.rs +++ b/src/render/mermaid.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::fmt::Display; -use crate::algorithms::{lca, LCA}; +use crate::algorithms::{lca, LowestCommonAncestor}; use crate::{Hierarchy, LinkView, NodeIndex, Weights}; use super::{EdgeStyle, NodeStyle}; @@ -110,13 +110,14 @@ where } // Delay emitting edges until we are in a region that is the parent of both the source and target nodes. + #[allow(clippy::type_complexity)] let mut edges: HashMap< Option<NodeIndex>, Vec<(NodeIndex, G::LinkEndpoint, NodeIndex, G::LinkEndpoint)>, > = HashMap::new(); // An efficient structure for retrieving the lowest common ancestor of two nodes. - let lca: Option<LCA> = self.forest.map(lca); + let lca: Option<LowestCommonAncestor> = self.forest.map(lca); while let Some(instr) = exploration_stack.pop() { match instr {