-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior in nx.effective_size
for the single node graph
#6916
Comments
Yeah we should be catching this corner case. Thanks for your work on this!! Please do send a PR :) |
Looking at this one again a code comment explicitly states that for the corner case of isolated nodes while using Borgatti's formula it should be undefined ( networkx/networkx/algorithms/structuralholes.py Lines 147 to 149 in f35e034
But the other case is where I guess we need to make a choice. I think for consistency we put in undefined behavior for isolated nodes but according to the reference it should be zero. networkx/networkx/algorithms/structuralholes.py Lines 155 to 157 in f35e034
Also the ZeroDivisionError is popping up because of the self loop which makes the node |
Hi @MridulS. Thanks for your kind help in this issue. That's only my personal opinion, so please feel free to tell me if I misunderstand the question. Best regards, |
IIUC, it seems that the returning |
Hello! It seems I've created quite a few issue reports, and I apologize for any inconvenience. Please feel free to review them at your own pace, or you can assign them to me if I can assist in creating PR to fix them.
According to the formula
The
effective_size
should have a well-defined value of0
for a graph with a single node.However, if we use Borgatti's method to calculate this graph, the value will lose its definition, and NetworkX will return some strange behavior:
For instance:
Result:
I am not sure whether such behaviors are expected. So it would be highly appreciated if you could further confirm and investigate it.
If they are unexpected, I will create a PR to fix it by returning a single
0
if the graph contains only one node.Best regards,
Joye
Environment
NetworkX 3.1
Python 3.10
The text was updated successfully, but these errors were encountered: