[Top][All Lists]

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

[igraph] Modularity (Q) based on the Louvain split, unexpected values

From: serafim loukas
Subject: [igraph] Modularity (Q) based on the Louvain split, unexpected values
Date: Sun, 29 Mar 2020 12:56:16 +0000

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?



My code and data:


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

A = scipy.io.loadmat('A.mat')['A']

graph = Graph.Weighted_Adjacency(A.tolist(), mode=ADJ_UNDIRECTED, 
attr="weight", loops=False)
Louvain = graph.community_multilevel(weights=graph.es['weight'], 
Q = graph.modularity(Louvain)


MATLAB (https://sites.google.com/site/bctnet/measures/list)
using community_louvain.m: Louvain community detection algorithm

clear all

Q =


Attachment: A.mat
Description: A.mat

reply via email to

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