Repository navigation
Native graph engine: closeness + average path length, native in both modes (#3037) - #3044
Closed
squid-protocol wants to merge 3 commits into
Closed
squid-protocol wants to merge 3 commits into
squid-protocol wants to merge 3 commits into
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]>
Contributor
…ality CodeQL (py/unnecessary-lambda) on #3044: `oracle=lambda graph: nx.closeness_centrality(graph)` is a bare wrapper -- use the callable directly. Behaviour-identical (the harness calls oracle(graph)). The pagerank oracle keeps its lambda: it binds weight="weight", so it is not a bare wrapper. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_014gkhy3FWC4ovUWkMDonGMr
Owner
Author
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 #3037. Part of #3033 (the native graph engine). Builds on #3042 (#3034, merged): it uses that PR's
GraphIndexandWorkBudget.What changed
graph_engine.closeness_and_path_length(index, budget)runs one breadth-first search per node over the reversed CSR index. That single pass produces both hop-count metrics:nx.closeness_centrality(G). That is directed, incoming distance, in Wasserman-Faust form. Registered in the parity harness asstrict.Nonewhen no file imports another.tailored. The oracle is per-sourcenx.single_source_shortest_path_length.PATH_METRICS_WORK_BUDGETis 50M incoming-edge scans, about 3 s of pure-Python search in the worst case. It counts work, never time, so the golden masters can't flake. Past the budget, both metrics areNone, never0.0.Edge weight plays no part in either metric: it stays a PageRank strength. networkx's weighted paths would treat it as a distance, which is backwards (#3033).
Measured on language-crucible v1.2.0 (V=2,817, E=1,354; warm, best of 5,
tests/tools/graph_parity.py --db)Both metrics come out of one pass: 1.7 ms in total.
repo_data.network_avg_path_lengthkeeps its column, but its meaning changes with this PR. Values from before and after are not comparable. On language-crucible it was 7.0723 and is now 1.358.docs/zero_dependency_mode.mdrecords this under "Older snapshots", and the brief's §3.5 interpretation text now describes the new definition. Closeness was NULL in zero-dependency mode and above 1,500 files before this PR, so older snapshots show NULL where newer ones have values.Golden masters: re-blessed after an uncapped, scoped diff
Scoped with
golden_diff.deep_compareover a fresh scan of each mode, usingGITGALAXY_DISABLE_GIT_HISTORY=1and the same flags astest_golden_crucible.py.network_macro/avg_path_length: 7.0723 → 1.358 (the redefinition)systemic_bottlenecks/fragile_dependency_chain:[]→ the top closeness × error-risk files. Closeness used to be skipped above 1,500 files, which covers the whole crucible.avg_path_length:None→ 1.358fragile_dependency_chainranking as full precisionVerification
None, not0.0Nonepytestpasses on the 9 affected suites (308 passed), run as plainpytestfrom outside the repo.audit_check.py: all clear.🤖 Generated with Claude Code