Skip to content

Commit 99451f7

Browse files
Nianle-LiCopilot
andauthored
Apply suggestion from @Copilot
Co-authored-by: Copilot <[email protected]>
1 parent 6a177a6 commit 99451f7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

cpp_easygraph/functions/centrality/eigenvector.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,13 @@ py::object cpp_eigenvector_centrality(
311311

312312
std::vector<bool> isolated_nodes(n, true);
313313
for (int i = 0; i < n; i++) {
314-
if (A_transpose.indptr[i + 1] > A_transpose.indptr[i] + 1) {
314+
// A node is isolated if it has zero edges (no entries in its row)
315+
if (A_transpose.indptr[i + 1] == A_transpose.indptr[i]) {
316+
isolated_nodes[i] = true;
317+
} else {
315318
isolated_nodes[i] = false;
316-
} else if (A_transpose.indptr[i + 1] == A_transpose.indptr[i] + 1) {
317-
int idx = A_transpose.indptr[i];
318-
if (A_transpose.indices[idx] == i && std::abs(A_transpose.data[idx] - 1.0e-4) < 1e-10) {
319-
isolated_nodes[i] = true;
320-
} else {
321-
isolated_nodes[i] = false;
322-
}
323319
}
324-
}
320+
}
325321

326322
std::vector<double> centrality;
327323

0 commit comments

Comments
 (0)