Skip to main content

degree_mode

Function degree_mode 

Source
pub fn degree_mode(graph: &Graph) -> IgraphResult<usize>
Expand description

Compute the mode of the degree sequence.

Returns the most frequent degree value. If multiple degrees share the highest frequency, the smallest is returned. Returns 0 for empty graphs.

§Examples

use rust_igraph::{Graph, degree_mode};

// Star S_5: degrees [4,1,1,1,1] → mode = 1
let g = Graph::from_edges(&[(0,1),(0,2),(0,3),(0,4)], false, Some(5)).unwrap();
assert_eq!(degree_mode(&g).unwrap(), 1);