Skip to main content

rich_club_sequence

Function rich_club_sequence 

Source
pub fn rich_club_sequence(
    graph: &Graph,
    weights: Option<&[f64]>,
    vertex_order: &[VertexId],
    normalized: bool,
    loops: bool,
    directed: bool,
) -> IgraphResult<Vec<f64>>
Expand description

Per-vertex rich-club coefficient sequence for graph.

Returns a Vec<f64> of length graph.vcount() whose i-th entry is the density (normalized = true) or raw edge count (normalized = false) of the subgraph that survives after removing the first i vertices of vertex_order from graph.

Counterpart of igraph_rich_club_sequence — see the module-level docs for the full mapping of arguments and semantics.

§Arguments

  • graph — input graph.
  • weights — optional per-edge weights of length ecount(). When None, every edge contributes 1.0.
  • vertex_order — permutation of 0..vcount() giving the order in which vertices are peeled off.
  • normalized — when true, divide the surviving edge count at each step by the total possible edges on the remaining vertices; when false, return the raw remaining edge count (or summed weight).
  • loops — whether self-loops are assumed possible (affects the normalization denominator only; ignored when !normalized).
  • directed — whether to use the directed denominator when normalizing. Silently coerced to false when graph is undirected.

§Errors

  • IgraphError::InvalidArgument — when:
    • vertex_order.len() != graph.vcount() as usize,
    • weights.is_some() and weights.unwrap().len() != graph.ecount(),
    • any entry of vertex_order is >= graph.vcount() (i.e. it is not a valid permutation of 0..vcount).

§Examples

use rust_igraph::{Graph, rich_club_sequence};

// Triangle K_3: after 0 removals → 3 edges, after 1 → 1, after 2 → 0.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
let seq = rich_club_sequence(&g, None, &[0, 1, 2], false, false, false).unwrap();
assert_eq!(seq, vec![3.0, 1.0, 0.0]);