We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b17484 commit b0c1bf0Copy full SHA for b0c1bf0
brainx/modularity.py
@@ -1352,8 +1352,10 @@ def _divide_partition(p, max_div=np.inf):
1352
# to nodes in the first partition and 1 for nodes in the second
1353
v_max = v[:, n]
1354
mask = (v_max < 0)
1355
- # if the mask is all true or all false, this will not split the partition
1356
- if not np.any(mask) or not np.any(~mask):
+ # if the mask is all True or all False, this will not split the partition
+ # and would create an empty partition
1357
+ # catch by checking max vector contains pos and neg values
1358
+ if np.abs(v_max.sum()) == np.abs(v_max).sum():
1359
return [p]
1360
s = np.ones_like(v_max)
1361
s[mask] = -1
0 commit comments