Christos Hatzis
2012-Nov-01 03:15 UTC
[R] possible bug with largest.cliques in igraph_0.6-3
There is a problem with the largest clique computation in the recent version of igraph.> library(igraph) > adj <- matrix(1, nrow=11, ncol=11) - diag(11) > g <- graph.adjacency(adj) > largest.cliques(g)[[1]] [1] 10 8 1 [[2]] [1] 9 7 1 [[3]] [1] 8 7 1 Warning message: In largest.cliques(g) : At cliques.c:958 :directionality of edges is ignored for directed graphs> sessionInfo()R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] igraph_0.6-3 ---------------------------------------------------------- An older version of igraph gave the correct answer> library(igraph) > adj <- matrix(1, nrow=11, ncol=11) - diag(11) > g <- graph.adjacency(adj) > largest.cliques(g)[[1]] [1] 0 1 2 3 4 5 6 7 8 9 10 Warning message: In largest.cliques(g) : At cliques.c:801 :directionality of edges is ignored for directed graphs> sessionInfo()R version 2.12.2 (2011-02-25) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] igraph_0.5.5-3 Thanks. Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 999 Broadway, Suite 301 Saugus, MA 01906
Indeed this seems to be a bug, if the graph is directed. The workaround is to convert it to an undirected graph, the clique computation ignores direction anyway: library(igraph) adj <- matrix(1, nrow=11, ncol=11) - diag(11) g <- graph.adjacency(adj) largest.cliques(g) # [[1]] # [1] 10 8 1 # # [[2]] # [1] 9 7 1 # # [[3]] # [1] 8 7 1 largest.cliques(as.undirected(g)) # [[1]] # [1] 1 2 3 4 5 6 7 8 9 10 11 Btw. please do not send igraph bug reports to r-help, either send them to igraph-help (see http://igraph.sf.net), to me directly, or, the best for us, report the bug at https://bugs.launchpad.net/igraph. Thanks. I have reported a bug for this, you can follow it here, in case you are interested: https://bugs.launchpad.net/igraph/+bug/1073800 On Wed, Oct 31, 2012 at 11:15 PM, Christos Hatzis <christos.hatzis at nuverabio.com> wrote:> There is a problem with the largest clique computation in the recent version > of igraph.[...]