Skip to content

fix: correct negative edge extraction and directed rewiring in signed - #138

Merged
aestrivex merged 1 commit into
aestrivex:masterfrom
YashBhardwaj21:fix/signed-null-models
Jul 8, 2026
Merged

fix: correct negative edge extraction and directed rewiring in signed#138
aestrivex merged 1 commit into
aestrivex:masterfrom
YashBhardwaj21:fix/signed-null-models

Conversation

@YashBhardwaj21

Copy link
Copy Markdown
Contributor

Fixes #137
Fix 1: Introduced inline multiplication by s during strength and sorted-weight extraction (e.g., Si = np.sum(W * Acur * s) and Wv = np.sort(W[Acur] * s)) in both null_model_und_sign and null_model_dir_sign. This ensures the algorithm extracts positive magnitudes during the negative branch, restoring the original MATLAB logic (where -W.*An was used).

Fix 2: Changed the rewiring call inside null_model_dir_sign from randmio_und_signed to randmio_dir_signed to correctly preserve asymmetric directed topology and independent in/out degree distributions.

Tests: Added comprehensive regression tests in test_null_model_sign.py to verify that negative edges are preserved and that exact per-node positive and negative degree distributions are perfectly maintained.

@aestrivex
aestrivex merged commit c28931c into aestrivex:master Jul 8, 2026
0 of 4 checks passed
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.

null_model_und_sign and null_model_dir_sign do not preserve negative weights and null_model_dir_sign also uses an undirected rewiring function

2 participants