Skip to main content

graph_summary

Function graph_summary 

Source
pub fn graph_summary(graph: &Graph) -> IgraphResult<GraphSummary>
Expand description

Compute a quick structural summary of a graph.

Returns a GraphSummary struct with key properties pre-computed: vertex/edge counts, connectivity, density, degree range, and whether the graph has self-loops or multi-edges. The struct implements Display for pretty-printing.

This is the Rust counterpart of python-igraph’s Graph.summary().

§Examples

use rust_igraph::{Graph, graph_summary};

let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();

let s = graph_summary(&g).unwrap();
assert_eq!(s.vcount, 5);
assert_eq!(s.ecount, 4);
assert!(s.connected);
assert_eq!(s.component_count, 1);
assert_eq!(s.min_degree, 1);
assert_eq!(s.max_degree, 2);
assert!(!s.has_loops);
assert!(!s.has_multiple);
println!("{s}");
use rust_igraph::{Graph, graph_summary};

let g = Graph::with_vertices(0);
let s = graph_summary(&g).unwrap();
assert_eq!(s.vcount, 0);
assert_eq!(s.ecount, 0);
assert!(s.connected); // vacuously