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

Add ability to generate ER hypergraphs without multiedges #596

Merged
merged 18 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
11 changes: 5 additions & 6 deletions docs/source/using-xgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Nicholas W. Landry, Ilya Amburg, Mirah Shi, and Sinan Aksoy, "Filtering higher-o
:bdg-link-primary-line:`Paper <https://doi.org/10.1088/2632-072X/ad253a>`
:bdg-link-primary-line:`Code <https://github.com/nwlandry/filtering-higher-order-datasets>`

Nicholas W. Landry, William Thompson, Laurent Hébert-Dufresne, and Jean-Gabriel Young, "Reconstructing networks from simple and complex contagions", Physical Review E **110**, L042301 (2024).

:bdg-link-primary-line:`Paper <https://doi.org/10.1103/PhysRevE.110.L042301>`
:bdg-link-primary-line:`Code <https://github.com/nwlandry/complex-network-reconstruction>`

Nicholas W. Landry, Jean-Gabriel Young, and Nicole Eikmeier, "The simpliciality of higher-order networks", *EPJ Data Science* **13**, 17 (2024).

:bdg-link-primary-line:`Paper <https://doi.org/10.1140/epjds/s13688-024-00458-1>`
Expand Down Expand Up @@ -81,12 +86,6 @@ Robin Delabays, Giulia De Pasquale, Florian Dörfler, and Yuanzhao Zhang, "Hyper
:bdg-link-primary-line:`Paper <https://arxiv.org/abs/2402.00078>`
:bdg-link-primary-line:`Code <https://github.com/TaylorBasedHypergraphInference/THIS>`

Nicholas W. Landry, William Thompson, Laurent Hébert-Dufresne, and Jean-Gabriel Young, "Complex contagions can outperform simple contagions for network reconstruction with dense networks or saturated dynamics", arXiv:2405.00129

:bdg-link-primary-line:`Paper <https://arxiv.org/abs/2405.00129>`
:bdg-link-primary-line:`Code <https://github.com/nwlandry/complex-network-reconstruction>`


Maxime Lucas, Luca Gallo, Arsham Ghavasieh, Federico Battiston, and Manlio De Domenico, "Functional reducibility of higher-order networks", arXiv:2404.08547 (2024).

:bdg-link-primary-line:`Paper <https://arxiv.org/abs/2404.08547>`
Expand Down
22 changes: 19 additions & 3 deletions tests/generators/test_uniform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest
from scipy.special import comb

import xgi
from xgi.exception import XGIError
Expand Down Expand Up @@ -150,14 +151,29 @@ def test_uniform_HPPM():
def test_uniform_erdos_renyi_hypergraph():
m = 2
n = 10
k = 2
H1 = xgi.uniform_erdos_renyi_hypergraph(n, m, k, seed=0)
p = 1
H1 = xgi.uniform_erdos_renyi_hypergraph(n, m, p, seed=0)
ne1 = H1.num_edges
H1.merge_duplicate_edges(rename="tuple")
ne2 = H1.num_edges
assert ne1 == ne2
assert ne1 == comb(n, m)

assert H1.num_nodes == 10
assert xgi.unique_edge_sizes(H1) == [2]

H2 = xgi.uniform_erdos_renyi_hypergraph(n, m, p, seed=0, multiedges=True)
print(H2.edges)
ne1 = H2.num_edges
H2.merge_duplicate_edges()
ne2 = H2.num_edges
assert ne1 != ne2
assert ne1 == n**m - n # remove loopy edges

# test that the seed works
H2 = xgi.uniform_erdos_renyi_hypergraph(n, m, k, seed=0)
p = 0.1
H1 = xgi.uniform_erdos_renyi_hypergraph(n, m, p, seed=0)
H2 = xgi.uniform_erdos_renyi_hypergraph(n, m, p, seed=0)

assert H1.edges.members(dtype=dict) == H2.edges.members(dtype=dict)

Expand Down
3 changes: 1 addition & 2 deletions xgi/core/dihypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,7 @@ def cleanup(self, isolates=False, relabel=True, in_place=True):

convert_labels_to_integers(_DH, in_place=True)

if not in_place:
return _DH
return _DH

def freeze(self):
"""Method for freezing a dihypergraph which prevents it from being modified
Expand Down
3 changes: 1 addition & 2 deletions xgi/core/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,8 +1487,7 @@ def cleanup(

convert_labels_to_integers(_H, in_place=True)

if not in_place:
return _H
return _H

def freeze(self):
"""Method for freezing a hypergraph which prevents it from being modified
Expand Down
3 changes: 1 addition & 2 deletions xgi/core/simplicialcomplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,7 @@ def cleanup(self, isolates=False, connected=True, relabel=True, in_place=True):

convert_labels_to_integers(_S, in_place=True)

if not in_place:
return _S
return _S

def freeze(self):
"""Method for freezing a simplicial complex
Expand Down
Loading
Loading