Skip to content

Commit b0c1bf0

Browse files
author
CindeeM
committed
RF: changed rule to check for eig vectors all of the same sign in Newman Partition
1 parent 0b17484 commit b0c1bf0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

brainx/modularity.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,8 +1352,10 @@ def _divide_partition(p, max_div=np.inf):
13521352
# to nodes in the first partition and 1 for nodes in the second
13531353
v_max = v[:, n]
13541354
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):
1355+
# if the mask is all True or all False, this will not split the partition
1356+
# 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():
13571359
return [p]
13581360
s = np.ones_like(v_max)
13591361
s[mask] = -1

0 commit comments

Comments
 (0)