Pergunta

I have a problem while plotting the communities. Please consider the following MWE

library(igraph)

m <- matrix(c(0,0,0,0,0,0,
              1,0,0,0,0,0,
              0,0,0,0,1,0,
              4,1,0,0,0,0,
              0,0,0,0,0,1,
              0,0,0,0,0,0),nrow=6,ncol=6)

g <- graph.adjacency(m)
memb <- membership(edge.betweenness.community(g))
memb
# [1] 1 1 2 1 2 2

I then expect to see two communities in the plot when doing

plot(g, mark.groups=list(memb), edge.width=0.5, edge.arrow.width=0.2) 

But actually I get only one community

enter image description here

Am I doing something wrong?

Foi útil?

Solução 2

If I understand your question correctly, then you are using the mark.groups argument wrong. Try

plot(g, 
     mark.groups=lapply(unique(memb), function(n) which(memb==n)), 
     edge.width=0.5, 
     edge.arrow.width=0.2)

Outras dicas

You can plot the result of the community structure detection, the communities object, instead of plotting the graph. See the example in ?plot.communities.

ebc <- edge.betweenness.community(g)
plot(ebc, g)

plot

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top