Skip to content

Native graph engine: Louvain modularity (faithful port of networkx's seeded Louvain) #3039

Closed

Description

@squid-protocol

Part of #3033.

Scope

Port louvain_partitions / _one_level / _gen_graph with identical seeded shuffles, threshold 1e-7 and resolution 1; build the undirected weights exactly as DiGraph.to_undirected() does (last-added reverse edge wins); then compute modularity.

Acceptance criteria

  • Identical communities and equal modularity at 4 dp on the harness graphs
  • Beats 203 ms
  • Risk: the most delicate port. If exact parity proves impossible, stop and report before changing any output.

Relevant baseline

operation networkx notes
louvain + modularity 203.1 ms

Networkx conventions to match

  • louvain_communities(G, weight="weight", resolution=1, threshold=1e-7, max_level=None, seed=42)
  • Uses a seeded shuffle of nodes per level
  • U = G.to_undirected(): when both a→b and b→a exist, the undirected edge keeps the attributes of the LAST one added in adjacency iteration order
  • Must compute modularity via the standard formula

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