Question about geographical threshold graph

57 views
Skip to first unread message

jimbo

unread,
Mar 29, 2021, 6:21:12 PM3/29/21
to networkx-discuss
Hi all,

I think there may be an error in the geographical threshold graph generation function . The docs say that the p_dist function should take in a distance value, d,  and return a probability (number between 0 and 1) of connecting the two nodes separated by d. Looking at the source, it seems that the default p_dist just returns 1/d^2 and uses that as the probability. There are many cases with d<1 and therefore 1/d^2 >1 so we can't interpret what is returned as a probability. Please let me know if I have missed something  and what should be done if I am correct. 

best,
jimbo

Dan Schult

unread,
Mar 29, 2021, 7:58:20 PM3/29/21
to networkx...@googlegroups.com
There is an arbitrary constant in the formula -- or maybe a redundancy of constants -- in p_dist and theta and w_u.
Each of them have arbitrary scaling. So, as long as p_dist is a constant value times a probability density function you are OK.
If you decrease all the distances by a factor of 10 you can increase the threshold by a factor of 100 and get the same results.
There is actually no randomness in the assignment of edges. The randomness occurs in the placement of the nodes.
Then a threshold is applied to find the edges. 

So, following what the docs say will work fine. But you can also have p_dist return values that don't have total probability density equal to 1.
Looks like more comprehensive docs would have helped in this case. I don't know the history but it's likely that the docs follow the
paper's description, while the code (and default) follow a more practical approach. We should open an issue or PR to get the docs
expanded.
Thanks!

jimbo

unread,
Mar 30, 2021, 8:42:38 PM3/30/21
to networkx-discuss
I see, thanks! I didn't notice that there is no randomness in the edge assignment. Another  thing I noticed about this function is that if instead of using 1/r^2 we use 1/r^3 in p_dist, we actually end up with far more connections (for a given theta). That's strange because we expect 1/r^3 to give a number that doesn't pass the threshold if 1/r^2 doesn't. Things get complicated because some nodes are separated by more than 1 while others are separated by less than 1 (so taking powers could actually increase OR decrease 1/r^n for n>1). I'll try to open up an issue or something. 

Thanks again. 

Ross Barnowski

unread,
Mar 30, 2021, 9:01:56 PM3/30/21
to networkx-discuss
Jimbo,

I already opened an issue re: the documentation highlighted by your original post and Dan's response: https://github.com/networkx/networkx/issues/4712.

Please feel free to comment/edit/close the issue as you see fit - I just wanted to make sure we linked the mailing list convo from the issue tracker so we didn't lose track of it. Also, if you'd prefer a clean slate and would like to open a new, more specific issue please go ahead!

~Ross

ian

unread,
Aug 7, 2021, 3:15:37 PM8/7/21
to networkx-discuss
Hi all,

I submitted a PR fixing the docs. Please let me know if it looks alright when you get a chance. 

Best,
Ian

Reply all
Reply to author
Forward
0 new messages