rigraphcliqueclique-problem

Remove maximal cliques in igraph


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)

Solution

  • 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))])