pub fn spanning_tree_count(graph: &Graph) -> IgraphResult<f64>Expand description
Count the number of spanning trees using Kirchhoff’s theorem.
τ(G) = (1/n) · Π_{i=2}^{n} λ_i
Returns 0.0 for disconnected graphs, 1.0 for single-vertex
or edgeless single-component trees. The result is returned as
f64 since spanning tree counts can be astronomically large.
§Examples
use rust_igraph::{Graph, spanning_tree_count};
// K_3: 3 spanning trees
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let count = spanning_tree_count(&g).unwrap();
assert!((count - 3.0).abs() < 0.1);
// K_4: 16 spanning trees
let g4 = Graph::from_edges(
&[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
let c4 = spanning_tree_count(&g4).unwrap();
assert!((c4 - 16.0).abs() < 0.5);