Skip to content

Native graph engine: exact betweenness (hop-count BFS Brandes, every repo size) #3038

Closed

Description

@squid-protocol

Part of #3033.

Scope

Reproduce random.Random(42).sample(list(nodes), k), heapq Dijkstra with the insertion counter and exact-float tie handling, _accumulate_basic, and _rescale for the sampled and unsampled directed cases.

Parallel sources with fixed-order reduction.

Acceptance criteria

  • Parity at 6 dp with networkx for V ≤ 500 and for the sampled V > 500 case
  • Beats 85 ms on the crucible graph

Relevant baseline

operation networkx notes
betweenness k=100 seed=42 84.9 ms

Networkx conventions to match

  • Sample is random.Random(42).sample(list(G.nodes()), k), since py_random_state wraps an int seed in random.Random
  • Weighted Brandes: _single_source_dijkstra_path_basic pushes (dist, next(count), pred, v) on a heapq
  • Equal-length paths are counted when vw_dist == seen[w] (exact float equality)
  • sigma starts at 0.0, and 1.0 for the source
  • Accumulation: _accumulate_basic
  • Rescale (_rescale, directed, normalized=True, endpoints=False): N = n-1
    • Unsampled: scale = 1/(K_source*(N-1))
    • Sampled: per-node scale_source = 1/((K_source-1)*(N-1)) for v in the sample, and scale_nonsource = 1/(K_source*(N-1)) otherwise

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). This supersedes the "networkx-compatible seeded sampler" scope.

    • Exact betweenness at every size. No sampling: sampling found 11 nonzero files vs 78 exact on crucible, and read 14 of the exact top-20 choke points as 0.

    • Hop count, not weight-as-distance. networkx interprets weight as distance, which made entity imports longer paths. So this is an unweighted BFS Brandes: no Dijkstra, and no sampler or _rescale k-branch to reproduce.

    • Speed:

      The number to beat is networkx's exact-weighted 1,560 ms on crucible.

    • Oracle: nx.betweenness_centrality(G) (exact, unweighted, normalized, directed).

    • Acceptance:

      • 6-dp parity with that oracle
      • a scoped golden-master diff: the bottleneck rankings and any betweenness consumers move, as intended
      • the PR notes the change for temporal-crucible history
  3. changed the title [-]Native graph engine: betweenness (weighted Brandes + networkx-compatible seeded sampler)[/-] [+]Native graph engine: exact betweenness (hop-count BFS Brandes, every repo size)[/+] on Sep 14, 2026
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