Condition in test_louvain::test_threshold
not representative of graphs with same parameters but different seed.
#6823
Labels
Current Behavior
The test for the Louvain algorithm asserts if the modularity of a partition obtained using
threshold=0.3
is smaller than the modularity when using the default value for a specific graph generated using theLFR_benchmark_graph
. However, if the graph used for testing is changed, this condition no longer holds in general (see Steps to Reproduce).Expected Behavior
I suggest changing the test to
assert mod1 <= mod2
instead.Steps to Reproduce
If we use the same settings for the graph generation but allow for a different seed we do not always pass the assertion.
On my machine, it took 28 tries to generate a graph (seed = 26537). For this graph, the test was successful 83/100 times. If we relax the test condition to
assert m1 <= m2
the test succeeds 100/100 times.Environment
Python version: 3.10
NetworkX version: 3.1
The text was updated successfully, but these errors were encountered: