Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Jul 1, 2024
1 parent 92746a3 commit e1519aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/algorithms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
8 changes: 4 additions & 4 deletions src/algorithms/lca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ 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(),
}
}

/// 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.
Expand Down
5 changes: 3 additions & 2 deletions src/render/mermaid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e1519aa

Please sign in to comment.