Remove maximal cliques in igraph

62 views Asked by At

I have a disconnected undirected network. I want to identify and remove all the components that are cliques. I do not want to remove all the cliques, just those that are themselves a component of the network.

How should I proceed?

library(igraph)
g <- graph_from_literal(a-b-c-d-b,e-f-g-e,h-i-l)
result <- graph_from_literal(a-b-c-d-b,h-i-l)
1

There are 1 answers

0
MCS On BEST ANSWER

One solution is the following, but I do not know to what extent this is efficient in large networks.

d <- graph_from_literal(a-b-c-d-b,e-f-g-e,h-i-l)
d0 <- decompose.graph(d)
d1 <- disjoint_union(d0[unlist(lapply(d0, function(x) count_max_cliques(x)!=1))])