igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] modularity in dense weighted networks with spinglass.commu


From: Gábor Csárdi
Subject: Re: [igraph] modularity in dense weighted networks with spinglass.community
Date: Tue, 16 Mar 2010 14:09:58 +0100

OK, the explanation is pretty simple. In the unweighted case, one has
to give explicitly

sc2 <- spinglass.community(g, weights=rep(1, ecount(g)))

otherwise the weights will be used. If one does that, then the two
modularity values are the same.

In the weighted case, the spinglass code normalizes by the number of
edges and the modularity function normalizes by the sum of the
weights, hence the difference.

I'll modify the spinglass code, to normalize by the sum of the
weights. I think this is a better approach.

Actually, the spinglass code always reports the Newman-type
modularity, not the generalized quantity. Maybe this should be updated
as well. Together with the spinglass.community() interface, to be
consistent with other functions that have a 'weights' argument.

Thanks again for the report!

Best Regards,
Gabor

On Mon, Mar 15, 2010 at 5:29 PM, Aaron Alexander-Bloch
<address@hidden> wrote:
> Thank you both,
> I'm eager to hear what you find Gabor.
> Best,
> Aaron
>
> On Fri, Mar 5, 2010 at 11:32 PM, Gábor Csárdi <address@hidden> wrote:
>>
>> Hi Aaron,
>>
>> hmmm, you are right, something strange is going on here, if I run the
>> following:
>>
>> R
>>
>> library(igraph)
>>
>> largest.component <- function(x) {
>>  cl <- clusters(x)
>>  ss <- which(cl$membership == which.max(cl$csize)-1)-1
>>  subgraph(x, ss)
>> }
>>
>> g <- largest.component(erdos.renyi.game(100, p=5/100))
>> E(g)$weight <- runif(ecount(g))
>> sc <- spinglass.community(g, weights=E(g)$weight)
>> sc$modularity
>> modularity(g, sc$membership, weights=E(g)$weight)
>>
>> sc2 <- spinglass.community(g)
>> sc2$modularity
>> modularity(g, sc2$membership)
>>
>> # I get
>>
>> > sc$modularity
>> [1] 0.2808567
>> > modularity(g, sc$membership, weights=E(g)$weight)
>> [1] 0.4861468
>> >
>> > sc2 <- spinglass.community(g)
>> > sc2$modularity
>> [1] 0.2737963
>> > modularity(g, sc2$membership)
>> [1] 0.3635749
>>
>> which is clearly different, both in the weighted and unweighted case.
>> For spinglass.community we just use the modularity value calculated by
>> the community detection code, as implemented by the original author of
>> the algorithm.
>>
>> I will check why the two values are not the same. Thanks for your report!
>>
>> Best,
>> Gabor
>>
>> On Tue, Mar 2, 2010 at 9:05 PM, Aaron Alexander-Bloch
>> <address@hidden> wrote:
>> > Hi - Thanks in advance for any help.
>> >
>> > I'm trying to apply spinglass.community in the R package to dense
>> > weighted
>> > networks and have some trouble interpreting the modularity value in my
>> > results. I'm assuming that $modularity is the value of the Hamiltonian
>> > as in
>> > the Reichardt/Bornholdt paper. As I'm keeping the gamma parameter at 1
>> > and
>> > using the 'config' model, my understanding is that the Hamiltonian is
>> > the
>> > same as Newman's modularity, at least for binary graphs. But I'm not
>> > clear
>> > on how these concepts are related for weighted graphs. If I separately
>> > get
>> > the modularity value of the partition that spinglass gives me, it is
>> > different from the modularity value given by spinglass directly. So my
>> > question is how should the modularity value given by spinglass be
>> > interpreted for weighted graphs?
>> >
>> > In a related question, is there any plan to implement the "weighted
>> > version"
>> > of this method as in Heimo (2008)
>> >
>> > http://iopscience.iop.org/1742-5468/2008/08/P08007/
>> >
>> > Thanks very much!
>> > Aaron
>> >
>> > _______________________________________________
>> > igraph-help mailing list
>> > address@hidden
>> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>>
>>
>>
>> --
>> Gabor Csardi <address@hidden>     UNIL DGM
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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