Skip to main content

is_clique

Function is_clique 

Source
pub fn is_clique(
    graph: &Graph,
    vertices: &[VertexId],
    directed: bool,
) -> IgraphResult<bool>
Expand description

Check whether a set of vertices forms a clique.

A clique is a set of vertices in which every pair is adjacent. An empty set and a singleton set are always considered cliques.

For directed graphs, if directed is true, requires edges in both directions (u→v and v→u) for every pair. If false, an edge in either direction suffices.

§Examples

use rust_igraph::{Graph, is_clique};

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();
assert!(is_clique(&g, &[0, 1, 2], false).unwrap());
assert!(!is_clique(&g, &[0, 1, 2, 3], false).unwrap());