Skip to content

Commit

Permalink
Add ability to generate ER hypergraphs without multiedges (#596)
Browse files Browse the repository at this point in the history
* Add ability to generate ER hypergraphs without multiedges

* update

* Fix #361

* Revert "Fix #361"

This reverts commit 28cbbf3.

* Update test.yml

* fix non-multi-edge probability

* formatting

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update using-xgi.rst

* Response to review

* Update uniform.py

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* Update xgi/generators/uniform.py

Co-authored-by: Maxime Lucas <[email protected]>

* updates

---------

Co-authored-by: Maxime Lucas <[email protected]>
  • Loading branch information
nwlandry and maximelucas authored Oct 10, 2024
1 parent 660f77e commit f2e2241
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 46 deletions.
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 @@ -86,12 +91,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

0 comments on commit f2e2241

Please sign in to comment.