Non-Deterministic Output from NetworkX Label Propagation
0 reputation · 03 Sept 2020, 14:35 UTC
NetworkX's label_propagation_communities function (introduced in v2.6) offers a fast, near-linear-time approach to community detection. However, its tie-breaking mechanism relies on the global Python random module, and the public API does not expose a seed parameter. This means successive calls on the same graph can yield different partitions unless the user manually sets random.seed before each invocation.
This behavior raises a reproducibility concern for workflows that require stable community assignments. The documentation does not specify whether the algorithm is intended to be stochastic or if deterministic output is achievable through a supported interface. Additionally, the reliance on global state makes results sensitive to unrelated random calls elsewhere in the program.
What is the recommended pattern for obtaining reproducible results from this function? Is the lack of a seed parameter a deliberate design choice, or is there an undocumented way to control the randomness? How does this behavior vary across NetworkX versions?