igraph-help
[Top][All Lists]

## Re: [igraph] Modularity (Q) based on the Louvain split, unexpected value

 From: Szabolcs Horvát Subject: Re: [igraph] Modularity (Q) based on the Louvain split, unexpected values Date: Sun, 29 Mar 2020 15:14:25 +0200

I would recommend posting the question on https://igraph.discourse.group/ as that forum is meant to replace this mailing list, and provides a nicer discussion environment.

On Sun, 29 Mar 2020 at 15:08, serafim loukas <address@hidden> wrote:
Just to add that I just found the python version of BCT (the Matlab toolbox that I used to benchmark igraph).

Using this: https://github.com/aestrivex/bctpy/blob/f9526a693a9af57051762442d8490dcdf2ebf4e3/bct/algorithms/modularity.py#L71, again I get approx. 0.1466 that matches the Matlab based results but is far from the python output (Q).

Makis

On 29 Mar 2020, at 14:56, serafim loukas <address@hidden> wrote:

Hi igraph community,

I have a graph and I want to estimate the modularity (Q) based on the Louvain split of the graph.

In python I used igraph and to compare, I also estimated Q in Matlab.
Based on igraph, the Q is negative (weird) whereas the Q based on the Matlab estimation is possitive.

I would expect differences in the values but not by so far (+ shows modularity, - shows anti-modularity).
Any idea why this happens?

Makis

———————————

My code and data:

PYTHON

```
import numpy as np
import scipy.io
from igraph import *

Louvain = graph.community_multilevel(weights=graph.es['weight'], return_levels=False)
Q = graph.modularity(Louvain)
print(Q)

-0.001847596203445795
```

using community_louvain.m: Louvain community detection algorithm

```
clear all
[M,Q]=community_louvain(A);

Q =

0.1466
```

<A.mat>_______________________________________________
igraph-help mailing list