I am attempting to calculate a graph's non-randomness using networkx.
This error appears for some graphs but not for other graphs.
~\anaconda3\lib\site-packages\networkx\algorithms\non_randomness.py
eq. 4.5
nr_rd = (nr - ((n - 2 * k) * p + k)) / math.sqrt(2 * k * p * (1 - p))
What graph characteristics result in this error?
The documentation describes two possible exceptions. Neither is this one.
Here is an example of a graph resulting in the error.
The node labels (a, m, d), colors, and size are node attributes used for grouping similar nodes. Each node has a unique ID that is not shown in the graph.

Here is code for creating that graph and generating the error.
nodes = ['a1','a2','a3','a4','m1','m2','m3','m4','d']
edges = [('a1','m1'),('a2','m2'),('a3','m3'),('a4','m4'),('m1','d'),('m2','d'),('m3','d'),('m4','d')]
my_g = nx.Graph()
for n in nodes:
my_g.add_node(n)
for e in edges:
my_g.add_edge(e[0],e[1])
nx.non_randomness(my_g)