Skip to main content

clique_size_hist

Function clique_size_hist 

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

Returns a histogram of clique sizes, counting all cliques.

A clique is any complete subgraph (not necessarily maximal). The result is a vector where index k holds the number of cliques of size k, including every single vertex (size 1) and every edge (size 2). Index 0 is always 0 (no cliques of size 0 exist). The vector length is clique_number + 1.

This is the counterpart of igraph’s igraph_clique_size_hist. Note that igraph stores the size-1 count in element 0; here index equals the clique size with element 0 left as a zero placeholder, matching the convention of the rest of this crate. For maximal cliques only, see maximal_cliques_hist.

Edge directions are ignored for directed graphs.

§Examples

use rust_igraph::{Graph, clique_size_hist};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
let hist = clique_size_hist(&g).unwrap();
// 4 vertices, 4 edges, 1 triangle {0,1,2}
assert_eq!(hist, vec![0, 4, 4, 1]);