pub fn dag_depth(ipld: &Ipld) -> usizeExpand description
Get the maximum depth of a DAG
Returns the length of the longest path from the root to a leaf node.
§Arguments
ipld- The DAG to measure
§Returns
The maximum depth (0 for leaf nodes, 1+ for containers)
§Example
use ipfrs_core::Ipld;
use ipfrs_core::dag::dag_depth;
let ipld = Ipld::List(vec![
Ipld::Integer(1),
Ipld::List(vec![
Ipld::Integer(2),
Ipld::List(vec![Ipld::Integer(3)]),
]),
]);
assert_eq!(dag_depth(&ipld), 4);