Skip to main content
Nature Communications logoLink to Nature Communications
. 2026 Jul 15;17:8665. doi: 10.1038/s41467-026-75402-0

Efficient Gillespie algorithms for spreading phenomena in large and heterogeneous higher-order networks

Hugo P Maia 1, Wesley Cota 1, Yamir Moreno 2,3, Silvio C Ferreira 1,4,5,✉
PMCID: PMC13490459  PMID: 42457723

Abstract

Higher-order interactions, where groups of nodes interact collectively rather than pairwisely, are central to many complex systems, from neural and ecological networks to social contagion. However, simulating dynamical processes on such higher-order structures remains computationally challenging due to the combinatorial growth of possible interactions. Here, we develop efficient and statistically exact Gillespie algorithms for Markovian spreading dynamics on large and heterogeneous hypergraphs. By incorporating phantom processes  − events that advance time without altering the system’s state − , we drastically reduce the computational complexity of standard algorithms (O(N2)), achieving up to linear scaling with system size. Relying on the susceptible-infected-susceptible model with critical mass thresholds as a benchmark, we show that the optimized algorithms outperform standard approaches by several orders of magnitude, enabling simulations of networks with millions of nodes and broad heterogeneity in both degree and interaction order. Efficient sampling methods, needed to overcome the bottlenecks imposed by either a high maximum order or number of interactions, and other dynamical processes on higher-order networks are tackled. These results establish a general framework for scalable, continuous-time simulations of higher-order contagion and related dynamical processes.

Subject terms: Complex networks, Biological physics


Higher-order interactions, where groups of nodes interact collectively rather than in pairs, are central to social contagion dynamics. Here, the authors develop efficient and exact Gillespie algorithms for spreading dynamics on large and heterogeneous hypergraphs, significantly reducing computational complexity.

Introduction

Networks provide the fundamental substrate for understanding how collective phenomena emerge from interactions among many agents1,2. Classical network theory assumes that interactions are exclusively pairwise, an assumption that has guided decades of research on synchronization3,4, opinion formation5,6, brain activity7,8, and ecological stability9,10, as well as on the spreading of diseases or information across populations11,12. Yet, in many real systems, interactions are inherently collective and cannot be reduced to independent pairwise contributions. In such cases, the dynamics depend on simultaneous, group-level processes that involve more than two units  − phenomena that are naturally described within the framework of higher-order networks13,14.

Simple networks describe systems whose elements interact pairwisely. In such cases, collective behaviors emerge from links connecting two agents at a time. While nonlinear effects of multiple pairwise interactions can sometimes be mimicked by effective rules, genuine group interactions cannot be decomposed into independent pairs14. The natural extension of pairwise networks is given by higher-order networks13, which allow simultaneous interactions among any number of nodes and thus capture complex collective effects that simple graphs cannot represent. In pairwise network dynamics, the infinitesimal generator of the Markov process is decomposable into a sum of dyadic operators such that higher-order terms appear only at the level of observables15 (e.g., correlation functions or closures). By contrast, in higher-order interactions represented by hypergraphs13, the microscopic transition rate is defined directly on groups of size m > 2; the generator itself contains irreducible multi-body operators. Such rates cannot be written as a superposition of pairwise contributions without altering the dynamics.

Higher-order interactions have been shown to alter the behavior of complex systems fundamentally. They can induce abrupt or hybrid phase transitions, multistability, or hysteresis16, phenomena that rarely have counterparts in pairwise models. Empirical evidence for such collective mechanisms spans diverse domains: synchronous activation of neural assemblies17,18, multi-species dependencies in ecological webs19, and contagion events driven by group gatherings, airborne exposure, or social reinforcement20–22. Capturing these effects requires frameworks where interactions among sets of nodes, represented as hyperedges or simplices, govern the dynamics.

Despite recent theoretical advances, simulating dynamical processes on higher-order networks remains a major computational challenge. The number of potential interaction events grows combinatorially with system size and interaction order, leading to prohibitive computational costs even for moderately large systems. As a result, most previous studies have been limited to small networks or to low-order interactions (e.g., triads), often implemented in discrete time23–25. However, discrete-time approximations can introduce biases in continuous-time Markovian dynamics26,27, and many key collective effects  − such as vanishing epidemic thresholds in heterogeneous networks − , only emerge in sufficiently large systems11,28.

Here, we develop efficient, statistically exact algorithms for simulating continuous-time contagion dynamics on higher-order networks of arbitrary size and heterogeneity. We develop algorithms to account for highly complex combinatorial states of hyperedge activation, building on the concept of phantom processes29 −attempted events that advance simulation time without changing the system state  −which allows for drastic optimizations of higher-order contagion dynamics. Existing exact stochastic methods scale poorly in this setting because potential events cannot be enumerated locally without repeatedly scanning high-order structures.

This limitation reflects a fundamental difference with respect to pairwise dynamics. In standard network-based models, transition rates can be decomposed into contributions associated with individual nodes or edges, so that the infinitesimal generator of the process is a sum of local operators. As a consequence, the set of feasible events is locally enumerable and can be updated through strictly local operations after each microscopic transition. In contrast, the higher-order dynamics studied here involve intrinsic multi-body interaction rules, where the activation of a transition depends on the simultaneous state of multiple nodes within a hyperedge. This implies that the generator cannot, in general, be expressed as a superposition of pairwise contributions, and that the set of feasible events becomes configuration-dependent and non-locally coupled. A single microscopic update may simultaneously create or remove O(r) potential events, where r is the hyperedge size, making standard local bookkeeping strategies ineffective.

The algorithms introduced here are designed to resolve this structural bottleneck by reorganizing the event space and its sampling in a way that preserves statistical exactness while restoring near-linear computational scaling. As a result, they enable systematic exploration of discontinuous transitions, hysteresis, and heterogeneous higher-order systems at scales that were previously inaccessible. This strategy drastically reduces computational complexity by replacing the global update of event lists with local sampling rules, allowing the simulation of hypergraphs with millions of nodes and broad distributions of both connectivity and order. We demonstrate the performance of the algorithms using the Susceptible − Infected − Susceptible (SIS) model with critical mass thresholds, a paradigmatic example of higher-order contagion dynamics21. Using the Susceptible − Infected − Recovered (SIR) epidemic model, we illustrate how the method can easily be adapted to other spreading processes. Beyond epidemic modeling, the proposed methods offer a general framework for scalable, continuous-time simulations of spreading and activation processes in complex systems with many-body interactions.

Results

Definition and concepts

A convenient mathematical representation of higher-order interactions is the hypergraph, H={N,E}, where N={i1,i2,…,iN} denotes the set of nodes and E={h1,h2,…,hH} the set of hyperedges. Each hyperedge h connects mh + 1 nodes and represents an mh-order interaction: first-order hyperedges correspond to pairwise links, second-order to triads, and so on. A special case is that of simplicial complexes30, where every m-order interaction implies the presence of all lower-order interactions 1, 2, …, m − 1, enforcing a hierarchical inclusion structure that general hypergraphs do not require.

Concepts originally defined for pairwise networks can be generalized to higher-order structures14,31. The generalized degree or m-degree of node i, denoted ki(m), is the number of m-order hyperedges that include it. The node’s hyperdegree vector is then ki = {ki(1), ki(2), ki(3), …}, and the total number of interactions involving node i is Ki = ∑mki(m). Statistical descriptors such as degree distributions can be computed for each order, providing a complete structural characterization of higher-order connectivity14.

Hyper-SIS dynamics

Contagion processes encompass a wide range of spreading phenomena, from disease transmission to information and opinion dynamics1,11,12,32. Here we consider the susceptible-infected-susceptible (SIS) dynamics on hypergraphs (Hyper-SIS), where each node i can be in one of two states: susceptible (σi = 0) or infected (σi = 1). Each hyperedge h can be active (ζh = 1) if its number of active nodes exceeds a critical mass threshold, or inactive (ζh = 0) otherwise. Infection events occur within hyperedges at rates β(m), which are functions of the orders of the hyperedges to which the node belongs, and infected nodes recover spontaneously at a rate α, returning to the susceptible state21,33.

