fix(test): networkx HITS test used a degenerate cycle graph (scipy-version flaky) - #1686
Merged
Merged
Conversation
…rsion flaky) test_compute_networkx_hits_outputs_hubs_and_authorities used a pure directed 3-cycle a->b->c->a. A cycle's adjacency is a permutation matrix (all singular values equal), so networkx HITS via scipy `svds(k=1)` returns an ARBITRARY vector from the fully-degenerate singular space. Its components can sum to ~0, so HITS's `h /= h.sum()` normalization blows up to inf/nan. Which vector svds returns is scipy/LAPACK-version dependent, so the test passed on the pinned scipy but failed on the `nx-upper-scipy` CI profile's newer scipy -- a latent flake, not a code regression. Use a graph with a well-defined hub/authority structure (a->b, a->c, b->c): its dominant singular vector is unique (Perron-Frobenius), so HITS scores are stable and version-independent. All 12 networkx tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_compute_networkx_hits_outputs_hubs_and_authoritiesfails on the CItest-networkx-scipy-policy (nx-upper-scipy, py3.12)job:Root cause — degenerate test input, not a code regression
The test graph was a pure directed 3-cycle
a→b→c→a. A cycle's adjacency is a permutation matrix, so all its singular values are equal — the singular space is fully degenerate. networkx's HITS computes scores viascipy.sparse.linalg.svds(A, k=1), which then returns an arbitrary vector from that degenerate space. When the returned vector's components sum to ~0, HITS's normalizationh /= h.sum()blows up toinf/nan.Which vector
svdsreturns depends on the scipy/LAPACK version, so the test passed on the pinned scipy but fails on thenx-upper-scipyprofile's newer scipy. It's a latent flake exposed by dependency drift, independent of any product code.Fix
Use a graph with a well-defined hub/authority structure (
a→b,a→c,b→c). Its dominant singular vector is unique (Perron-Frobenius), so HITS scores are stable and version-independent:Test-only change; all 12 networkx tests pass. This unblocks CI on the default branch (it will otherwise fail any PR whose fresh lockfile pulls the newer scipy).
🤖 Generated with Claude Code
https://claude.ai/code/session_01W5vkD2ZCyv3bmecBYoYYQy