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

feat: hypergraph random edge shuffle #531

Merged
merged 5 commits into from
Apr 5, 2024
Merged

feat: hypergraph random edge shuffle #531

merged 5 commits into from
Apr 5, 2024

Conversation

doabell
Copy link
Contributor

@doabell doabell commented Apr 5, 2024

This PR implements random_edge_shuffle for hypergraphs, as described in Configuration models of random hypergraphs, Philip S C., 2020.

Given two edges, the existing double_edge_swap swaps two nodes, whereas random_edge_shuffle puts all nodes in a bucket and shuffles them.
This preserves the edge sizes and node degrees.
If the same node appears in both hyperedges, then this is still true after reshuffling.

The user can also use this to shuffle two randomly selected hyperedges, if no edge IDs are specified.

xgi/core/hypergraph.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@nwlandry nwlandry left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks, @doabell! Two small comments to address, but otherwise, I think that it is good to go.

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.16%. Comparing base (b717e4b) to head (a286f66).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #531      +/-   ##
==========================================
+ Coverage   92.12%   92.16%   +0.04%     
==========================================
  Files          60       60              
  Lines        4393     4417      +24     
==========================================
+ Hits         4047     4071      +24     
  Misses        346      346              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@doabell
Copy link
Contributor Author

doabell commented Apr 5, 2024

Resolved these comments, could you take another look? Thanks.

@nwlandry
Copy link
Collaborator

nwlandry commented Apr 5, 2024

Looks great! Thanks so much! Merging now.

@nwlandry nwlandry merged commit caf534b into xgi-org:main Apr 5, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants