crate::ix!();
pub trait TreeWeightedBranchingMeasurer {
fn measure_tree_weighted_branching(&self) -> TreeWeightedBranchingStats;
}
#[derive(Debug, Clone, PartialEq, derive_builder::Builder, getset::Getters)]
#[builder(pattern = "owned", setter(into), build_fn(skip))]
#[getset(get = "pub")]
pub struct TreeWeightedBranchingStats {
#[builder(default)]
total_nodes_in_tree: usize,
#[builder(default)]
total_child_count_in_tree: usize,
#[builder(default)]
min_child_count_in_tree: u8,
#[builder(default)]
max_child_count_in_tree: u8,
#[builder(default)]
average_child_count_in_tree: f32,
}
impl Default for TreeWeightedBranchingStats {
fn default() -> Self {
Self {
total_nodes_in_tree: 0,
total_child_count_in_tree: 0,
min_child_count_in_tree: 0,
max_child_count_in_tree: 0,
average_child_count_in_tree: 0.0,
}
}
}
impl TreeWeightedBranchingStatsBuilder {
pub fn build(&self) -> Result<TreeWeightedBranchingStats, derive_builder::UninitializedFieldError> {
let stats = TreeWeightedBranchingStats {
total_nodes_in_tree: self.total_nodes_in_tree.unwrap_or_default(),
total_child_count_in_tree: self.total_child_count_in_tree.unwrap_or_default(),
min_child_count_in_tree: self.min_child_count_in_tree.unwrap_or_default(),
max_child_count_in_tree: self.max_child_count_in_tree.unwrap_or_default(),
average_child_count_in_tree: self.average_child_count_in_tree.unwrap_or_default(),
};
Ok(stats)
}
}