snap-stanford / snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
Other
2.16k stars 795 forks source link

Unable to create path using GenTree() #203

Open SveinHogemo opened 3 years ago

SveinHogemo commented 3 years ago

I am using snap.py with Python 3.7.8. When I tried to create a tree with fanout 1 (i.e. a path) in the interactive shell, the session quit abruptly with no error message.

I looked at the C++ code and it seems this line is the culprit (/snap-core/ggen.h, line 134): const int Nodes = (int) (pow(double(Fanout), double(Levels+1)) - 1) / (Fanout - 1);

So the number of nodes is calculated using the formula for geometric sums, and with fanout 1 you get a division by zero. I do not have any perfect suggestion for how to resolve this, but I think either the number of nodes should be calculated another way, or it should be specified in docs that fanout must be >=2.