Skip to main content

coreness

Function coreness 

Source
pub fn coreness(graph: &Graph) -> IgraphResult<Vec<u32>>
Expand description

Per-vertex coreness number.

Returns Vec<u32> of length vcount: result[v] is the highest k such that v belongs to the k-core. The empty graph yields an empty vector. Self-loops contribute 2 to a vertex’s degree (matches upstream IGRAPH_LOOPS).

§Examples

use rust_igraph::{Graph, coreness};

// K3 triangle: every vertex has degree 2 in a graph where the
// minimum degree is 2 → coreness 2 for all three.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(0, 2).unwrap();
assert_eq!(coreness(&g).unwrap(), vec![2, 2, 2]);