capability_feature_measurement/
weighted_branching.rs1crate::ix!();
3
4pub trait TreeWeightedBranchingMeasurer {
12 fn measure_tree_weighted_branching(&self) -> TreeWeightedBranchingStats;
13}
14
15#[derive(Debug, Clone, PartialEq, derive_builder::Builder, getset::Getters)]
18#[builder(pattern = "owned", setter(into), build_fn(skip))]
19#[getset(get = "pub")]
20pub struct TreeWeightedBranchingStats {
21 #[builder(default)]
22 total_nodes_in_tree: usize,
23
24 #[builder(default)]
25 total_child_count_in_tree: usize,
26
27 #[builder(default)]
28 min_child_count_in_tree: u8,
29
30 #[builder(default)]
31 max_child_count_in_tree: u8,
32
33 #[builder(default)]
34 average_child_count_in_tree: f32,
35}
36
37impl Default for TreeWeightedBranchingStats {
38 fn default() -> Self {
39 Self {
40 total_nodes_in_tree: 0,
41 total_child_count_in_tree: 0,
42 min_child_count_in_tree: 0,
43 max_child_count_in_tree: 0,
44 average_child_count_in_tree: 0.0,
45 }
46 }
47}
48
49impl TreeWeightedBranchingStatsBuilder {
50 pub fn build(&self) -> Result<TreeWeightedBranchingStats, derive_builder::UninitializedFieldError> {
51 let stats = TreeWeightedBranchingStats {
52 total_nodes_in_tree: self.total_nodes_in_tree.unwrap_or_default(),
53 total_child_count_in_tree: self.total_child_count_in_tree.unwrap_or_default(),
54 min_child_count_in_tree: self.min_child_count_in_tree.unwrap_or_default(),
55 max_child_count_in_tree: self.max_child_count_in_tree.unwrap_or_default(),
56 average_child_count_in_tree: self.average_child_count_in_tree.unwrap_or_default(),
57 };
58 Ok(stats)
59 }
60}