File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
hypergraphx/communities/hypergraph_mt Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -248,14 +248,15 @@ def _check_fit_params(
248248 hypergraph .get_sizes ()
249249 ) # TODO: check whether we want to refactor the name of this variable
250250
251- # Isolated nodes.
252- self .isolates = np .where (self .incidence .getnnz (1 ) == 0 )[
253- 0
254- ] # TODO: implement it as a core method
255- # Non-isolated nodes.
256- self .non_isolates = np .where (self .incidence .getnnz (1 ) != 0 )[
257- 0
258- ] # TODO: implement it as a core method
251+ row_sums = self .incidence .sum (axis = 1 )
252+ # If row_sums is a matrix (e.g., from sparse), convert to 1D array
253+ if hasattr (row_sums , "A1" ):
254+ row_sums = row_sums .A1
255+ else :
256+ row_sums = np .asarray (row_sums ).flatten ()
257+
258+ self .isolates = np .where (row_sums == 0 )[0 ]
259+ self .non_isolates = np .where (row_sums != 0 )[0 ]
259260
260261 # Normalize u such that every row sums to 1.
261262 self .normalizeU = normalizeU
You can’t perform that action at this time.
0 commit comments