Skip to content

Sampled betweenness in suggest_questions takes 45 to 70s on large graphs #5667

Backlog

Description

@Max17190

On v8 at d249de36 (0.9.124), suggest_questions computes betweenness with 100 sampled sources on every full rebuild and every update that changes topology. _betweenness_centrality at graphify/analyze.py:499 matches networkx exactly since #5303, but it still runs Python code for every neighbor of every source.

Graph Nodes Median of 3 runs
Django 55k 5.0s
Kubernetes 472k 44.6s
VS Code 315k 67.6s

To reproduce, load a large graphify-out/graph.json with build_from_json and time _betweenness_centrality(G, 100, seed=42). Linux, CPython 3.12.3, networkx 3.7, numpy 1.26.4.

Proposed: run each source's search one level at a time with numpy and keep every sum in networkx's order, so the scores stay identical to the last bit.

Activity

  1. github-actions commented on Dec 1, 2026

    @github-actions

    Thanks for opening this issue, @Max17190. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions