Skip to content
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

effective_size of nodes with only self-loop edges is undefined #7347

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rossbar
Copy link
Contributor

@rossbar rossbar commented Mar 13, 2024

Handles the corner-case of isolated nodes that contain self-edges. Currently, isolated nodes are treated as having undefined effective_size:

>>> G = nx.Graph()
>>> G.add_node(0)
>>> nx.effective_size(G)
{0: nan}

However, the current behavior for isolated nodes with self-loops is inconsistent, resulting in ZeroDivisionError for the undirected case and 0.0 for directed graphs::

>>> G = nx.Graph([(0, 0)])
>>> nx.effective_size(G)
Traceback (most recent call last)
   ...
ZeroDivisionError: division by zero
>>> G = nx.DiGraph([(0, 0)])
>>> nx.effective_size(G)
{0: 0.0}

This discrepancy is due to the ambiguity of the direction of a self-edge.

Based on the current behavior and Borgatti's formula, I think the thing that makes the most sense is to have effective_size be undefined for all of these cases, making the behavior consistent across the board.

Closes #6916

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Strange behavior in nx.effective_size for the single node graph
1 participant