You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Zero-dependency mode: native betweenness/closeness and repo-topology metrics (follow-up to #3027) #3031
#3027 made zero-dependency mode compute PageRank natively. _pagerank() in network_risk_sensor.py matches nx.pagerank to below 1e-15 on the self-scan and language-crucible graphs. Every metric that is still not computed is now recorded as None rather than a 0.0 placeholder. Without networkx, that leaves:
networkx samples k=100 nodes with seed=42 above 500 nodes. A native version would have to reproduce that exact random sample to match.
Brandes is O(V·E) and exact for ≤500 nodes. Above 500 there's a choice: match nx's sampler, or use exact Brandes in both modes, which changes full precision.
closeness_score
Straightforward BFS, but it is bypassed above 1,500 nodes in both modes today.
Exact and cheap for ≤1,500 nodes (V BFS runs).
network_cyclic_density
—
Tarjan SCC: exact, O(V+E).
network_articulation_points
—
Tarjan/Hopcroft on the undirected view: exact, O(V+E).
network_assortativity
—
Closed-form over the degree pairs of edges; exact. It must match nx.degree_assortativity_coefficient's directed out→in convention.
network_avg_path_length
—
BFS over the largest undirected component; exact. nx skips it above 5,000 nodes.
network_modularity
Louvain with seed=42; matching it natively means reproducing nx's Louvain.
Hard to match exactly. Probably leave it None.
Ask
Implement the exact-and-cheap ones natively, following the #3027 pattern:
a pure-Python function
a parity test against networkx on random graphs
the zero-dependency golden-master diff, scoped
That covers cyclic density, articulation points, assortativity, avg path length, and closeness ≤1,500. Decide betweenness separately, since matching nx's sampler vs. exact Brandes is a design call. Update docs/zero_dependency_mode.md as each one lands.
Filed as the follow-up agreed when #3027 was scoped.
Superseded by #3033: the decision is now to remove networkx from the runtime entirely (native implementations in both modes, networkx kept only as a test-time oracle). Its scope is covered by the epic's sub-issues.
Activity
squid-protocol commentedon Sep 14, 2026
Superseded by #3033: the decision is now to remove networkx from the runtime entirely (native implementations in both modes, networkx kept only as a test-time oracle). Its scope is covered by the epic's sub-issues.