Hello,
simply create a membership vector (to each vertex its community number). Example with 4 random communities:
library(igraph) g<-erdos.renyi.game(100,3/100) memb<-sample(1:4,100) memb [1] 2 3 1 4 3 2 3 2 1 1 1 1 1 2 2 1 3 2 3 3 2 2 4 4 4 1 4 2 1 1 2 1 2 4 3 1 2 [38] 4 4 3 3 2 4 2 4 3 2 1 1 1 2 3 1 3 1 4 1 2 1 2 1 1 1 2 3 3 1 1 1 3 4 3 3 3 [75] 4 3 4 3 3 3 3 1 4 4 4 2 4 4 4 1 1 1 3 4 1 3 4 1 3 3 modularity(g,memb) [1] 0.003766435
Best, -- Fabio
Hello,
I am trying to compare network scale modularity scores for my network using various community types. The first types are what are generated algorithmically, such as walktrap. However, I would also like to assign each vertex a community of my choosing and calculate modularity using the assigned communities. I have tried to do this by creating a vector that mimics the output of running member() on a walktrap output. The vector: >> v = attrib$edgroup >> names(v) = attrib$vertex
where attrib$edgroup is a column that has my choice of "community" in integer form, and attrib$vertex are the "names" of the vertices in the graph. if I run the following,
>> modularity(graph1,v)
>> modularity(graph1, membership(comms))
What's the best way to do what I'm asking?
Best,
Walter
-- Walter McHugh
Interdisciplinary M.A, Statistical Methods and Data Science
Northeastern University
Boston, MA
_______________________________________________ igraph-help mailing list address@hiddenhttps://lists.nongnu.org/mailman/listinfo/igraph-help
|