Skip to main content

hrg_create

Function hrg_create 

Source
pub fn hrg_create(graph: &Graph, prob: &[f64]) -> IgraphResult<HrgTree>
Expand description

Create an HrgTree from a directed binary tree graph.

The input graph must be a directed, simple binary tree with an odd number of vertices 2n-1: n-1 internal vertices (out-degree 2) and n leaves (out-degree 0). Exactly one vertex (the root) must have in-degree 0; all others must have in-degree 1.

prob has one entry per internal vertex. Internal vertices are enumerated as: root first, then remaining internals in ascending vertex-id order.

ยงExample

use rust_igraph::{Graph, hrg_create};

// 5-vertex binary tree: root(0) -> 1,2; vertex 1 -> 3,4
let g = Graph::from_edges(&[(0,1),(0,2),(1,3),(1,4)], true, Some(5)).unwrap();
let prob = vec![0.3, 0.7]; // root=0.3, vertex1=0.7
let hrg = hrg_create(&g, &prob).unwrap();
assert_eq!(hrg.size(), 3);