Find us on…
[!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
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:
par_b and par_theta correspond to $b$ and $\theta_0$.See the main paper for full details.
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.
[!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.
PyPI (pip)Use pip install hyperSIS to install it.
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:
sh
git clone https://github.com/gisc-ufv/hyperSIS.git
cd hyperSIS
Activate your preferred Python environment (e.g., venv, conda, etc.):
```sh
python -m venv venv source venv/bin/activate
conda create -n hyperSIS python=3.11 conda activate hyperSIS ```
Install the Python package:
sh
pip install ./python
FC and FFLAGS.```sh
export FC=gfortran # default is gfortran export FFLAGS="-O3 -march=native -funroll-loops" # adjust optimization flags pip install ./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:
SimulationArgs
A 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 a SimulationResult object containing the processed results, including network mapping, temporal evolution, and statistics of infected nodes.
The SimulationArgs dataclass contains all configurable parameters for running a hyperSIS simulation.
verbose: boolDefault: True
verbose_level: str
'info', 'warning', 'error', 'debug'.Default: warning
seed: int
Default: 42
remove_files: bool
Default: False
network: NetworkFormat
("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)
output_dir: Optional[str]
None, a temporary folder is used.Default: None
algorithm: str
'HB_OGA' or 'NB_OGA'.Default: HB_OGA
sampler: str
'rejection_maxheap' or 'btree'.Default: btree
tmax: int
Default: 100
use_qs: bool
Default: False
n_samples: int
Default: 10
time_scale: str
'uniform' or 'powerlaw'.Default: uniform
initial_condition: tuple
('fraction', float) → fraction of infected nodes('number', int) → exact number of initially infected nodesDefault: ("fraction", 1.0)
export_states: bool
Default: False
build_xgi_hypergraph: bool
Default: False
par_b: float
Default: 0.5
par_theta: float
0.5run_simulation(beta1: float, args: SimulationArgs)
Runs a Hyper-SIS simulation on the specified network.
Parameters:
beta1: float
Base infection rate $\beta(1)$ for pairwise interactions.args: SimulationArgs
Simulation parameters, including network specification, algorithm choice, number of samples, initial condition, and epidemic parameters par_b and par_theta.Returns:
SimulationResult
Object 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 an xgi hypergraph, if generated.hyperSIS_samplingRead hyperSIS_sampling.md for instructions.
[!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},
}