We focus on the Hyper-SIS model with a critical mass threshold34, where contagion in a hyperedge of order m is possible only if at least θ(m) of its m + 1 members are infected. Each susceptible node in an active hyperedge is then infected independently at rate β(m). We denote the vectors of rates and of thresholds by β = {β(1), β(2), …, β(m)} and θ = {θ(1), θ(2), …, θ(m)}, respectively. Figure 1 schematically illustrates the process. More general activation mechanisms of hyperedges are discussed elsewhere21.

Fig. 1. Schematic representation of the Hyper-SIS model.

Fig. 1

Infected nodes (red) transmit the disease to susceptible nodes (gray) via pairwise edges or higher-order interactions, the latter depicted as light-blue shaded regions. In this schematic model, hyperedges are active only if their number of infected nodes exceeds a critical mass threshold θ(m) = m. Pairwise infections occur at a rate β(1), second-order infections at a rate β(2), and so on. Note that no infection with rate β(3) is depicted since the hyperedge is not active.

We use a simple rule for infection that enhances the higher-order interaction effect assuming an infection rate that increases linearly with the hyperedge order:

β(m)=β[1+b(m−1)], 1

where the pairwise infection rate is β(1) = β, and a factor b controls how the interaction strength increases with the hyperedge order. Other relations have been investigated, such as a logarithmic dependence34 and, more frequently, a restriction to pairwise and triadic interactions where β(m) = 0 for m > 2 23,24. We also assume a simple linear dependence for the critical mass threshold:

θ(m)=1+(m−1)θ0. 2

For θ0 = 0, a single infected agent is sufficient to activate the hyperedge, while for θ0 = 1, the activation occurs when all but one agent are infected.

This model naturally reproduces the rich phenomenology of higher-order contagion, including continuous and discontinuous transitions, bistability, and hysteresis, depending on the order composition and threshold parameters. In the following sections, we use the Hyper-SIS dynamics as a benchmark for assessing the accuracy and efficiency of the proposed Gillespie algorithms.

Standard Gillespie algorithm for Hyper-SIS

In a Markovian contagion dynamics, healing and infection events are modeled as a sequence of Poisson processes associated with changes in the state of nodes or edges35. Standard and optimized Gillespie algorithm for simulating Markovian SIS dynamics on simple graphs, originally introduced elsewhere29, is presented in the “Methods" section. This algorithm serves as the foundation for the extensions developed here to handle higher-order interactions.

