Skip to content

fix: preserve nodes with unassigned community level in filtering#2259

Open
Br1an67 wants to merge 1 commit intomicrosoft:mainfrom
Br1an67:fix/issue-1808-preserve-unleveled-nodes
Open

fix: preserve nodes with unassigned community level in filtering#2259
Br1an67 wants to merge 1 commit intomicrosoft:mainfrom
Br1an67:fix/issue-1808-preserve-unleveled-nodes

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Description

Fix _filter_under_community_level to retain nodes where level is NaN, which represent isolated nodes not assigned to any community by the Leiden algorithm. Previously these nodes were silently dropped because NaN comparisons always evaluate to False in pandas, causing approximately 10% data loss.

Related Issues

Fixes #1808

Proposed Changes

  • Add | df.level.isna() condition to _filter_under_community_level so NaN-level nodes are preserved
  • Add unit tests verifying both NaN preservation and correct level filtering

Checklist

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have updated the documentation (if necessary).
  • I have added appropriate unit tests (if applicable).

Additional Notes

Downstream code already handles NaN community values with fillna(-1), so preserving these nodes is consistent with the existing data flow.

Modify _filter_under_community_level to retain nodes where level is NaN,
which represent isolated nodes not assigned to any community by the
Leiden algorithm. Previously these nodes were silently dropped because
NaN comparisons always evaluate to False in pandas.

Fixes microsoft#1808
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fatal Bug]: Nodes Missing Community and Level Attributes Are Excluded During Query Execution

1 participant