Reputation: 6755
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
Am I doing something wrong?
Upvotes: 0
Views: 66
Reputation: 10825
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)
Upvotes: 4
Reputation: 22293
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)
Upvotes: 1