Long story short, I'm creating a graph using networkx and the lower the weights between nodes(edges) the better.
My problem is pagerank doesn't like getting a weight of zero and gives me an error. So I was thinking is there a number that is essentially zero in python but not exactly zero. Something like 0.0000000000001?
or if my approach is really horrible(which I suspect it might) is there another way to deal with this? Pagerank recussivily gets a score and then normalizes it against the entire dataset so scores tend to be very low as dataset gets larger(think 1/billion nodes).
>>> 1e-324
0.0
>>> 1e-323
9.8813129168249309e-324
Some interesting tests
>>> 1e-307 < sys.float_info.min
False
>>> 1e-307 > sys.float_info.min
True
>>> 1e-323 < sys.float_info.min
True
>>> 1e-323 + 1e-323
1.9762625833649862e-323
>>> 1e-324 + 1e-324
0.0
Update for @Kari's comment
Im curious why this is True
>>> 0.0 < 1e-323 < sys.float_info.min
True
You can look at sys.float_info.min, the value of the minimum positive normalized float. On my system, this is 2.2250738585072014e-308.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With