E52D fix: handle empty graph in degree_pearson_correlation_coefficient (Fixes #6913) by samay2504 · Pull Request #8395 · networkx/networkx · GitHub
[go: up one dir, main page]

Skip to content

fix: handle empty graph in degree_pearson_correlation_coefficient (Fixes #6913)#8395

Open
samay2504 wants to merge 1 commit intonetworkx:mainfrom
samay2504:fix/networkx-6913-degree-correlation-empty
Open

fix: handle empty graph in degree_pearson_correlation_coefficient (Fixes #6913)#8395
samay2504 wants to merge 1 commit intonetworkx:mainfrom
samay2504:fix/networkx-6913-degree-correlation-empty

Conversation

@samay2504
Copy link
Contributor

Fixes #6913

@samay2504 samay2504 force-pushed the fix/networkx-6913-degree-correlation-empty branch from 5136ab3 to beecf9e Compare December 17, 2025 11:24
Copy link
Contributor
@rossbar rossbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the discussion in #7392 which was another attempt at fixing this issue - I think some of the points there are still relevant.

Also - let's move the tests into existing test files: see the pattern used in #7392 as an example!

…raph

Fixes networkx#6913

When a graph has no edges, degree_pearson_correlation_coefficient now
returns float('nan') instead of raising ValueError, since Pearson
correlation is mathematically undefined for zero data points.

Test added to existing test file as requested in review.
@samay2504 samay2504 force-pushed the fix/networkx-6913-degree-correlation-empty branch from beecf9e to 4bb19b0 Compare December 17, 2025 19:38
@samay2504
Copy link
Contributor Author

Done,the tests are moved to the existing tests file.

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.

ValueError crash in "nx.degree_pearson_correlation_coefficient" when input graph with no edges

2 participants

0