Repository navigation
Native graph engine: cyclic density (SCC) + articulation points in O(V+E) (#3035) - #3046
Merged
Merged
Conversation
…modes (#3037) - graph_engine.closeness_and_path_length(): one BFS per node over the reversed CSR index yields both hop-count metrics. - closeness: strict parity with nx.closeness_centrality (Wasserman-Faust) - average path length: REDEFINED per #3033's tailoring decisions as the mean hops over every directed reachable pair (A transitively imports B) across all files, instead of the largest undirected component - None when no file imports another - The V>1500 (closeness) and V>5000 (path length) node-count cutoffs are replaced by a deterministic WorkBudget: PATH_METRICS_WORK_BUDGET = 50M incoming-edge scans, past which both metrics are None, never 0.0. - Runs in BOTH modes like PageRank, so zero-dependency mode now gets closeness, the "fragile dependency chain" ranking and path length. - language-crucible (V=2,817): both metrics in 1.7 ms. Before this, closeness took 12.9 ms (nx) and was skipped at this size, and the undirected path length took about 1.2 s. Path length reads 1.358 (was 7.0723). - Docs: zero_dependency_mode.md, the 02-16 wiki page, README, CLAUDE.md, the console banner and the LLM brief's section 3.5 text. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ragile-chain ranking populated) Scoped with an uncapped golden_diff over fresh scans of both modes: exactly two differences per mode -- network_macro/avg_path_length (7.0723 / None -> 1.358) and systemic_bottlenecks/fragile_dependency_chain ([] -> populated, closeness now computed at the crucible's 2,817 files). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…V+E) (#3035) - graph_engine.nodes_in_cycles(): iterative Tarjan SCC over the CSR out-runs. Strict parity with sum(len(c) for c in nx.strongly_connected_components(G) if len(c) > 1). - graph_engine.articulation_point_count(): iterative Hopcroft-Tarjan over the undirected view (_undirected_neighbors = the adjacency of G.to_undirected()). Strict parity with nx.articulation_points. - Neither recurses: a 5,000-node cycle and chain are tested. - NetworkRiskSensor._cycle_metrics() runs both in BOTH modes, outside the networkx macro block, replacing the nx calls. Zero-dependency mode now reports cyclic density and articulation points. - language-crucible: 1.12 ms vs 2.14 ms (SCC); 2.28 ms vs 9.87 ms (articulation points, incl. to_undirected). Values are identical. - Registered as strict in tests/tools/graph_parity.py. Docs updated. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…y + articulation points now native) Uncapped golden_diff scope: full precision 0 differences (crucible_check --update: no drift); zero dependency exactly 2 -- network_macro/ cyclic_density None -> 0.005 and articulation_points None -> 137, the same values full precision reports. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
…ality CodeQL (py/unnecessary-lambda) on #3046: `oracle=lambda graph: nx.closeness_centrality(graph)` is a bare wrapper -- use the callable directly. Behaviour-identical (the harness calls oracle(graph)). Other oracles keep their lambdas: pagerank binds weight=, cyclic_density is a composed expression, articulation_points calls .to_undirected()/len(). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_014gkhy3FWC4ovUWkMDonGMr
This was referenced Sep 14, 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.
Closes #3035. Part of #3033 (the native graph engine). Stacked on #3044 (#3037): this branch contains #3044's two commits until it merges, and review should cover only the last commit(s).
What changed
Two O(V+E) algorithms in
gitgalaxy/core/graph_engine.py. Both read the shared CSR index and never recurse.nodes_in_cycles(index): iterative Tarjan SCC over the out-runs, using an explicit (node, next-edge) work stack. It gives cyclic density = nodes in SCCs of size > 1, divided by V. Strict parity withsum(len(c) for c in nx.strongly_connected_components(G) if len(c) > 1).articulation_point_count(index): iterative Hopcroft–Tarjan low-link over the undirected view._undirected_neighborsgives each node's distinct neighbours with direction ignored, which is the adjacency ofG.to_undirected(). Strict parity withlen(list(nx.articulation_points(G.to_undirected()))). The parent is skipped as a node, not an edge, so a mutually importing pair counts as one undirected edge, as in networkx.NetworkRiskSensor._cycle_metrics()runs both in both modes, outside the networkx macro block, which drops thenx.strongly_connected_componentsandnx.articulation_pointscalls. Both metrics areNonefor an empty graph, as before. No work budget is needed, since both are linear.Both are registered in
tests/tools/graph_parity.pyasstrict.Measured on language-crucible v1.2.0 (V=2,817, E=1,354; warm, best of 10,
graph_parity.py --db)to_undirected())Other checks:
Golden masters
I diffed fresh scans of each mode against the committed fixtures with an uncapped
golden_diff.deep_compare. The scans usedGITGALAXY_DISABLE_GIT_HISTORY=1and the same flags astest_golden_crucible.py.crucible_check.py --updatealso reported "No drift detected". This is the strict-parity guarantee holding on the real corpus.Nonethere before and is now native:network_macro/cyclic_density:None→ 0.005network_macro/articulation_points:None→ 137The zero-dependency fixture is re-blessed in the second commit.
Verification
pytestpasses on the 9 affected suites (360 passed), run as plainpytestfrom outside the repo.nx.strongly_connected_componentsornx.articulation_points, and both modes agreeaudit_check.py: all clear.zero_dependency_mode.md(table, summary, and an older-snapshots note: zero-dep values were NULL, and the definition is unchanged), the 02-16 wiki, README, CLAUDE.md, the console banner, and the zero-dependency warning.🤖 Generated with Claude Code