Skip to main content

largest_weighted_cliques

Function largest_weighted_cliques 

Source
pub fn largest_weighted_cliques(
    graph: &Graph,
    vertex_weights: &[f64],
) -> IgraphResult<Vec<Vec<VertexId>>>
Expand description

Returns every clique of maximum total weight.

The weight of a clique is the sum of its vertex weights (positive integer weights, truncated to their integer parts). There may be several cliques tying for the largest weight; all of them are returned, each sorted ascending, and the list itself is sorted lexicographically. Because all weights are positive, every maximum-weight clique is maximal.

This is the counterpart of igraph’s igraph_largest_weighted_cliques.

Edge directions are ignored for directed graphs.

§Errors

Returns IgraphError::InvalidArgument if vertex_weights has the wrong length or any (truncated) weight is not a positive integer.

§Examples

use rust_igraph::{Graph, largest_weighted_cliques};

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 cs = largest_weighted_cliques(&g, &[1.0, 1.0, 1.0, 5.0]).unwrap();
assert_eq!(cs, vec![vec![2, 3]]);