igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] "Assigned" Communities and Modularity


From: Fabio Daolio
Subject: Re: [igraph] "Assigned" Communities and Modularity
Date: Wed, 13 May 2015 09:31:37 +0200

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
 
On 12 May 2015, at 23:33, Walter McHugh <address@hidden> wrote:

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)

then R crashes.  I also tried to clone a "communities" object, using instructions from the following URL: https://lists.nongnu.org/archive/html/igraph-help/2012-03/msg00075.html but using the typical syntax also causes R to crash:

>> 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@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

[Prev in Thread] Current Thread [Next in Thread]