pub fn mean_degree(
graph: &Graph,
count_loops: bool,
) -> IgraphResult<Option<f64>>Expand description
Mean degree of the graph.
For directed graphs, returns ecount / vcount (the average out-degree,
which equals the average in-degree). For undirected graphs, returns
2 * ecount / vcount.
If count_loops is false, self-loop edges are excluded from the count.
Returns None for graphs with no vertices.
§Examples
use rust_igraph::{Graph, mean_degree};
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
// 3 edges, 4 vertices, undirected → mean = 2*3/4 = 1.5
assert!((mean_degree(&g, true).unwrap().unwrap() - 1.5).abs() < 1e-10);