# R code
library(igraph)
bits <- function(x, n) { # decodes binary representation of graphs
list <- NULL
while (x > 0) {
list <- c(list, x %% 2)
x <- x %/% 2
}
while (length(list) < n) {list <- c(list, 0)}
return(list)
}
n<-5 # number of vertices
edges <- choose(n, 2)
models <- 0:(2^edges-1) # all graphs on n vertices
mat <- matrix(rep(0, n^2), ncol=n) #adjacency matrix
nstar <- 0
for (m in models) {
mat[lower.tri(mat)] <- bits(m, hran)
l <- maximal.cliques(graph.adjacency(mat, mode="lower"))
aux <- factor(unlist(l))
l <- lapply(l, setdiff, levels(aux)[tabulate(aux) == 1])
l <- lapply(l, setdiff, l[[which.max(unlist(lapply(l, length)))]])
if (sum(unlist(lapply(l, length))) < 1) nstar <- nstar + 1
}
nstar
|