Skip to main content

maximal_cliques_hist

Function maximal_cliques_hist 

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

Returns a histogram of maximal clique sizes.

A maximal clique cannot be extended by adding an adjacent vertex. The result is a vector where index k holds the number of maximal cliques of size k. Maximal cliques of size 1 are exactly the isolated vertices. Index 0 is always 0. The vector length is clique_number + 1.

This is the counterpart of igraph’s igraph_maximal_cliques_hist. As with clique_size_hist, index equals the clique size (element 0 is a zero placeholder), whereas igraph stores the size-1 count in element 0. To count all cliques (not just maximal ones), use clique_size_hist.

Edge directions are ignored for directed graphs.

§Examples

use rust_igraph::{Graph, maximal_cliques_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 = maximal_cliques_hist(&g).unwrap();
// maximal cliques: edge {2,3} (size 2), triangle {0,1,2} (size 3)
assert_eq!(hist, vec![0, 0, 1, 1]);