Skip to content

Commit 0b17484

Browse files
author
CindeeM
committed
BF: add catch in Newman Partition for partition with 1 or fewer edges
1 parent 9d8db5e commit 0b17484

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

brainx/modularity.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,9 @@ def _divide_partition(p, max_div=np.inf):
13351335
# Construct the subgraph modularity matrix
13361336
A_ = A[p, p[:, None]]
13371337
graph_A_ = nx.from_numpy_matrix(A_, nx.Graph())
1338+
# make sure partition has edges
1339+
if graph_A_.number_of_edges() <= 1:
1340+
return [p]
13381341
B_ = modularity_matrix(graph_A_)
13391342
w, v = sl.eigh(B_, eigvals=(len(B_) - 2, len(B_) - 1))
13401343

0 commit comments

Comments
 (0)