python - networkx calculating numeric assortativity requires int? -
i trying use networkx calculate numeric assortativity based on numeric attribute set nodes. node attributes floats. when call assortativity function:
assort = nx.numeric_assortativity_coefficient(g,'float_attr')
i got following errors.
file "/some dir.../networkx/algorithms/assortativity/correlation.py", line 229, in numeric_assortativity_coefficient = numeric_mixing_matrix(g,attribute,nodes) file "/some dir.../networkx/algorithms/assortativity/mixing.py", line 193, in numeric_mixing_matrix mapping=dict(zip(range(m+1),range(m+1))) typeerror: range() integer end argument expected, got float.
i checked documentation page of networkx assortativity algorithm , did not numeric attributes have int. knows if that's required?
btw, used same network , gender attribute (set 0 , 1) calculate both attribute , numeric assortativity. had no problem that. seems problem int/float type of node attribute.
problem solved converting float variable int using following method
int(round(float_attr*1000, 0))
submitted issue here , got confirmatory answer deals discrete int values.
peformance-wise, since network not huge (200+ nodes), still takes <1 min calculation.
Comments
Post a Comment