Skip to content

Native graph engine: closeness at every size + directed average path length #3037

Closed

Description

@squid-protocol

Part of #3033.

Scope

Closeness on the reversed index with Wasserman-Faust; average path length over the largest undirected component.

Replace the V>1500 (closeness) and V>5000 (avg path length) node-count cutoffs with a work budget on V×E. The crucible graph (2,817 nodes) computes exact closeness in 21 ms with networkx, yet is skipped today.

Parallel per-source BFS above a size threshold, with results combined in fixed order.

Acceptance criteria

  • Parity with networkx wherever networkx computes the value
  • Average path length beats 1,213 ms on the crucible graph
  • Note: raising the cutoff CHANGES full-precision output (closeness starts being computed on large repos). That needs a scoped bless and a PR note.

Relevant baseline

operation networkx notes
closeness (exact, all nodes) 21.4 ms the 1,500-node cutoff is far too conservative for sparse import graphs
avg shortest path length (LCC) 1,213.5 ms the dominant cost of the whole graph phase

Networkx conventions to match

  • closeness (directed): computed on G.reverse(), i.e. incoming distance
  • Unweighted BFS (single_source_shortest_path_length), totsp = sum(dist)
  • Value is (len(sp)-1)/totsp when totsp>0 and V>1
  • wf_improved=True multiplies by (len(sp)-1)/(V-1)
  • avg path length: unweighted, largest connected component of U, mean over all ordered pairs

Activity

  1. added
    enhancement
    metrics
    core-engine
    on Sep 14, 2026
  2. squid-protocol commented on Sep 14, 2026

    @squid-protocol
    OwnerAuthor

    Revised by the tailoring decisions on #3033 (2026-09-14).

    • Closeness: remove the V>1500 cutoff; compute it at every size, gated only by the deterministic work budget from Native graph engine: shared CSR graph index + parity/benchmark harness #3034. Exact all-node closeness takes 18 ms on crucible (V=2,817), which is skipped today. Oracle: nx.closeness_centrality(G) with no cutoff.

    • Average path length: REDEFINED as the mean hop count over all directed reachable pairs (A transitively depends on B), across every file, instead of the largest undirected component. Measured:

      • crucible: 1.36 over 1,891 pairs in 6 ms, vs 7.05 undirected-LCC in 952 ms covering 22.5% of files
      • self-scan: 1.71 vs 4.19

      Oracle: mean of nx.single_source_shortest_path_length(G, n) over all n, excluding self. Store it in repo_data.network_avg_path_length (the same column), and document the new meaning in the LLM brief §3.5 interpretation text and in docs/zero_dependency_mode.md.

    • Acceptance:

      • parity with the tailored oracles
      • a scoped golden-master diff in both modes: closeness appears on large repos; path length changes value
      • the PR notes the definition change for temporal-crucible history
  3. changed the title [-]Native graph engine: closeness and average path length (BFS family) with parallel sources and an edge-budget cutoff[/-] [+]Native graph engine: closeness at every size + directed average path length[/+] on Sep 14, 2026
  4. squid-protocol commented on Sep 14, 2026

    @squid-protocol
    OwnerAuthor

    Landed on main in 492b029, via #3046's squash merge (#3046 was stacked on #3044):

    • native closeness and directed reachable-pair average path length in both modes
    • the V>1500 cutoff replaced by PATH_METRICS_WORK_BUDGET
    • golden masters re-blessed

    PR #3044 is closed as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engineenhancementmetricsperformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions