Skip to main content

maximal_cliques

Function maximal_cliques 

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

Returns all maximal cliques in the graph.

A maximal clique is a clique that cannot be extended by adding another adjacent vertex. Uses the Bron-Kerbosch algorithm with pivoting.

Edge directions are ignored for directed graphs.

ยงExamples

use rust_igraph::{Graph, maximal_cliques};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();

let cliques = maximal_cliques(&g).unwrap();
// Path graph: each edge is a maximal clique
assert_eq!(cliques.len(), 3);