pub struct DagMetrics {
pub avg_branching_factor: f64,
pub max_branching_factor: usize,
pub width: usize,
pub total_nodes: usize,
pub avg_leaf_depth: f64,
}Expand description
Additional DAG metrics beyond basic statistics.
Provides advanced graph-theoretic metrics for analyzing DAG structure.
Fields§
§avg_branching_factor: f64Average branching factor (average number of children per non-leaf node)
max_branching_factor: usizeMaximum branching factor (maximum number of children for any node)
width: usizeWidth of the DAG (maximum number of nodes at any level)
total_nodes: usizeTotal number of nodes in the DAG
avg_leaf_depth: f64Average depth of leaf nodes
Implementations§
Source§impl DagMetrics
impl DagMetrics
Sourcepub fn from_ipld(ipld: &Ipld) -> Self
pub fn from_ipld(ipld: &Ipld) -> Self
Calculate advanced metrics for an IPLD structure.
§Arguments
ipld- The IPLD data to analyze
§Returns
Advanced metrics about the DAG structure
§Examples
use ipfrs_core::{Ipld, CidBuilder};
use ipfrs_core::dag::DagMetrics;
use std::collections::BTreeMap;
let cid = CidBuilder::new().build(b"data").unwrap();
let mut map = BTreeMap::new();
map.insert("link1".to_string(), Ipld::link(cid.clone()));
map.insert("link2".to_string(), Ipld::link(cid));
let ipld = Ipld::Map(map);
let metrics = DagMetrics::from_ipld(&ipld);
assert_eq!(metrics.max_branching_factor, 2);Trait Implementations§
Source§impl Clone for DagMetrics
impl Clone for DagMetrics
Source§fn clone(&self) -> DagMetrics
fn clone(&self) -> DagMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DagMetrics
impl Debug for DagMetrics
Source§impl Default for DagMetrics
impl Default for DagMetrics
Source§fn default() -> DagMetrics
fn default() -> DagMetrics
Returns the “default value” for a type. Read more
Source§impl PartialEq for DagMetrics
impl PartialEq for DagMetrics
impl StructuralPartialEq for DagMetrics
Auto Trait Implementations§
impl Freeze for DagMetrics
impl RefUnwindSafe for DagMetrics
impl Send for DagMetrics
impl Sync for DagMetrics
impl Unpin for DagMetrics
impl UnwindSafe for DagMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more