Skip to main content
. 2025 Aug 21;16:7809. doi: 10.1038/s41467-025-63001-4

Table 1.

Hypergraph construction algorithm pseudo-code

Algorithm: Hypergraph construction
Input: Disturbance value R; Coupling coefficients μ1 and μ2; Number of the nearest neighbor nodes K; Flow matrix MF; Distance matrix MD; Node set 1, 2,,n.
Output: Hypergraph matrix H.
1 Initialize the hypergraph. Establish the empty hypergraph matrix H=0n×n, where rows represent hyperedges and columns represent nodes.
2 For node i in node set 1, 2,,n:
3    Initialize node states. Using Eq. (5) in the main text to calculate each node state at time t=0. Denote as x10,x20,,xn(0).
4    Apply the disturbance. Add R to the state value of node i, xi0+=R.
5    While xit>1,i{1, 2,,n}:
6     Disturbance propagation. According Eq. (1) in the main text, update each node state set in the next time step.
7     Flow propagation. According Eqs. (6) and (7) in the main text, the flow of all xit+1(0, 1] nodes are allocated to a maximum of K neighbor nodes whose state values are in the interval (0, 1].
8     Node failure. For any node i, if xit+1>1, we set xit+1=0, fij=fji=0, dij=dji=1, j1, 2,,n, t+=1.
9   End
10     Update hypergraph matrix H. If node i causes the failure of node j (xj(t)=0), then set the value in the ith row and jth column of H to 1.
11 End