Efficient Gillespie algorithms for spreading phenomena in large and heterogeneous higher-order networks
[!NOTE] Code implemented using the Fortran Package Manager.
Main paper: Efficient Gillespie algorithms for spreading phenomena in large and heterogeneous higher-order networks, by Hugo P. Maia, Wesley Cota, Yamir Moreno, and Silvio C. Ferreira.
Reference: Nature Communications 17, 8665 (2026) DOI:10.1038/s41467-026-75402-0 Preprint: arxiv:2509.20174 DOI:10.48550/arXiv.2509.20174
Hyper-SIS Dynamical Model
This code simulates SIS dynamics on hypergraphs (Hyper-SIS). Each of the $N$ agents can be either susceptible ($\sigma_i = 0$) or infected ($\sigma_i = 1$). Infections occur via hyperedges, which are active if a critical mass of members is infected, while infected nodes recover spontaneously.
Key points:
- Node recovery rate: $\alpha = 1$.
- Hyperedge activation threshold: $\theta(m) = 1 + (m-1)\theta_0$, where $m$ is the hyperedge order.
- Infection rate as a function of hyperedge order: $\beta(m) = \beta[1 + b(m-1)]$.
- Pairwise infection rate: $\beta(1) = \beta$.
- Parameters
par_bandpar_thetacorrespond to $b$ and $\theta_0$.
See the main paper for full details.
Using it as a Fortran dependency
Add this package as a dependency using the Fortran Package Manager (fpm):
[dependencies]
hyperSIS.git = "https://github.com/gisc-ufv/hyperSIS"
See the documentation and main program for details.
Python package
[!TIP] 💡 A Google Colab notebook demonstrating all installation and usage steps is available here.
The easiest way to use this project is through its Python interface.
Via PyPI (pip)
Use pip install hyperSIS to install it.
Build python package
In this case, you need to clone the repository manually.
Before installing, make sure that at least one Fortran compiler is available. By default, the package assumes GNU Fortran (gfortran) installed and available in your PATH. See Installing GFortran for help.
Steps:
-
Clone the repository and enter it:
git clone https://github.com/gisc-ufv/hyperSIS.git cd hyperSIS
-
Activate your preferred Python environment (e.g.,
venv,conda, etc.):# Example with venv python -m venv venv source venv/bin/activate # Example with conda conda create -n hyperSIS python=3.11 conda activate hyperSIS
-
Install the Python package:
pip install ./python
- If you want to use another compiler and/or Fortran flags, set the
FCandFFLAGS.
# Optional: customize the Fortran compiler and flags export FC=gfortran # default is gfortran export FFLAGS="-O3 -march=native -funroll-loops" # adjust optimization flags pip install ./python
- If you want to use another compiler and/or Fortran flags, set the
Usage (Python)
[!TIP] 💡 See examples.ipynb and Google Colab for examples.
Import the package with
import hyperSIS as hs
The simulation interface revolves around two main objects:
-
SimulationArgsA dataclass containing all parameters required to configure a hyperSIS simulation, including network specification, algorithm choices, temporal settings, initial conditions, and epidemic parameters. -
run_simulation(beta1: float, args: SimulationArgs)The function that executes the simulation with the given arguments. Returns aSimulationResultobject containing the processed results, including network mapping, temporal evolution, and statistics of infected nodes.
Simulation arguments
The SimulationArgs dataclass contains all configurable parameters for running a hyperSIS simulation.
-
verbose: bool- Enable verbose output.
- Default:
True
-
verbose_level: str- Logging level:
'info','warning','error','debug'. - Default:
warning
- Logging level:
-
seed: int- Random seed for reproducibility.
- Default:
42
-
remove_files: bool- Remove temporary files after execution.
- Default:
False
-
network: NetworkFormat- Network specification as a tuple. Optional parameters are in brackets:
("edgelist", path, [delimiter], [comment], [cache])("fortran-edgelist", path, [cache])("bipartite", path, [delimiter], [comment], [cache])("xgi", name_or_object, [cache])("xgi_json", path, [cache])("hif", path, [cache])("PL", gamma, N, [sample])("networkx", nx.Graph, [cache])
- Default:
("PL", 3.0, 100, 1)
- Network specification as a tuple. Optional parameters are in brackets:
-
output_dir: Optional[str]- Directory to store simulation output. If
None, a temporary folder is used. - Default:
None
- Directory to store simulation output. If
-
algorithm: str- Simulation algorithm:
'HB_OGA'or'NB_OGA'. - Default:
HB_OGA
- Simulation algorithm:
-
sampler: str- Sampling method:
'rejection_maxheap'or'btree'. - Default:
btree
- Sampling method:
-
tmax: int- Maximum simulation time.
- Default:
100
-
use_qs: bool- Whether to use the quasi-stationary method.
- Default:
False
-
n_samples: int- Number of samples per simulation.
- Default:
10
-
time_scale: str- Temporal scale for output:
'uniform'or'powerlaw'. - Default:
uniform
- Temporal scale for output:
-
initial_condition: tuple- Initial state specification:
('fraction', float)→ fraction of infected nodes('number', int)→ exact number of initially infected nodes
- Default:
("fraction", 1.0)
- Initial state specification:
-
export_states: bool- Whether to export the full state trajectory.
- Default:
False
-
build_xgi_hypergraph: bool- Whether to build and return the xgi hypergraph representation of the network.
- Default:
False
-
par_b: float- Epidemic infection rate scale $b$ in $\beta(m) = \beta[1 + b(m-1)]$.
- Default:
0.5
-
par_theta: float- Epidemic critical mass threshold $\theta_0$ in $\theta(m) = 1 + (m-1)\theta_0$.
- Default:
0.5
Function
run_simulation(beta1: float, args: SimulationArgs)
Runs a Hyper-SIS simulation on the specified network.
Parameters:
beta1: floatBase infection rate $\beta(1)$ for pairwise interactions.args: SimulationArgsSimulation parameters, including network specification, algorithm choice, number of samples, initial condition, and epidemic parameterspar_bandpar_theta.
Returns:
-
SimulationResultObject containing:network: NetworkFormat– the network specification used.node_map: dict– mapping from original node IDs to Fortran node IDs.temporal: TemporalResult– temporal dynamics with:t: np.ndarray– mean time per Gillespie tick.rho_avg: np.ndarray– mean number of infected nodes over all runs.rho_var: np.ndarray– variance of infected nodes.n_samples: int– number of runs where infection is non-zero.active_states: Optional[dict]– detailed active states per sample and time (if requested), formatted as{sample_id: {time: {"nodes": [...], "edges": [...]}}}.
xgi_hypergraph: Optional[xgi.core.hypergraph.Hypergraph]– representation of the structure as anxgihypergraph, if generated.
Fortran executable hyperSIS_sampling
Read hyperSIS_sampling.md for instructions.
How to Cite
[!IMPORTANT] When using this package, please cite the following paper:
Efficient Gillespie algorithms for spreading phenomena in large and heterogeneous higher-order networks, by Hugo P. Maia, Wesley Cota, Yamir Moreno, and Silvio C. Ferreira (2026)
Reference: Nature Communications 17, 8665 (2026) DOI:10.1038/s41467-026-75402-0 Preprint: arxiv:2509.20174 DOI:10.48550/arXiv.2509.20174
The BibTeX entry is:
@article{Maia2026_hyperSIS,
title = {Efficient {Gillespie} algorithms for spreading phenomena in large and heterogeneous higher-order networks},
volume = {17},
issn = {2041-1723},
url = {https://www.nature.com/articles/s41467-026-75402-0},
doi = {10.1038/s41467-026-75402-0},
number = {1},
journal = {Nature Communications},
author = {Maia, Hugo P. and Cota, Wesley and Moreno, Yamir and Ferreira, Silvio C.},
month = jul,
year = {2026},
note = {Publisher: Nature Publishing Group},
pages = {8665},
}
Metadata
Release files for hyperSIS 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hypersis-1.2.4.tar.gz | 16.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hypersis-1.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 359.5 kB
Release files / hypersis-1.2.4.tar.gz
| Download URL | hypersis-1.2.4.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b17ba5ea20dd4da2b4482f4dda0daa316d3cd7b8b8ce8968257dafafdd30ea6
|
|
BLAKE2b-256 checksum How to use checksums |
c1d7479cd8296e1211f41b584dde0836a8f1d4743bdf9a69cd9dc53873cc947d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency logRelease files / hypersis-1.2.4-py3-none-any.whl
| Download URL | hypersis-1.2.4-py3-none-any.whl |
|---|---|
| Size | 343.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdc22bf1af2528daa5031b03028e597f612bdbba69a4101592546f02f1c3d96f
|
|
BLAKE2b-256 checksum How to use checksums |
644e51705169d435bb45697ac9271b392af347ed2863ed65267a6618dd9e3b2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.
Transparency log