The Hyper-SIS model retains the same implementation of the healing dynamics of the pairwise model, where a list of all infected nodes, Λ(I), is continuously updated, yielding the total healing rate given by (see the “Methods" section)

F=∑i=1Nασi=αNI, 3

where NI is the number of infected agents. In contrast, updating the infection processes becomes substantially more demanding as higher-order interactions are introduced, since the number of possible infection events grows rapidly with both node degree and hyperedge order. In what follows, we present alternative strategies to implement Hyper-SIS dynamics on hypergraphs with arbitrary degree and order distributions, beginning with lower algorithmic complexity and efficiency, and progressing toward more sophisticated algorithms that achieve higher computational performance. The main symbols used to describe the Hyper-SIS dynamics are summarized in Table 1.

Table 1.

List of the main symbols used in the algorithms for simulations of Hyper-SIS

State of node i σi
State of HE h ζh
Quiescence state of node i ηi
List of infected nodes Λ(I)
List of susceptible nodes in active HEs Λ(S)
List of potentially active HEs Λ(H)
List of potentially quiescent nodes Λ(Q)
Maximum number of susceptible nodes within an active HE ωh
Number of susceptible nodes in HE h nh(S)
Number of active HE of order m that contain node i ni(m)
Number of quiescent nodes NQ
Number of nodes N
Number of HEs H
Interaction distribution PK
Order distribution fm
Power-law interaction distribution exponent γk
Power-law order distribution exponent γm
Hyperdegree of a node i ki
m-degree of a node i ki(m)
Order of HE h mh
Total healing rate F
Total infection rate G
Infection rate in a HE of order m β(m)
Critical mass threshold in a HE of order m θ(m)

Acronym: HE (hyperedge).

Since contagion can occur in any active hyperedge h of order mh, the standard GA for Hyper-SIS requires a list Λ(S) of 2-tuples (i, h) with all susceptible nodes i belonging to active hyperedges h. The total infection rate is given by

G=∑hβ(mh)∑i∈h(1−σi)ζh. 4

The standard GA algorithm proceeds as follows. At each time step, the lists Λ(I) and Λ(S) are constructed, and the total rate of events is computed as R = F + G. An infection or a healing event is then selected with probabilities f = F/R and 1 − f = G/R, respectively. If a healing event is chosen, an infected node is randomly selected from Λ(I) and healed. If an infection event is selected, a susceptible node belonging to an active hyperedge h is drawn from Λ(S) with probability proportional to β(mh) and infected. After each event, time is advanced by τ=−lnu/R, and the states of the affected nodes (σi) and hyperedges (ςh) are updated accordingly.

Rebuilding the infection and recovery lists differs substantially in computational cost. Updating Λ(I) after a healing event is algorithmically simple and inexpensive, as it does not depend on network connectivity: the healed node can be removed from Λ(I) by replacing its entry with the last element of the list. In contrast, updating Λ(S) is considerably more demanding. Following either an infection or healing, Λ(S) must be scanned sequentially to remove all deactivated entries. Concomitantly, all hyperedges containing a newly infected node are scanned appending any that became active to Λ(S). A simpler but computationally prohibitive alternative is to reset both Λ(I) and Λ(S) by visiting all nodes and hyperedges after every event. To distinguish these implementations, we refer to the algorithm with full list rebuilding as GA and to the local-update version as GA+. Although the former is inefficient, it is often used because of its algorithmic simplicity and serves as a reliable benchmark for validating optimized implementations.

Hyperedge-based optimized algorithm (HB-OGA)

The high computational cost of creating and managing infection lists can be reduced by introducing a list of potentially active hyperedges, Λ(H), whose update has low computational and algorithmic complexity. Let nh(S) denote the number of susceptible nodes in hyperedge h. Instead of the exact potential infection of nh(S) susceptible nodes, assume that each active hyperedge h attempts to infect ωh = mh + 1 − θ(mh) nodes at rate β(mh), where ωh represents the maximum number of susceptible nodes allowed within an active hyperedge of order mh, given that at least θ(mh) nodes must be infected for activation. The total infection attempt rate is therefore

G=∑h∈Λ(H)β(mh)ωh, 5

where the sum may include inactive hyperedges (ζh = 0) still present in the list Λ(H), leading to an overestimation of the true infection rate in Eq. (4).

The algorithm proceeds analogously to the optimized Gillespie algorithm (OGA) originally used in pairwise epidemic processes29 (see the section “Methods" for details). A healing or infection attempt event is selected with probabilities f = F/R and 1 − f = G/R, respectively, using Eqs. (3) and (5). For a healing event, an infected node i is randomly chosen from Λ(I) and its state is set to susceptible. This update modifies σi, the list of infected nodes Λ(I), and the number of susceptible members nh(S) for all hyperedges containing node i. To avoid the costly task of scanning the entire list, neither Λ(H), the total attempt rate G, nor the hyperedge states ζh are updated at this stage.

For infection events, a hyperedge h is randomly selected from Λ(H) with probability proportional to βhωh. If h is inactive, the total attempt rate G is adjusted, h is removed from the list, and a phantom process occurs effectively cleaning Λ(H) without a full sweep. If h is active, one of its susceptible nodes becomes infected with probability nh(S)/ωh; otherwise, with complementary probability 1−nh(S)/ωh, a phantom process occurs. In both cases, time advances by τ=−lnu/R. These rejection events exactly compensate for the overcounting of potential infections, ensuring that the algorithm remains statistically exact. The schematic representation of the HB-OGA algorithm is summarized in Fig. 2(a).

Fig. 2. Schematic representation of optimized algorithms for hyper-SIS dynamics.

Fig. 2

a Hyperedge-based (HB) algorithm. A hyperedge (shaded regions) is active (red border) when the number of active nodes (red) satisfies the critical-mass threshold condition. Active hyperedges are selected with probability proportional to their maximum infection rate (βhωh), while the ratio between actual and overcounted infection rates determines the probability of a phantom process. b Node-based (NB) algorithm. Quiescent nodes (crossed circles), i.e., susceptible nodes belonging to active hyperedges, are selected with probability proportional to their maximum allowed infection rate (ki ⋅ β). The actual infection rate is then recovered via the corresponding phantom process probability. See Table 1 for a description of the symbols used.

Node-based optimized algorithm (NB-OGA)

An alternative optimization strategy tracks the infection attempts at the level of individual nodes rather than hyperedges. In this node-based approach, the algorithm monitors susceptible nodes that belong to at least one active hyperedge – hereafter called quiescent nodes. Let ni = {ni(1), ni(2), …, ni(m)} denote the vector giving the number of active hyperedges of each order that include node i. The corresponding infection rate for node i is β ⋅ ni. A node is quiescent if ∣∣ni∣∣ > 0, represented by the variable ηi = 1, and non-quiescent otherwise (ηi = 0).

The algorithm assumes that each quiescent node i experiences infection attempts at rate β ⋅ ki≥β ⋅ ni. Thus, all hyperedges containing node i may attempt to infect it, regardless of whether they are currently active. The total infection attempt rate is

G=∑iβ⋅kiηi, 6

which overestimates the true infection rate. The excess is corrected statistically by phantom processes, as described below.

Moreover, at each step, a healing or infection event is selected with probabilities f = F/R and 1 − f = G/R, using Eqs. (3) and (6). Healing events follow the same procedure as before: an infected node is randomly chosen from Λ(I), its state σi is changed to susceptible, and its quiescence state ηi is updated, subsequently adding the node to the list of quiescent nodes Λ(Q) if necessary, but the quiescence of its neighbors is not updated at this point. For infection events, the algorithm constructs Λ(Q), the list of all NQ nodes that may belong to an active hyperedge. A node is selected from Λ(Q) with probability proportional to β ⋅ ki. If the node is found to be non-quiescent, it is removed from the list, G is updated, and a phantom process occurs. Otherwise, node i is infected with probability β ⋅ ni/β ⋅ ki; if the attempt fails, a phantom process takes place. In both cases, the simulation time advances by τ=−lnu/R. This node-based scheme significantly lowers computational complexity compared with a full reset of infection lists, since only the neighborhood of the selected node is inspected to update ni. The list Λ(Q) can also be maintained efficiently: when nodes become quiescent, they are appended to the list, while those that lose all active hyperedges remain temporarily until selected during later infection attempts. The schematic representation of the NB-OGA algorithm is summarized in Fig. 2(b).

Validation of the optimized algorithms

To compare algorithmic performance across sizes and structural regimes, we generate synthetic hypergraphs using the bipartite configuration model (BCM), adapted from Courtney and Bianconi36; see Supplementary Fig. 1. The BCM allows to produce hypergraphs with arbitrary degree and order distributions PK and fm, respectively. Extensive simulations were performed to assess the efficiency of the proposed algorithms across different network sizes and levels of heterogeneity. Their statistical equivalence is demonstrated in Fig. 3, which shows that all methods yield identical results for both the stationary and temporal evolution of the epidemic prevalence.

Fig. 3. Comparison of the Hyper-SIS dynamics run with different algorithms.

Fig. 3

The top panels show the stationary prevalence, 〈ρ〉, as a function of the pairwise infection rate, β(1) = β, while the bottom panels show the time evolution of the prevalence, ρ(t), for different initial conditions. Simulations were run for 200 independent realizations for networks with N = 16, 000 nodes. The interaction distribution follows a power law PK ~ K−2.7 with K ∈ [3, Kc], and the order is distributed according to a power law fm~(m+1)−γm with m ∈ [1, mc]. Here, Kc and mc are rigid cutoffs. Parameters γm = 6.0, b = 0, and θ0 = 1 are used in the left hand panel, while γm = 3.0, b = 0.8, and θ0 = 0.7 are used in the right hand panels. Acronyms: GA (standard Gillespie algorithm with full list rebuilding), GA+ (standard Gillespie algorithm with local-update), HB-OGA (hyperedge-based optimized Gillespie algorithm) and NB-OGA (node-based optimized Gillespie algorithm).

Performance was evaluated for three classes of structures: homogeneous hypergraphs, power-law hypergraphs, and hypergraphs containing hyperblobs34. For each network type and size, an ensemble of 20 realizations was generated and sampled once. The total simulation time was fixed at T = 10, 000α−1. When the system reached an absorbing state, a single node was randomly reactivated following the quasistationary reactivation method of Ref. 37.

For uniform interaction distributions, the epidemic transition points are approximately invariant with network size, whereas heterogeneous contact distributions exhibit pronounced finite-size effects. The parameter sets were chosen to explore the relevant dynamical regimes by fixing all parameters except β(1), which was adjusted to maintain a constant epidemic prevalence as network size increased.

All CPU times were measured on a workstation equipped with an Intel Core i7-13700F processor (5.2 GHz), 64 GB of DDR4 RAM, and a 250 GB NVMe SSD. The code was implemented in Fortran and compiled with version 2024.2.0 of the LLVM-based Intel Fortran compiler (ifx) for 64-bit Linux, using double precision and standard optimization flags.

Computational performance for homogeneous number of interactions

A simple example of a hypergraph with a homogeneous distribution of interactions is obtained by assigning the same number of interactions, K = 8, to every node, while controlling the fraction of hyperedges of each order m through the order distribution fm. Specifically, we set f1 = 1/2 for pairwise connections, fm = 1/8 for hyperedges of order m = 2, 3, 4, and 5, and fm = 0 otherwise. Although each node has an identical total number of interactions, its generalized degree is heterogeneous because it depends on the orders of the attached hyperedges. The average generalized degrees are 〈ki(1)〉 = 4, 〈ki(m)〉 = 1 for m = 2, 3, 4, 5, and ki(m) = 0 otherwise. This parameter choice ensures that higher-order effects are non-negligible while keeping interactions evenly distributed across nodes.

For the contagion dynamics, we analyze two representative regimes: one with low higher-order spreading rates, dominated by pairwise interactions, and another with strong higher-order effects. The first regime exhibits a continuous transition from the disease-free to the endemic state, as expected in pairwise contagion models38, whereas the second regime, dominated by higher-order interactions, displays a discontinuous transition from the disease-free to a highly active epidemic phase39. Figure 4 shows the CPU times (in seconds) as a function of network size, comparing the efficiency of the algorithms in the supercritical regime for both continuous and discontinuous transitions.

Fig. 4. Algorithms’ performance on homogeneous contact distributions.

Fig. 4

CPU times for the simulation of Hyper-SIS contagion dynamics on a hypergraph with 〈k(1)〉 = 4 and 〈k(m)〉 = 1 for m = 2 to 5. First-order spreading rates β(1) were selected to maintain a stationary prevalence ρ ≈ 0.3 with b = 0 in (a) and ρ ≈ 0.82 with b = 1 in (b); the former was achieved through an initial condition starting from a single infected node while the latter starting with all nodes infected. Parameters were chosen to produce a continuous phase transition in (a) and a discontinuous phase transition in (b). Critical mass threshold is determined by θ0 = 1. Acronyms are the same as previous figures. Error bars are defined as the standard deviation of the CPU time obtained from 20 sampled networks. Acronyms are defined in Figure 3.

As expected, the non-optimized implementation, which fully rebuilds the lists of possible processes after each event in GA, exhibits a high computational complexity that scales as  ~ N2. Nevertheless, it serves as a benchmark to verify the correctness of the more advanced and efficient algorithms, as shown in Fig. 3. The local-update strategy implemented in GA+ is ~80 times faster in the continuous regime and about 20 times faster in the discontinuous regime, although its overall computational complexity still scales as N2. In contrast, the introduction of phantom processes in both HB-OGA and NB-OGA drastically reduces computational complexity, yielding CPU times that scale nearly linearly with system size. Despite their similar scaling, the hyperedge-based approach outperforms the node-based method in low-prevalence regimes, where its CPU times are roughly half those of NB-OGA. Conversely, in high-prevalence regimes, NB-OGA becomes slightly more efficient than HB-OGA. As discussed in for power-law distributions, this relative performance may invert again when strong structural heterogeneity is present.

Computational performance for power-law distributed hypergraphs

The nearly linear computational complexity observed for homogeneous distributions remains valid for heterogeneous order and interaction distributions when they have a size-independent upper cutoff. When the distribution’s upper cutoffs increase with size, such as in power-laws, the algorithm performance has additional demands and linear computation complexity is no longer guaranteed. To evaluate the algorithms’ performance in networks with both interaction and order heterogeneities, we select power-law distributions, PK~K−γk and fm~(m+1)−γm, respectively. To reduce sample-to-sample fluctuations and avoid outliers in randomly generated networks with heavy-tailed distributions, we impose rigid cutoffs Kc and mc, defined by NPKc=1 and Hfmc=1, which yields Kc~N1/γk and mc~H1/γm, still scaling with network size. This procedure suppresses large fluctuations in the maximum number of interactions and the highest hyperedge order, which could hinder precise comparisons of computational efficiency for a finite ensemble of networks40,41. Outliers in order are discussed below in the context of hyperblobs and improved sampling methods to mitigate their effects are considered in the sequence.

We fixed γk = 2.7, minimal degree K = 3, rigid cutoff, and examined the effect of order heterogeneity by considering three order distributions: γm = 6.0 with a cutoff at mc = 10, and γm = 3.0 and 2.5 with rigid cutoffs. Decreasing γm increases order heterogeneity, ranging from networks dominated by pairwise interactions (~90% pairwise and 8% second-order, …) for γm = 6.0, to networks where higher-order interactions are more frequent (around 50% pairwise, 20% second-order, 10% third-order, …) for γm = 2.5.

For γm = 6.0, we set b = 0 and θ0 = 1, yielding dynamics dominated by pairwise interactions and a continuous phase transition. For γm = 3.0, parameters b = 0.8 and θ0 = 0.7 were chosen to produce discontinuous transitions in a regime with moderate higher-order effects. Finally, for γm = 2.5, we used b = 0.9 and θ0 = 0.6 to generate discontinuous transitions with strong higher-order heterogeneity.

Figure 5 shows the CPU times (in seconds) as a function of network size for the different algorithms and the parameter sets described above. For low higher-order heterogeneity (γm = 6.0, Fig. 5a), the performance trends are similar to those observed for homogeneous interaction distributions in Fig. 4: GA+ displays high computational complexity (tCPU ~ N2), whereas the optimized algorithms achieve near-linear scaling (tCPU ~ N) for sizes up to N ~ 105 followed by a crossover to higher computational complexity, still far more efficient than standard GA. Among them, the hyperedge-based approaches are more efficient, running about three times faster than the node-based implementations. For intermediate order heterogeneity (γm = 3.0, Fig. 5b), HB-OGA markedly outperforms GA+ but, in turn, is less efficient than NB-OGA. The latter exhibits CPU times that scale slightly faster than linearly with network size, corresponding to low computational complexity, while HB-OGA scales approximately as tCPU ~ N1.5, indicating a higher computational cost. For strong heterogeneity (γm = 2.5, Fig. 5c), the qualitative behavior is similar to that for γm = 3.0, but both HB-OGA and NB-OGA display increased computational complexity, with CPU times scaling as tCPU ~ N1.7 and tCPU ~ N1.3, respectively. The increased computational complexity is due to the increasing rejections as the upper cutoffs in both order and interactions increase; see Supplementary Fig. 2 and the corresponding discussion in the end of this section.

Fig. 5. Algorithms’ performance on power-law distributed hypergraphs.

Fig. 5

CPU times for simulations of the Hyper-SIS contagion on hypergraphs with power-law interaction and order distributions. First-order spreading rates, β(1), were chosen to maintain the same stationary epidemic prevalence on networks of different sizes. Exponents (a) γm = 6 and ρ ≈ 0.3; (b) γm = 3 and ρ ≈ 0.67; and (c) γm = 2.5 and ρ ≈ 0.8 were considered. Heterogeneous interaction distribution was considered for fixed γk = 2.7 and the degree range K ∈ [3, Kc], where Kc(N) is a rigid cutoff. Acronyms are defined in Figure 3.

The performances were further evaluated for fixed network parameters and varying epidemic prevalences. We considered a continuous transition, in which the order parameter varies smoothly with the control parameter β(1). Simulations were performed with b = 0.4 and θ0 = 1.0 fixed, while β(1) was adjusted to produce low and high prevalences, respectively. We compare the results for a hypergraph with power-law distributions of both node interactions and hyperedge orders; see Supplementary Fig. 3. At high infection densities, the performance of GA+ and HB-OGA deteriorates substantially (up to tenfold slower), whereas NB-OGA is only moderately affected (roughly twice slower). Indeed, at low prevalence, NB-OGA is about one order of magnitude slower than HB-OGA, but the two achieve comparable performance at high prevalence. This crossover arises from the excess of phantom processes in NB-OGA at low prevalence, where the attempt infection rate greatly exceeds the actual rate, i.e., βi ⋅ ki ≫ βi ⋅ ni. Note that for the parameter set used (low b and high θ0), lower-order activations are favored. In contrast, for the same order heterogeneity and similar prevalence, as shown in Fig. 5(b) where NB-OGA outperforms HB-OGA, the parameters with high b and lower θ0 enhance higher-order interactions. These findings indicate that HB-OGA performs best when lower-order interactions dominate the dynamics, while NB-OGA becomes more efficient in regimes driven by strong higher-order effects.

Computational performance for hypergraphs with a Hyperblob

Outliers are common in complex systems and play a key role in shaping their dynamics. In pairwise networks, for instance, a few nodes with degree k ≫ 〈k〉 can sustain metastable localized activity, where only a vanishing fraction of the system maintains epidemic activity in the thermodynamic limit42,43. In higher-order networks, outliers may arise either as nodes with exceptionally large numbers of interactions or as hyperedges of very high order, m ≫ 〈m〉. To evaluate algorithmic performance in this latter scenario, we added a hyperedge of order m = N − 1, referred to as a hyperblob34, to networks with power-law degree and order distributions. The hyperblob alone can induce bistability: once activated, it simultaneously transmits infection to all susceptible nodes at rate β(N − 1). In the Hyper-SIS model with a critical mass threshold, these hyperblob-driven effects emerge only when the density of infected nodes exceeds the activation condition ρN > θ(N − 1).

The Hyper-SIS dynamics associated with hyperblobs are bistable34. To evaluate algorithmic performance, we considered two initial conditions: one where the hyperblob remains inactive (ρ ≈ 0.25) and another where it is active from the start (ρ ≈ 0.82). To explore these regimes, a hyperedge of order N − 1 was added to networks with γk = 2.7 and γm = 6.0, using the same parameters as in Fig. 5(a). Figure 6 shows the CPU times (in seconds) obtained for different algorithms applied to the hyperblob case. In the low-prevalence regime, dominated by lower-order interactions, GA+ performs inefficiently, exhibiting a computational complexity of tCPU ~ N2, whereas HB-OGA and NB-OGA are markedly more efficient, with scaling tCPU ~ N1.1 and tCPU ~ N1.2, respectively.

Fig. 6. Algorithms’ performance with the presence of a hyperblob.

Fig. 6

CPU times for the simulation of Hyper-SIS contagion dynamics on a PL higher-order network of γm = 6.0 plus a hyperblob. The dynamics is bistable and two regimes were tested: (a) lower prevalence where the hyperblob is inactive with ρ ≈ 0.25 and (b) higher prevalence when the hyperblob is active with ρ ≈ 0.82. Critical mass threshold is controlled by θ0 = 0.5 and β(m) = β(1) for all orders except the hyperblob for which β(N − 1) = 20β(1). Acronyms are defined in Figure 3.

In the high-prevalence regime, dominated by hyperblob activation, HB-OGA becomes substantially slower – over an order of magnitude less efficient than GA+, while NB-OGA retains its computational scaling with a smaller prefactor. The strong slowdown of HB-OGA at high prevalence arises from the excess of rejected attempts when sampling hyperedges in proportion to βhωh once the hyperblob is active. In contrast, NB-OGA improves in this regime because phantom processes become less frequent: the number of active hyperedges ni connected to a node i approaches its hyperdegree ki, bringing the ratio β ⋅ ni/β ⋅ ki closer to unity.

Improved sampling methods

While the focus of this work is on employing phantom processes to accelerate simulations, the basic rejection method used to sample nodes or hyperedges with broadly distributed weights {wi} can lead to an excessive number of rejections when wi/wmax ≪ 1 for most elements, where wmax=maxi{wi}. This inefficiency can drastically degrade performance. Sampling efficiency can be improved through binary tree (BT) structures44, alias sampling techniques44, or–favoring simplicity–the improved optimized Gillespie algorithm (IOGA) introduced in Ref. 29. The key idea behind IOGA is to reduce rejections by partitioning quiescent nodes or potentially active hyperedges into two (or more) groups according to their weights: Λlow = {i∣wi≤w*} and Λhigh = {i∣wi > w*}. The total infection rate is then divided between the two groups,

Glow=∑i∈Λlowwi, 7

and

Ghigh=∑i∈Λhighwi. 8

When an infection attempt occurs, an element is drawn from Λlow with probability Glow/(Glow + Ghigh), proportionally to its weight; otherwise, an element from Λhigh is selected. The rejection step then uses wi/w* or wi/wmax depending on whether the sample came from the low- or high-weight group, respectively. The threshold w* should be chosen to minimize the number of rejections. Since weight distributions in epidemic processes typically decay, setting w* ≳ 〈w〉 is generally sufficient. In our implementation, we adopt w* = 〈w〉 + σw, where σw=⟨w2⟩−⟨w⟩2 denotes the standard deviation of the weights.

Binary trees are data structures commonly used to enable efficient weighted sampling in stochastic simulations. In this approach, individual events are stored as leaves, while internal nodes contain the cumulative weights of their descendants, forming a hierarchical representation of partial sums. Sampling is performed by drawing a uniform random number and traversing the tree according to these cumulative weights until a leaf (event) is selected. This procedure, as well as updates to event weights, can be carried out in O(lnN) time.

Table 2 summarizes the CPU times for Hyper-SIS simulations incorporating both order and contact heterogeneities, confronting the computational performance of standard OGA with IOGA and sampling using binary trees, using the same parameters as in Fig. 5(b). While IOGA and BT present similar performance with the former being slightly better, their computational advantage become increasingly pronounced as network size and heterogeneity grow. Among the optimized methods, HB-OGA gains more from the IOGA correction because the acceptance probability for hyperedge infection attempts is inversely proportional to ωh = mh + 1 − θ(mh), whose distribution is broader than that of the infection attempts for quiescent nodes in NB-OGA. Nevertheless, NB-OGA remains significantly more efficient than HB-OGA in regimes characterized by strong higher-order heterogeneity.

Table 2.

Performances of improved rejection methods

Hyperedge-Based Node-Based
N 105 106 107 105 106 107
OGA 7.8 252.6 – 8.2 284.6 –
ρ = 0.25 IOGA 1.9 47.0 1121.1 6.2 176.2 4328.6
BT 2.8 64.1 1665.8 8.8 181.2 4988.0
OGA 40.1 2148.5 – 7.3 251.7 –
ρ = 0.8 IOGA 8.4 248.2 15809.1 4.5 101.6 2971.7
BT 10.5 291.0 11252.2 6.2 168.7 3678.1

CPU times in minutes to run a total fixed time of 104α−1 in quasistationary simulations of the Hyper-SIS model on a PL higher-order network with degree and order exponents set to γk = 3 and γm = 3. Parameters were set to b = 0.6 and θ0 = 0.8, with the first-order spreading rate β(1) set to maintain a fixed stationary infection density ρ indicated in the table. The rejection methods compared were: the standard rejection OGA, the improved rejection with IOGA and a binary trees (BT).

Algorithms’ performance on real networks

Algorithm performances on real networks are shown in Fig. 7. The first dataset, eventernote-events45, contains 69,885 nodes and 131,647 hyperedges, where nodes represent individuals and hyperedges correspond to events attended by them. The interaction order ranges from 1 to 619, with an average 〈m〉 = 9.05 and standard deviation σm = 13.06. The second network, coauth-dblp46, comprises 1,659,954 nodes and 2,093,835 hyperedges, with nodes representing authors and hyperedges representing their publications on DBLP. In this case, the interaction order spans from 1 to 219, with 〈m〉 = 3.46 and σm = 1.76. Both datasets were obtained from the XGI Python library47. The measured CPU times reveal that the standard GA and GA+ are much less efficient than the optimized algorithms, with NB-OGA outperforming HB-OGA due to the substantial heterogeneity presented in the real networks. Furthermore, the IOGA further improves efficiency for both approaches, particularly in the larger coauth-dblp network.

Fig. 7. Algorithms’ performance on real higher-order networks.

Fig. 7

Total evolution time reached after 12 h of real CPU time of Hyper-SIS on real hypergraphs eventernote-events (69,885 nodes and 131,647 hyperedges) and coauth-dblp (1,659,954 nodes and 2,093,835 hyperedges). For each network, 8 runs were taken with parameters b = 0.6, θ0 = 0.8. First-order spreading rates β(1) = 0.1 and β(1) = 0.8 were used for the former and the latter, respectively, in order to obtain a stationary density of infected nodes ρ ≈ 0.4 in both cases. Acronyms: HB-IOGA (hyperedge-based improved optimized Gillespie algorithm); NB-IOGA (node-based optimized Gillespie algorithm); other acronyms are defined in Figure 3.

Optimized algorithms for other dynamical processes

Since Hyper-SIS captures the essential ingredients of algorithms for higher-order spreading processes, its extension to other dynamical models is straightforward. For instance, in the SIR epidemic process, where healed nodes remain permanently recovered, the only difference is that recovered nodes cannot be reinfected, while infection and healing rules are otherwise identical to those of SIS. Figure 8 shows the performance analysis for spreading on hypergraphs with power-law distributions of node degree and hyperedge order. The initial condition consists of a single infected node chosen at random, and simulations run until the absorbing state is reached.

Fig. 8. Algorithm performance for SIR spreading on power-law hypergraphs.

Fig. 8

CPU times (in seconds) for simulations starting from a single infected node randomly selected and running until activity ceases (i.e., the absorbing state is reached). The higher-order network has power-law degree and order distributions with exponents γk = 3 and γm = 3. Spreading parameters were set to (a) b = 0, θ0 = 1.0, yielding a final recovered fraction ρR = 0.1, and (b) b = 0, θ0 = 1.0, yielding ρR = 0.3. A total of 10 000 runs were performed per network. Acronyms are defined in Figures 3 and 7.

The order parameter is the final fraction of recovered individuals, ρR. In the low-incidence regime (ρR = 0.1), both HB-OGA and NB-OGA exhibit nearly linear computational complexity, with HB-OGA outperforming NB-OGA by a factor of ~four. Notably, IOGA provides only a slight improvement for the node-based approach, while no noticeable difference is observed for the hyperedge-based approach; the curves for HB-OGA and HB-IOGA are indistinguishable at this scale. This occurs because high-order hyperedges are rarely activated in this regime, rendering the IOGA method effectively redundant. In contrast, in the higher-incidence regime (ρR = 0.3), HB-OGA suffers a significant loss of efficiency, which is recovered when using IOGA, whereas NB-OGA maintains a computational complexity similar to that observed in the low-incidence regime.

Indeed, the generalization to other spreading processes requires only minor adjustments. As an example, consider a version of the Maki − Thompson model for rumor spreading48 on higher-order networks, implemented using NB-OGA. This model features states analogous to SIR dynamics: susceptible individuals correspond to ignorants, who are unaware of the rumor; infected individuals correspond to spreaders, who propagate the rumor to ignorants; and recovered individuals correspond to stiflers, who are aware of the rumor but no longer interested in spreading it. The spreading of the rumor follows the same mechanism as infection in the SIR model, occurring at rate β(m) for each active hyperedge of order m to which a node belongs to. In contrast, the stifling (recovery) process occurs at rate α(m) when spreaders belong to hyperedges of order m containing a number of aware individuals (spreaders plus stiflers) above a threshold ϕ(m); such hyperedges are referred to as saturated.

Thus, the spreading dynamics closely mirrors that of the SIR model: a list of quiescent ignorants, i.e., those belonging to at least one active hyperedge, is constructed, and one node is selected with weight wi ∝ β ⋅ ki. The selected node becomes a spreader with probability β ⋅ ni/(β ⋅ ki), where ni is the actual number of active hyperedges to which node i belongs to; otherwise, a phantom process occurs. The stifling dynamics requires an additional list of quiescent spreaders, defined as those belonging to at least one saturated hyperedge. A node from this list is selected with probability proportional to α ⋅ ki and becomes a stifler with probability α ⋅ zi/(α ⋅ ki), where zi is the actual number of saturated hyperedges to which node i belongs to; otherwise, a phantom process occurs. Both lists of quiescent ignorants and spreaders are updated using the same procedures employed for quiescent nodes in the SIR dynamics.

Counting rejection and phantom events

The computational complexity of the algorithms is strongly dependent on the number of rejections during the simulation and becomes critical when the order and interaction distributions are broad, with upper cutoffs that diverge with system size. We quantify the acceptance probability during sampling for different algorithms, considering power-law order distributions with a rigid upper cutoff; see Supplementary Fig. 2. The acceptance probability decays approximately as a power law with system size, implying a higher computational cost for larger systems. On the other hand, the fraction of attempted infections that result in phantom processes is largely size-independent and remains stable across prevalence regimes. Therefore, the contribution of the dynamical evolution – excluding the random sampling step used to select nodes and hyperedges–has a low computational complexity of O(N). Consequently, if facc(N) denotes the probability that a sampling attempt is accepted [see Supplementary Fig. 2(a)], the CPU time is expected to scale as tCPU ~ N/facc(N); see Supplementary Fig. 2(b).

Discussion

We developed the optimized Gillespie algorithm29, originally introduced for pairwise spreading processes, to simulate Markovian contagion models on higher-order networks of large size and strong heterogeneity in both node degrees and hyperedge orders. Our analysis focused on the Hyper-SIS model with a critical mass threshold21, enabling the assessment of algorithmic efficiency across networks ranging from 103 to 107 nodes. Extensions to other dynamical processes, including Hyper-SIR and rumor spreading with higher-order interactions, were also presented. Synthetic benchmarks were generated using the bipartite configuration model36, and real-world datasets were examined46,47.

We proposed two algorithms based on the concept of phantom processes29, in which the exhaustive list of potential events required by the standard GA–associated with high computational cost–is replaced by a list containing both actual and phantom events that advance time without altering the system state. In the node-based OGA, the list tracks quiescent nodes belonging to active hyperedges, whereas the hyperedge-based OGA monitors potentially active hyperedges. These optimized approaches are up to several orders of magnitude faster than the standard GA, with CPU times scaling nearly linearly with system size (tCPU ~ N) for bounded order and interaction distributions, compared to the quadratic scaling (tCPU ~ N2) of the standard method. For distributions with upper cutoffs increasing with system size, the computational complexity departs from strict linearity, but remains significantly more efficient than the quadratic scaling of the standard algorithm. The node-based version outperforms the hyperedge-based one in highly heterogeneous networks, whereas the reverse holds for low-heterogeneity structures. In addition, the adoption of efficient rejection schemes to sample nodes or hyperedges further improves performance, especially in strongly heterogeneous systems.

In the low-prevalence regime, where contagion is dominated by pairwise interactions, our results agree with previous studies on purely pairwise contagion models29,37,49. In contrast, in high-prevalence regimes, where higher-order interactions sustain the spreading dynamics, the proposed algorithms exhibit substantially lower computational complexity than the standard GA. While GA scales as tCPU ~ N2, HB-OGA and NB-OGA achieve nearly linear scaling with system size, representing the lower computational bound in non-vanishing prevalence regimes. The relative performance of the two optimized methods depends on the strength of higher-order effects: as these interactions become stronger, the node-based approach (NB-OGA) increasingly outperforms the hyperedge-based one (HB-OGA). The observed tCPU ~ N2 scaling of the standard algorithm arises from the finite-prevalence regime (ρ = 0.1 − 0.8) considered here, where a macroscopic fraction of higher-order interactions remains active, and is therefore not directly tied to structural density. In contrast, the optimized algorithms approach the minimal achievable complexity tCPU ~ N under bounded interaction sizes, highlighting their ability to efficiently handle configuration-dependent multi-body event spaces.

Finally, we also analyzed simplicial complexes, a specific class of higher-order networks13,30. These structures are densely connected at lower orders, resulting in a large number of links per node, and are frequently used as a framework for studying contagion dynamics23,50. Their performance characteristics are consistent with those observed in Fig. 4 for networks with homogeneous interaction sizes and low order heterogeneity: HB-OGA and NB-OGA achieve comparable performance with low computational complexity, scaling as tCPU ~ N, and both significantly outperform the standard GA, which exhibits the much higher complexity tCPU ~ N2.

Although initially motivated by SIS-type contagion dynamics and extended here to SIR epidemic models and Maki–Thompson rumor spreading dynamics, the algorithms can be readily generalized to other processes on hypergraphs exhibiting inactive-to-active transitions, including rumor propagation48,51,52 and other epidemic models such as SIRS and SEIR11,50,53. More broadly, the relevance of the proposed approach stems from the fact that higher-order dynamical processes are governed by intrinsically multi-body interaction rules, for which the set of feasible transitions is configuration-dependent and cannot be efficiently handled within standard pairwise frameworks. In this context, the algorithms introduced here provide a scalable and statistically exact methodology for simulating such systems. We therefore expect them to become versatile tools for investigating spreading and activation dynamics in large, heterogeneous higher-order networks, enabling the systematic exploration of models and phenomena that remain inaccessible to conventional simulation approaches.

Methods

The optimized Gillespie algorithm for SIS models with pairwise interactions

Before discussing epidemic models, consider a set of Z independent Poisson processes, p = 1, 2, 3, …, Z, each occurring at rate λp, such that the probability that an event p occurs within the time interval [t, t + dt] is λpdt. The total rate at which any event occurs is R=∑p=1Zλp, implying that the probability density function for an event to occur at time t is

π(τ)=R∏p=1Ze−λpτ=Re−Rτ. 9

The Gillespie algorithm (GA)54 is a statistically exact method for simulating Markovian stochastic reaction processes. It proceeds through discrete time steps τ drawn from an exponential distribution as defined in Eq. (9), and at each step selects one event with probability proportional to its rate λp. The list of all possible events is continuously updated during the simulation.

The standard (non-optimized) GA applied to the SIS model on pairwise networks involves two lists of processes: Λ(I), containing all NI infected nodes, and Λ(IS), containing all NIS edges connecting infected to susceptible nodes. The total rate has two contributions, R = F + G, where

F=∑i=1Nασi=αNI, 10

is the total healing rate, and

G=∑i,jAijβσi(1−σj)=βNIS, 11

is the total infection rate, with Aij=A{i,j}(1) being the standard adjacency matrix2. At each time step, with probability f = F/R, one node is randomly selected from the list Λ(I) and healed. With complementary probability 1 − f = G/R, one IS edge is randomly chosen from the list Λ(IS), and the corresponding susceptible node is infected. Time is incremented by τ=−lnu/R, where u is a pseudo-random number uniformly distributed in the range (0, 1), and both lists are updated.

Updating the infection lists has high computational complexity, which quickly becomes prohibitive even for networks of only tens of thousands of nodes. This limitation can be largely overcome by aforementioned phantom processes29. In epidemic models, this corresponds to overcounting infection attempts by assuming that each infected node transmits to all of its neighbors at rate β, regardless of their state, while an actual infection occurs only if the selected neighbor is susceptible. This leads to a total attempt infection rate

G=∑iβkiσi, 12

which is greater than or equal to the true infection rate in Eq. (11). The rest of the algorithm proceeds analogously. The main different is that when an infection attempt is chosen, an infected node from the list Λ(I) (no longer requiring Λ(IS)) is selected with probability proportional to its degree ki. One of its neighbors j is then chosen at random: if j is susceptible, it becomes infected; otherwise, a phantom process occurs and the system state remains unchanged. In both cases, time is advanced by τ=−lnu/R, with R computed from Eqs. (10) and ((12)). This optimization preserves the statistical exactness of the Gillespie procedure29.

Supplementary information

Supplementary Information (535.9KB, pdf)

Acknowledgements

We thank M. Clarin from COSNET Lab-BIFI for helping with the figures.

Author contributions

H.P.M: Conceptualization, formal analysis, methodology, data curation, coding and simulations, visualization, writing original draft. W.C.: Validation, methodology, data curation, formal analysis, coding and simulations, writing and editing. Y.M.: Conceptualization, formal analysis, writing and editing, and funding acquisition. S.C.: Conceiving the study, conceptualization, formal analysis, methodology, writing original draft, supervision, and funding acquisition.

Peer review

Peer review information

Nature Communications thanks the anonymous reviewer(s) for their contribution to the peer review of this work. A peer review file is available.

Funding

H.P.M, S.C.F, and W.C. acknowledge the financial support of Fundação de Amparo à Pesquisa do Estado de Minas Gerais (FAPEMIG)-Brazil (Grants No. APQ-01973-24 and APQ-03079-24). S.C.F. acknowledges the financial support by the Conselho Nacional de Desenvolvimento Científico e Tecnológico (CNPq)-Brazil (Grants no. 310984/2023-8 and 408389/2024-9 INCT-NeuroComp) and Fundação de Amparo à Pesquisa do Estado de São Paulo (FAPESP)-Brazil (Grant. No. 25/24366-1). W. C. acknowledges the financial support by INCT-DigiSaúde (CNPq Grant 408775/2024-6). Y. M. was partially supported by the Government of Aragon, Spain, and ERDF “A way of making Europe” through grant E36-23R (FENOL). YM also acknowledges support from Grant No. PID2023-149409NB-I00 from Ministerio de Ciencia, Innovación y Universidades, Agencia Española de Investigación (MICIU/AEI/10.13039/501100011033) and ERDF “A way of making Europe”. This study was financed in part by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior (CAPES), Brazil, Finance Code 001.

Data availability

Hypergraph datasets generated in this paper are publicly at (10.5281/zenodo.17187745), ref. 55.

Code availability

The HB-OGA and NB-OGA codes are available at (https://github.com/gisc-ufv/hyperSIS), ref. 56. The code is developed in Modern Fortran57, it follows a modular, object-oriented structure and is compatible with the Fortran Package Manager (fpm)58, as well as a Python interface. A Jupyter Notebook with usage examples is provided. Network input can be supplied as a list of hyperedges, in bipartite format, in the XGI JSON format47, or in the HIF standard format59. Both temporal and quasi-stationary dynamics are available. The code was run using the LLVM-based Intel Fortran (ifx) and the non-commercial GNU Fortran (gfortran) compilers, on Linux and Windows Subsystem for Linux (WSL).

Competing interests

The authors declare no competing interests.

Footnotes

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary information

The online version contains supplementary material available at 10.1038/s41467-026-75402-0.

References

  • 1.Barrat, A., Barthélemy, M. & Vespignani, V. DynamicalProcesses on Complex Networks (Cambridge University Press, 2008).
  • 2.Barabási, A. L. & Pósfai, M. Network Sciencehttps://books.google.com.br/books?id=ZVHesgEACAAJ (Cambridge University Press, 2016).
  • 3.Gómez-Gardeñes, J., Gómez, S., Arenas, A. & Moreno, Y. Explosive synchronization transitions in scale-free networks. Phys. Rev. Lett.106, 128701 (2011). [DOI] [PubMed] [Google Scholar]
  • 4.Arenas, A., Díaz-Guilera, A., Kurths, J., Moreno, Y. & Zhou, C. Synchronization in complex networks. Phys. Rep.469, 93–153 (2008). [Google Scholar]
  • 5.Deffuant, G., Neau, D., Amblard, F. & Weisbuch, G. Mixing beliefs among interacting agents. Adv. Complex Syst.3, 87–98 (2000). [Google Scholar]
  • 6.Maia, H. P., Ferreira, S. C. & Martins, M. L. Adaptive network approach for emergence of societal bubbles. Phys. A: Stat. Mech. its Appl.572, 125588 (2021). [Google Scholar]
  • 7.Haimovici, A., Tagliazucchi, E., Balenzuela, P. & Chialvo, D. R. Brain organization into resting state networks emerges at criticality on a model of the human connectome. Phys. Rev. Lett.110, 178101 (2013). [DOI] [PubMed] [Google Scholar]
  • 8.Bullmore, E. & Sporns, O. Complex brain networks: graph theoretical analysis of structural and functional systems. Nat. Rev. Neurosci.10, 186–198 (2009). [DOI] [PubMed] [Google Scholar]
  • 9.Montoya, J. M., Pimm, S. L. & Solé, R. V. Ecological networks and their fragility. Nature442, 259–264 (2006). [DOI] [PubMed] [Google Scholar]
  • 10.Fath, B. D., Scharler, U. M., Ulanowicz, R. E. & Hannon, B. Ecological network analysis: network construction. Ecol. Model.208, 49–55 (2007). [Google Scholar]
  • 11.Pastor-Satorras, R., Castellano, C., Van Mieghem, P. & Vespignani, A. Epidemic processes in complex networks. Rev. Mod. Phys.87, 925–979 (2015). [Google Scholar]
  • 12.Ferraz de Arruda, G., Rodrigues, F. A. & Moreno, Y. Fundamentals of spreading processes in single and multilayer complex networks. Phys. Rep.756, 1–59 (2018). [Google Scholar]
  • 13.Bianconi, G. Higher-Order Networks, Elements in the Structure and Dynamics of Complex Networks10.1017/9781108770996 (Cambridge University Press, 2021).
  • 14.Battiston, F. et al. The physics of higher-order interactions in complex systems. Nat. Phys.17, 1093–1098 (2021). [Google Scholar]
  • 15.Hinrichsen, H. Non-equilibrium critical phenomena and phase transitions into absorbing states. Adv. Phys.49, 815–958 (2000). [Google Scholar]
  • 16.Ferraz de Arruda, G., Petri, G., Rodríguez, P. & Moreno, Y. Multistability, intermittency, and hybrid transitions in social contagion models on hypergraphs. Nat. Commun. 10.1038/s41467-023-37118-3 (2023). [DOI] [PMC free article] [PubMed]
  • 17.Sizemore, A. E., Phillips-Cremins, J. E., Ghrist, R. & Bassett, D. S. The importance of the whole: Topological data analysis for the network neuroscientist. Netw. Neurosci.3, 656–673 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Sizemore, A. E. et al. Cliques and cavities in the human connectome. J. Comput. Neurosci.44, 115–145 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Bairey, E., Kelsic, E. D. & Kishony, R. High-order species interactions shape ecosystem diversity. Nat. Commun.7, 12285 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Mancastroppa, M., Guizzo, A., Castellano, C., Vezzani, A. & Burioni, R. Sideward contact tracing and the control of epidemics in large gatherings. J. R. Soc. Interface19, 20220048 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Ferraz de Arruda, G., Aleta, A. & Moreno, Y. Contagion dynamics on higher-order networks. Nat. Rev. Phys.10.1038/s42254-024-00733-0 (2024).
  • 22.St-Onge, G., Sun, H., Allard, A., Hébert-Dufresne, L. & Bianconi, G. Universal nonlinear infection kernel from heterogeneous exposure on higher-order networks. Phys. Rev. Lett.127, 158301 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Iacopini, I., Petri, G., Barrat, A. & Latora, V. Simplicial models of social contagion. Nat. Commun.10, 2485 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Landry, N. W. & Restrepo, J. G. The effect of heterogeneity on hypergraph contagion models. Chaos: Interdiscip. J. Nonlinear Sci.30, 103117 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Kim, J., Lee, D.-S. & Goh, K.-I. Contagion dynamics on hypergraphs with nested hyperedges. Phys. Rev. E108, 034313 (2023). [DOI] [PubMed] [Google Scholar]
  • 26.Fennell, P. G., Melnik, S. & Gleeson, J. P. Limitations of discrete-time approaches to continuous-time contagion dynamics. Phys. Rev. E94, 052125 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Silva, D. H., Rodrigues, F. A. & Ferreira, S. C. Accuracy of discrete- and continuous-time mean-field theories for epidemic processes on complex networks. Phys. Rev. E110, 014302 (2024). [DOI] [PubMed] [Google Scholar]
  • 28.Ferreira, S. C., Castellano, C. & Pastor-Satorras, R. Epidemic thresholds of the susceptible-infected-susceptible model on networks: A comparison of numerical and theoretical results. Phys. Rev. E86, 041125 (2012). [DOI] [PubMed] [Google Scholar]
  • 29.Cota, W. & Ferreira, S. C. Optimized Gillespie algorithms for the simulation of Markovian epidemic processes on large and heterogeneous networks. Comput. Phys. Commun.219, 303–312 (2017). [Google Scholar]
  • 30.Torres, J. J. & Bianconi, G. Simplicial complexes: higher-order spectral dimension and dynamics. J. Phys.: Complex.1, 015002 (2020). [Google Scholar]
  • 31.Bick, C., Gross, E., Harrington, H. A. & Schaub, M. T. What are higher-order networks? SIAM Rev.65, 686–731 (2023). [Google Scholar]
  • 32.Castellano, C., Fortunato, S. & Loreto, V. Statistical physics of social dynamics. Rev. Mod. Phys.81, 591–646 (2009). [Google Scholar]
  • 33.Cencetti, G., Contreras, D. A., Mancastroppa, M. & Barrat, A. Distinguishing simple and complex contagion processes on networks. Phys. Rev. Lett.130, 247401 (2023). [DOI] [PubMed] [Google Scholar]
  • 34.Barrat, A., Ferraz de Arruda, G., Iacopini, I. & Moreno, Y. Social contagion on higher-order structures in Higher-order systems10.1007/978-3-030-91374-8_13 pp. 329–346 (Springer, 2022).
  • 35.Daley, D. & Gani, J.Epidemic Modelling: An Introduction, Cambridge studies in mathematical biology https://books.google.es/books?id=DFrxpZHdz9UC (Cambridge University Press, 1999).
  • 36.Courtney, O. T. & Bianconi, G. Generalized network structures: The configuration model and the canonical ensemble of simplicial complexes. Phys. Rev. E93, 062311 (2016). [DOI] [PubMed] [Google Scholar]
  • 37.Costa, G. S. & Ferreira, S. C. Simple quasistationary method for simulations of epidemic processes with localized states. Comput. Phys. Commun.267, 108046 (2021). [Google Scholar]
  • 38.Pastor-Satorras, R. & Vespignani, A. Epidemic spreading in scale-free networks. Phys. Rev. Lett.86, 3200 (2001). [DOI] [PubMed] [Google Scholar]
  • 39.Ferraz de Arruda, G., Tizzani, M. & Moreno, Y. Phase transitions and stability of dynamical processes on hypergraphs. Commun. Phys.4, 24 (2021). [Google Scholar]
  • 40.Silva, D. H., Ferreira, S. C., Cota, W., Pastor-Satorras, R. & Castellano, C. Spectral properties and the accuracy of mean-field approaches for epidemics on correlated power-law networks. Phys. Rev. Res.1, 033024 (2019). [Google Scholar]
  • 41.Boguñá, M., Pastor-Satorras, R. & Vespignani, A. Cut-offs and finite size effects in scale-free networks. Eur. Phys. J. B38, 205 - 209 (2004). [Google Scholar]
  • 42.Boguñá, M., Castellano, C. & Pastor-Satorras, R. Nature of the epidemic threshold for the susceptible-infected-susceptible dynamics in networks. Phys. Rev. Lett.111, 068701 (2013). [DOI] [PubMed] [Google Scholar]
  • 43.Silva, D. H. & Ferreira, S. C. Dissecting localization phenomena of dynamical processes on networks. J. Phys.: Complex.2, 025011 (2021). [Google Scholar]
  • 44.D’Ambrosio, F., Bodlaender, H. L. & Barkema, G. T. Dynamic sampling from a discrete probability distribution with a known distribution of rates. Computational Stat.37, 1203–1228 (2022). [Google Scholar]
  • 45.Luo, B. et al. eventernote-events, 10.5281/zenodo.11151063 (2024).
  • 46.Benson, A. R., Abebe, R., Schaub, M. T., Jadbabaie, A. & Kleinberg, J. Simplicial closure and higher-order link prediction. Proc. Natl. Acad. Sci.115, E11221–E11230 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 47.Landry, N. W. et al. Xgi: A python package for higher-order interaction networks. J. Open Source Softw.8, 5162 (2023). [Google Scholar]
  • 48.Ferraz de Arruda, G., Jeub, L. G., Mata, A. S., Rodrigues, F. A. & Moreno, Y. From subcritical behavior to a correlation-induced transition in rumor models. Nat. Commun.13, 3049 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 49.St-Onge, G., Young, J.-G., Hébert-Dufresne, L. & Dubé, L. J. Efficient sampling of spreading processes on complex networks using a composition and rejection algorithm. Comput. Phys. Commun.240, 30–37 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 50.Wang, D., Zhao, Y., Luo, J. & Leng, H. Simplicial sirs epidemic models with nonlinear incidence rates. Chaos: Interdiscip. J. Nonlinear Sci.31, 053112 (2021). [DOI] [PubMed] [Google Scholar]
  • 51.Daley, D. J. & Kendall, D. G. Epidemics and rumours. Nature204, 1118–1118 (1964). [DOI] [PubMed] [Google Scholar]
  • 52.Oliveira, K. A., Traversa, P., Ferraz de Arruda, G. & Moreno, Y. Rumor propagation on hypergraphs. Nat. Commun.17, 3253 (2026). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 53.Zhang, Z., Mei, X., Jiang, H., Luo, X. & Xia, Y. Dynamical analysis of hyper-sir rumor spreading model. Appl. Math. Comput.446, 127887 (2023). [Google Scholar]
  • 54.Gillespie, D. T. A general method for numerically simulating the stochastic time evolution of coupled chemical reactions. J. Computational Phys.22, 403–434 (1976). [Google Scholar]
  • 55.Maia, H. P., Cota, W., Moreno, Y. & Ferreira, S. C., Datasets of hypergraphs with power-law degree and order distributions. 10.5281/zenodo.17187745 (2025).
  • 56.Maia, H. P., Cota, W., Moreno, Y. & Ferreira, S. C., 10.5281/zenodo.20548808 Efficient gillespie algorithms for spreading phenomena in large and heterogeneous higher-order networks: gisc-ufv/hypersis: v1.2.1, (2026). [DOI] [PMC free article] [PubMed]
  • 57.Curcic, M., Modern Fortran, edited by Rouson, D. http://ieeexplore.ieee.org/document/10280370 (Manning Publications Company, Shelter Island, NY, 2020).
  • 58.Kedward, L. J. et al. The state of Fortran. Comput. Sci. Eng.24, 63–72 (2022). [Google Scholar]
  • 59.Coll, M. et al. Hif: The hypergraph interchange format for higher-order networks. Netw. Sci.13, e21 (2025). [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Information (535.9KB, pdf)

Data Availability Statement

Hypergraph datasets generated in this paper are publicly at (10.5281/zenodo.17187745), ref. 55.

The HB-OGA and NB-OGA codes are available at (https://github.com/gisc-ufv/hyperSIS), ref. 56. The code is developed in Modern Fortran57, it follows a modular, object-oriented structure and is compatible with the Fortran Package Manager (fpm)58, as well as a Python interface. A Jupyter Notebook with usage examples is provided. Network input can be supplied as a list of hyperedges, in bipartite format, in the XGI JSON format47, or in the HIF standard format59. Both temporal and quasi-stationary dynamics are available. The code was run using the LLVM-based Intel Fortran (ifx) and the non-commercial GNU Fortran (gfortran) compilers, on Linux and Windows Subsystem for Linux (WSL).


Articles from Nature Communications are provided here courtesy of Nature Publishing Group

RESOURCES