Tensor network dynamical message passing for epidemic models Cheng Ye, Zi-Song Shen, Pan Zhang Abstract While epidemiological modeling is pivotal for informing public health strategies, a fundamental trade-off limits its predictive fidelity: exact stochastic simulations are often computationally intractable for large-scale systems, whereas efficient analytical approximations typically fail to account for essential short-range correlations and network loops. Here, we resolve this trade-off by introducing Tensor Network Dynamical Message Passing (TNDMP), a framework grounded in a rigorous property we term Susceptible-Induced Factorization . This theoretical insight reveals that a susceptible node acts as a dynamical decoupler, factorizing the global evolution operator into localized components. Leveraging this, TNDMP provides a dual-mode algorithmic suite: an exact algorithm that computes local observables with minimal redundancy on tractable topologies and a scalable and tunable approximation for complex real-world networks. We demonstrate that widely adopted heuristics, such as Dynamical Message Passing (DMP) and Pair Approximation (PA), are mathematically recoverable as low-order limits of our framework. Numerical validation in synthetic and real-world networks confirms that TNDMP significantly outperforms existing methods to predict epidemic thresholds and steady states, offering a rigorous bridge between the efficiency of message passing and the accuracy of tensor network formalisms. Introduction Infectious diseases have long posed a pervasive threat to humanity, from the catastrophic devastation of the Black Death 41 ; 13 to the global disruption of the COVID-19 pandemic 3 . To analyze and forecast these outbreaks, mathematical modeling has served as a cornerstone of epidemiology since Bernoulli’s study in 1760 2 , later maturing through the seminal Kermack-McKendrick 22 and Reed-Frost 15 models. The compartmental models, exemplified by the classic susceptible-infected-recovered (SIR) model 32 , characterize epidemic processes by assuming that each individual in a population occupies one of several distinct states at any given time. These models have emerged as the prevailing paradigm due to their multifaceted analytical capacity, which enables the simulation of epidemic trajectories 12 ; 37 , the reconstruction of infection origins 23 ; 4 , the derivation of critical epidemic thresholds 29 ; 6 , and the optimization of intervention strategies 11 ; 24 . Furthermore, owing to the universal nature of spreading dynamics, these frameworks have transcended their biological origins. They now underpin a vibrant interdisciplinary field, proving pivotal in areas as diverse as information dissemination 10 ; 20 , social behavior 9 ; 17 , financial contagion 18 , and cascading failures in power grids 14 ; 5 . A principal methodology in epidemic modeling involves constructing and solving dynamical equations. Analytical techniques, such as mean-field (MF) approaches 38 ; 33 , typically assume homogeneous mixing or predefined contact patterns, and such approximations often fail in real-world settings where contact structure is crucial. This limitation has spurred the development of network epidemiology 28 ; 23 ; 21 ; 37 ; 30 , which models contacts explicitly as networks and shifts analysis from population densities to node-specific observables. However, exact equations in network epidemiology are hindered by long-range correlations, which generate intractable high-order terms. In practice, these terms are truncated via approximations that inevitably introduce error. Common methods include explicit techniques like Pair Approximation (PA) 28 or implicit ones like Dynamical Message Passing (DMP) 23 ; 21 ; 37 , which employs “messages” that are also efficient nearest-neighbor approximations 30 ; 42 . Both constitute approximations within nearest-neighbor that ignore network loops, relying instead on tree-like assumptions and incurring a distinct loop-induced error. Efforts to correct these errors remain limited 16 . Although Monte Carlo simulations provide a robust benchmark, their computational cost, requiring extensive sampling for convergence in large systems, poses a significant bottleneck. Tensor Network (TN) methods 31 ; 36 provide a powerful framework for encoding network structure and high-dimensional correlations, with proven success across various dynamical models 40 ; 7 ; 1 ; 8 ; 34 and simple epidemic system 25 . However, TN simulations face a computational bottleneck at the global scale in epidemic models on complex network. For instance, a recent implementation using Matrix Product States 26 for epidemic modeling incurred costs exceeding those of classical heuristics for comparable accuracy. This inefficiency persists despite TN’s compression capabilities, highlighting a fundamental mismatch: explicitly tracking the full system state imposes unnecessary overhead for tasks like computing local marginals. It suggests that high precision does not require retaining full system-wide information, motivating the development of methods that avoid global evolution in favor of localized inference. In this work, we introduce Tensor Network Dynamical Message Passing (TNDMP), a method founded on a tensor network representation for epidemic dynamics, designed to overcome the aforementioned limitations. TNDMP fully accounts for correlations and network loops while using only the computational effort necessary to compute local observables. The approach is built on a rigorous theoretical foundation we term Susceptible-Induced Factorization , which not only derives TNDMP but also unifies classical heuristics, such as Pair Approximation and standard DMP, as exact solutions on tree-like topologies. Furthermore, to address the scalability challenges posed by large, complex networks, we further introduce an approximation scheme controlled by a tunable parameter N , enabling TNDMP to handle short loops and short-range correlations rigorously via tensor network contraction, while treating long-range correlations through message passing. We evaluate TNDMP on the SIR model across a range of networks, calculating single-node marginal probabilities. Its performance is compared against Pair Approximation (PA), standard Dynamical Message Passing (DMP), and a ground-truth benchmark from Monte Carlo (MC) simulation. To validate the method, we first apply exact TNDMP to synthetic networks containing artificial cliques—structures known to challenge classical approximations. On these benchmarks, TNDMP reproduces the MC results exactly. We further test the N -parameterized approximation of TNDMP on both synthetic and real-world contact networks. Even with a minimal refinement ( N=3 ), TNDMP consistently outperforms PA and DMP, with accuracy improving as N increases. In real-world networks with widespread epidemic, we observe a burn-out phenomenon, where predictions from classical methods exhibit significant dynamical deviations that exceed typical static errors. TNDMP effectively mitigates this issue, reducing both the overestimation of infection prevalence and the temporal shift in the predicted outbreak peak compared to existing heuristics. More broadly, the underlying tensor network framework and the TNDMP formulation are highly extensible, supporting future applications such as modeling temporal evolution and enabling reverse-time inference for a wide class of non-recurrent dynamical systems beyond epidemiology. Results Epidemic Dynamics on Tensor Networks Figure 1: Schematic illustration of tensor network dynamical message passing. (a) The Susceptible-Infected-Recovered (SIR) model, featuring three states and two transition processes. The three states are encoded as three vectors. (b) The tensor X_{G}^{t} with n indices representing the probability of 3^{n} states in an n -node system. The state tensor evolves by contracting a tensor operator, which can be decomposed to local evolution of each node. (c) Susceptible-Induced Factorization: contracting projector S factorizes the global operator into sub operators with projector S itself and consequently contract onto initial state at last. With an independent initial state, the joint probability given a node susceptible can be split into independent parts. (d) Updating the tensor of a local area by contracting local operator with messages passed in, which only establishes on specific area based on the factorization property. (e) Illustration of exact and approximate partition, where the later is a repartition on each exact region. Obtained regions are circled by gray dashed lines, where the naive calculation is equivalent to assigning entire network as a region. The canonical SIR model 32 serves as the simplest non-trivial framework for describing epidemic dynamics. Within this compartmental model, as illustrated in Fig. 1 (a), the population is stratified into three distinct states: susceptible (S), infected (I), and recovered (R). The system evolves through two fundamental mechanisms: infection, in which a susceptible individual transitions to the infected state following exposure to an infected host; and recovery, characterized by the transition of an infected individual to the recovered state. These processes are formally represented as: \begin{split}SI&\xrightarrow{\lambda}II,\\ I&\xrightarrow{\rho}R,\end{split} (1) where \lambda and \rho denote constant rates of infection and recovery, respectively. Tensor network form of epidemic dynamics For an SIR model defined on a graph G=(V,E) with n=|V| nodes, each node i occupies one of the three discrete states X_{i}\in\{S,I,R\} , resulting in a total of 3^{n} possible system configurations \mathbf{X}=(X_{1},X_{2},\dots,X_{n}) . The distribution of joint probabilities P(\mathbf{X},t) of global configurations at time t is encoded as an n -index tensor: \mathcal{P}(t)=\sum_{\mathbf{X}}P(\mathbf{X},t)\ket{X_{1}}\ket{X_{2}}\dots\ket{X_{n}}, (2) where a vector \ket{X_{i}} is one of the basis vectors depicted in Fig. 1 (a). The temporal evolution of the state tensor is governed by the action of a transition operator: \displaystyle\mathcal{P}(t+\tau)=\mathcal{T}(\tau)\mathcal{P}(t), (3) where \mathcal{T}(\tau) acts as a 2n -index tensor operator, as illustrated in Fig. 1 (b). For brevity, we eliminate the explicit time-step dependence and denote the operator as \mathcal{T} . Consequently, the state of the system at time t is determined by the sequential application of the t/\tau operator layers to the initial state \mathcal{P}(0) : \mathcal{P}(t)=\mathcal{T}^{t/\tau}\mathcal{P}(0). (4) A central theoretical finding within this framework is the “Susceptible-Induced Factorization” inherent to the SIR model’s dynamics, which is derived from a node-wise factorization of \mathcal{T} . It factorizes the 2n -index tensor \mathcal{T} into a tensor network composed of single-node temporal operators and diagonal tensors as generalized Kronecker deltas. In the example shown in Fig. 1 (b), the purple squares and white circles denote single-node operators and diagonal tensors, respectively, with the network topology encoded in the connections between these tensors. Our analysis reveals that the susceptible projector, a vector of the susceptible state acting as a future state of a node i , denoted \bra{S_{i}} , possesses a unique algebraic property: \bra{S_{i}}\mathcal{T}=\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{T}_{\mathcal{C}}^{i}\bra{S_{i}}. (5) The contraction leaves \bra{S_{i}} invariant and factorizes the operator \mathcal{T} into a product of independent components \mathcal{T}_{\mathcal{C}}^{i} , each corresponding to a connected component \mathcal{C} of the cavity graph G\backslash i obtained by removing node i from G . This mechanism effectively breaks the inter-neighbor correlations established by \mathcal{T} ; as depicted in Fig. 1 (c), the contraction of \bra{S} with the dynamical operator visually “cuts” the network connections at that node. More broadly, this property propagates backward in time, implying that a susceptible projector serves as a “breakpoint” in the network’s correlational structure throughout the epidemic history. Given an uncorrelated initial state, the joint probability distribution tensor with node i susceptible \bra{S_{i}}\mathcal{P}(t) is factorized into several uncorrelated components, as shown in Fig. 1 (c). This factorization insight provides a theoretical foundation for developing efficient localized computational strategies. It reveals that in exact calculation of local observables, the dependence on the external environment inducing intractable global state evolution can be efficiently simplified and the factors corresponding to connected components \mathcal{C} reveal the scope of application. On tree graphs, it leads to a derivation of pair approximation function and dynamical message passing equations presented in the Supplementary Materials. Moreover, this critical insight directly underpins the development of our efficient algorithm for extracting local observables. Tensor network dynamical message passing As illustrated in Fig. 1 (d), the Susceptible-Induced Factorization facilitates the determination of local states. Specifically, a local state tensor \mathcal{P}_{\alpha}(t) is updated via the following contraction: \mathcal{P}_{\alpha}(t+\tau)=\mathcal{T}_{\alpha}(m_{\partial\alpha}(t))\mathcal{P}_{\alpha}(t), (6) where the effective operator \mathcal{T}_{\alpha} integrates “messages”, m_{\partial\alpha}(t)=\{\sum_{j\in(\partial i\cap\partial\alpha)}m_{j\to i}(t)|i\in\alpha\} , originating from the external environment. A message m_{j\to i}(t) is the conditional probabilities P(I_{j}|S_{i},t) that node j is infected given that node i is susceptible at time t . This local update scheme is applied to single nodes and designated spatial domains, where “regions” are defined as the atomic elements, while other eligible areas are their combination. These regions, derived through network partitioning, collectively constitute a complete cover of the network. Consequently, any local observables that depend directly on the state of an area \mathcal{P}_{A}(t) can be precisely evaluated using the region state \mathcal{P}_{\alpha}(t) where A\subseteq\alpha (or a combination thereof) through local updates, thus obviating the computational necessity of resolving the global state \mathcal{P}(t) at every timestep. In particular, these local updates are based on message exchanges across edges associated with adjacent regions. Therefore, the state of the region encompassing the edge (i,j) is necessary to evaluate m_{j\to i}(t) , which subsequently requires further messages and region states. Ultimately, this framework accounts for the states across all regions, but maintains superior computational efficiency compared to the direct simulation of the global state. Leveraging the concept of local updates, we developed the Tensor Network Dynamical Message Passing (TNDMP) algorithm to efficiently evaluate local observables. The TNDMP algorithm initially identifies the reducible structure of the system by partitioning the network into regions, as illustrated in Fig. 1 (e). Subsequently, the states of all regions and combinations required for multi-region-spanning observables are computed step by step via tensor contraction according to Eq. ( 6 ). In doing so, TNDMP simultaneously derives the messages m_{j\to i}(t)=P(I_{j}S_{i},t)/P(S_{i},t) required by operators \mathcal{T}_{\alpha}(m_{\partial\alpha}(t)) . Here, P(I_{j}S_{i},t) is obtained by contracting projectors on \mathcal{P}_{\alpha} during each iteration, while P(S_{i},t) and the single-node tensors \mathcal{P}_{i}(t) are calculated separately through local update contractions with \mathcal{T}_{i}(m_{\partial i}(t)) . Our method maintains mathematical rigor by introducing no approximations beyond those implicit in the network partitioning itself. Consequently, TNDMP yields a lower computational overhead compared to the direct and exact simulation of the global state. To further reduce computational complexity during contraction, we introduce an additional decomposition of the operator \mathcal{T}_{\alpha} , which is distinct from the node-wise decomposition shown in Fig. 1 (b). The implemented Trotter decomposition, illustrated in Fig. 1 (d), utilizes isolated single-node operators and pairwise operators, which are analogous to single bit gates and two bit gates, to model infection and recovery processes. Specifically, infections originating from external nodes are modeled by single-node gates conditioned on incoming messages, while internal infections are represented by pairwise operators. Moreover, because the state tensor of an n -node region scales as 3^{n} , this exponential growth renders exact calculations for large regions computationally prohibitive. To address this scalability challenge, we propose an approximation scheme that subdivides oversized exact regions into approximate subregions of manageable size. We define a parameter N to represent the maximum allowable size for these approximate regions. This approach can be conceptualized as a hierarchical sub-partitioning applied to each exact region (see Fig. 1 (e)). The approximation method is denoted by its parameter value, for instance, “ N4 ” in Fig. 1 (e) signifies a partition where N=4 . In the limit where N=2 , regions are restricted to individual edges, causing the TNDMP algorithm to effectively reduce to a pair approximation formulated within a tensor network framework. Algorithm The pseudocode for calculating the marginals \mathcal{P}_{i} by the TNDMP is summarized below: • Input : Network G=(V,E) , partition parameter N , initial information (patient zero or infected probabilities), epidemic parameters \lambda,\rho , time step \tau , end time T . 1. Network Partitioning : Divide network G into a set of regions \mathcal{R} by partitioning with the parameter N . 2. Initialization : Initialize messages \{m_{i\to j}(0),(i,j)\in E\} , state tensor of regions \{\mathcal{P}_{\alpha}(0),\alpha\in\mathcal{R}\} and nodes \{\mathcal{P}_{i}(0),i\in V\} by initial information. 3. Iterative Evolution : For each time step t=0,\tau,\dots,T-\tau : (a) Region Update : Update each state tensor \mathcal{P}_{\alpha}(t) by contracting Trotter operators that are factorized from operator \mathcal{T}_{\alpha}(m_{\partial\alpha}(t)) ; (b) Node Update : Update each \mathcal{P}_{i}(t) by contracting the operator \mathcal{T}_{i}(m_{\partial i}(t)) ; (c) Message Passing : Apply projectors to \mathcal{P}_{\alpha}(t+\tau) and \mathcal{P}_{i}(t+\tau) to extract the joint and marginal probabilities, P(I_{j}S_{i},t+\tau) and P(S_{i},t+\tau) , respectively. Calculate the new messages as: m_{i\to j}(t+\tau)=P(\mathrm{I}_{j}\mathrm{S}_{i},t+\tau)/P(\mathrm{S}_{i},t+\tau) , \forall(i,j)\in E. • Output : Marginals \{\mathcal{P}_{i}(t)|i\in V\} for t=0,\tau,2\tau,\dots,T . Figure 2: Performance evaluation on synthetic networks with feasible regions. (a) A network consisting of n=43 nodes with an ideal exact region partition. The structure contains one intermediate node and seven loops with sizes ranging from 3 to 9. The intermediate node is patient zero, representing the only infectious individual at t=0 . (b) Temporal evolution of the cumulative infection fraction f=\frac{1}{n}\sum^{n-1}_{i=0}P(C_{i}) , where P(C_{i})=P(I_{i})+P(R_{i}) . We compare the ground-truth marginals derived via Monte Carlo (MC) simulations with Pair Approximation (PA), Dynamical Message Passing (DMP), and our rigorous method ( N9 ). (c) The error in cumulative infection marginals, E=\frac{1}{n}\sum_{i=0}^{n-1}|P(C_{i})-P^{MC}(C_{i})| , obtained by our approximation for all non-trivial values of N\in[3,9] , as well as PA and DMP. (d) Final errors contributed by single loops, arranged according to their lengths. (e) A network of n=313 nodes generated from a random tree augmented with cliques of sizes 3 to 6; the respective counts for these cliques are [35, 10, 2, 1]. The experiment originates from a single patient zero (colored red). (f) The fraction of cumulative infection f on network in panel (e) over time. (g) Error in cumulative infection marginals through time for existing algorithms compared to our approximation with various N . (h) Probability density distribution of cumulative infection marginals at the steady state, comparing rigorous TNDMP ( N6 ) with other algorithms. Applications of TNDMP In our experiments, the SIR model is parameterized with an infection rate of \lambda=0.1 and a recovery rate of \rho=0.05 . The results obtained from 10^{6} Monte Carlo (MC) simulations serve as the ground truth. For the majority of our evaluations, we report the marginals of the cumulative infection C , defined as the sum of the probabilities of being in the infected ( I ) and recovered ( R ) states. Experiment on synthetic networks We initiate our evaluation using networks with tractable exact partitions, where the exact regions requiring local tensor network contractions remain computationally manageable. This setup enables TNDMP to achieve high accuracy by employing a sufficiently large, yet computationally feasible, parameter N . Initially, TNDMP is validated on a network topology containing multiple disjoint loops with lengths ranging from 3 to 9, as illustrated in Fig. 2 (a). As N increases, our approximation systematically incorporates these loops into the partitioning in ascending order of their lengths. By designating the central node as the only initially infected node (patient zero), the epidemic dynamics are restricted to individual loops. This configuration ensures that error propagation between disjoint loops is prevented. Consequently, the error variance across different N values directly reflects the specific error contributions of single loops relative to their lengths. Fig. 2 (b) displays the cumulative infection fraction f=\frac{1}{n}\sum^{n-1}_{i=0}P(C_{i}) , where P(C_{i})=P(I_{i})+P(R_{i}) represents the marginal cumulative infection probability for node i . We compare the ground truth from MC simulations with results from PA and DMP, alongside exact TNDMP approach ( N=9 in this network). Our method demonstrates high fidelity by closely tracking the MC results, whereas PA and DMP exhibit significant deviations. Fig. 2 (c) illustrates the L_{1} error for TNDMP across N ranging from 3 to 9, compared to PA and DMP. The results indicate that the TNDMP error decreases monotonically as N increases, where PA can be considered equivalent to TNDMP with N=2 as previously noted. The residual error at N=9 is minimal and primarily attributable to the Trotter decomposition. Furthermore, this experimental design allows us to quantify the error contributions inherent to single loops of varying lengths (neglecting the Trotter-induced bias). For clearer illustration, these loop-specific errors are presented at the steady state ( t=150 ) in Fig. 2 (d). The results reveal that the error contribution from a single loop is inversely correlated with its length. This observation supports the hypothesis that longer loops induce smaller errors, which serves as a fundamental motivation for our approximation method, even though the current experiment focuses on independent loops. Figure 3: Comparative analysis of epidemic dynamics and steady-state distributions in real-world networks. Experimental results for four real-world networks are presented in columns, respectively. (a) Structural sketches of the networks annotated with their average degrees \langle k\rangle . (b) Temporal evolution of the cumulative infection fraction f . (c) Temporal evolution of the L_{1} error E in cumulative infection marginals. (d) Temporal evolution of the the derivative df/dt . (e) Probability density function of the cumulative infection marginals at the steady state. (f) Scatter plot of the steady-state marginal probabilities C_{i} for 50 randomly selected nodes. The y -axis represents the MC ground truth, while the x -axis represents results obtained via TNDMP ( N=9 ) and PA. The green dashed line indicates the ideal y=x agreement with the ground truth. To evaluate the performance of our approximation, we constructed a globally tree-like network incorporating cliques. This was achieved by first generating a random tree and subsequently replacing each node of degree d\geq 3 with a d -node clique, where the original edges were remapped to the new clique vertices. While this construction poses a significant challenge for classical methods predicated on tree-like assumptions, its exact partition is unambiguous: each clique is defined as a single region, while the remaining edges in the tree are treated as individual regions. Consequently, the maximum cardinality of the cliques directly determines the value of the threshold parameter N at which our methodology achieves exact results. In our evaluation, we generated a 200-node random tree and replaced 48 nodes with cliques, the largest of which had a size of 6. This setup ensures that TNDMP achieves exact calculation at N=6 . A schematic of this network, with patient zero colored red, is illustrated in Fig. 2 (e). Panels (f) and (g) of Fig. 2 present the cumulative infection fraction f and its L_{1} error on this network, comparing our approximation for N\in\{3,4,5,6\} against PA and DMP. For N<6 , portions of the cliques are pruned to satisfy the N constraint. The results exhibit a monotonic decrease in TNDMP error as N increases, with the rigorous N=6 algorithm yielding a Trotter error below 10^{-3} . Notably, all our approximations, even at N=3 , yield significantly lower errors than PA and DMP. Furthermore, Fig. 2 (h) illustrates the probability density function of the cumulative infection at the final time step. The steady states reveal a substantial disparity between the ground truth obtained from Monte Carlo (MC) simulations and the endemic states predicted by tree-based methods. In contrast, the results from our method closely align with the MC simulations. Applications on real-world networks We further evaluated the approximate TNDMP method on four real-world networks for which a rigorous TNDMP approach is computationally prohibitive: an electric power grid ( n=494 ), a collaboration network of Sandia National Labs scientists ( n=86 ), a co-authorship network ( n=379 ), and the network of contiguous USA states ( n=49 ) 35 . Structural sketches of these networks are presented in Fig. 3 (a). The results presented in Fig. 3 consistently demonstrate that our TNDMP method outperforms PA and DMP. Rows (b) and (c) in Fig. 3 depict the temporal evolution of the cumulative infection fraction and the corresponding L_{1} error E for PA, DMP, and our approximations with N\in\{3,6,9\} . An inverse relationship between the error and the parameter N is observed throughout the evolution. A distinctive feature in the error profiles of the latter two networks is the occurrence of pronounced peaks followed by a transient reduction, despite the absence of substantial divergence in the cumulative infection fraction. To investigate this phenomenon, Fig. 3 (d) presents the derivative of the cumulative infection fraction df/dt . As observed in the panels for the latter two networks, the derivative decreases rapidly following its peak, eventually falling below the levels recorded in Monte Carlo simulations. In contrast, for the first two networks, the derivatives predicted by the approximate methods remain consistently higher than the MC results. In conjunction with the high cumulative infection fraction f , we attribute the subsequent reduction of errors to the following mechanism: in the latter two networks, the overestimation of the derivative by approximate methods is so pronounced that it leads to a rapid depletion of the susceptible population, triggering a premature burn-out of the epidemic. Thus, instead of sustaining a more enduring propagation, characterized by the broader df/dt peaks seen in the first two networks, the majority of individuals are infected within a very short duration in the last two networks. Consequently, this burn-out effect causes df/dt=\cfrac{\lambda}{n}\sum_{(i,j)\in E}P(S_{i}I_{j}) in the approximate simulations to weaken rapidly because few individuals remain susceptible, while the derivative in the ground-truth system, df_{MC}/dt , decreases more gradually. Since errors primarily stem from overestimated infection, such that df/dt-df_{MC}/dt\approx dE/dt , the crossover point where df/dt falls below df_{MC}/dt corresponds to the observed error peak followed by a transient decrease. Fig. 3 (e) and (f) focus on the steady-state results for TNDMP with N=9 . The fifth column displays the probability density function of the final cumulative infection, while the last column compares the steady-state marginal probabilities of 50 randomly selected nodes between TNDMP ( N=9 ) and PA. These density and marginal plots further corroborate our explanation of the error dynamics: the approximate simulations for the latter two networks converge to a state of total burn-out , where most individuals reach a cumulative infection marginal near 1.0, whereas the true infected fraction is significantly smaller. Although TNDMP also exhibits a tendency to overestimate infection, it consistently provides results superior to PA and DMP. The density plots reveal that our method yields a distribution closer to the ground truth, and the scatter plots confirm that the TNDMP results generally align more closely with the true values. Across the four real-world networks analyzed, our method demonstrates its most significant performance gains on the second network. This observation aligns with our theoretical expectations, as TNDMP is specifically designed to yield superior results on topologies that are predominantly sparse and tree-like. In contrast, the advantage over PA and DMP is less pronounced in the final lattice-like network, which presents a significant challenge for all methods due to its high clustering. In the third network, we observe two distinct peaks in the df/dt profile. This phenomenon mirrors the stepped behavior previously noted in Fig. 2 (f), which corresponds to the impact of numerous short loops that are neglected when sub-partitioning densely connected cliques. These peaks highlight the substantial influence of clustered short loops on epidemic dynamics and underscore the potential for further performance gains if clique structures are managed more precisely within our framework. Computational Efficiency and Scalability To demonstrate the necessity of the proposed N -based approximation and evaluate its computational cost, we analyze the 494-bus network. This topology presents a significant challenge for exact inference owing to its loop-rich structure. Specifically, the largest region requiring rigorous treatment comprises 212 nodes. In the context of the SIR model, computing the exact marginals for this region would require summing over a state space of dimension 3^{212}\approx 1.7\times 10^{101} , rendering the exact solution computationally intractable. However, the N=9 approximation partitions the system into 33 multi-edge regions within a negligible duration (less than 1 second) and reduces the state space from 3^{212} to less than 33\times 3^{9} region-states plus the minor state spaces of remaining individual edges. Consequently, efficient approximation schemes are essential. Table 1 compares the CPU running time of the proposed TNDMP method against the Monte Carlo (MC) baseline and tree-like approximations (PA and DMP). While MC simulations ( 10^{6} realizations) provide a statistical baseline, they incur a computational cost three orders of magnitude higher than deterministic methods. Table 1: Comparison of CPU Running Time on the 494-Bus Network. The exact solution is infeasible ( 3^{212} states). TNDMP ( N=9 ) achieves a runtime comparable to fast heuristics (PA, DMP) while avoiding the heavy computational burden of Monte Carlo (MC) simulations. The reported time for TNDMP ( N=9 ) refers to the dynamic simulation duration. The preprocessing time for network partitioning is less than 1 second and is not included in the simulation runtime. Method Time (sec.) Relative Cost PA 13.06 1.0\times DMP 13.10 \approx 1.0\times TNDMP ( N=9 ) 212.18 \mathbf{\approx 16.3\times} MC 137073.54 >10,000\times Exact – Intractable ( 3^{212} ) Significantly, TNDMP ( N=9 ) achieves a critical balance between rigor and efficiency. Despite incorporating higher-order correlations to address the inaccuracies, its computational cost exceeds that of the ultra-fast DMP and PA heuristics by a factor of only approximately 16. This result indicates that TNDMP successfully bridges the gap between accuracy and efficiency, offering near-exact precision at a cost comparable to classical heuristics. Discussion We introduce a tensor network (TN) framework for characterizing the dynamics of epidemic models on networks. This formalism provides a robust mathematical toolkit for analytical derivation and naturally unifies classical Dynamical Message Passing (DMP) and Pair Approximation (PA) as exact methods for tree topologies. The framework encompasses Tensor Network Dynamical Message Passing (TNDMP) with both an exact methodology and efficient approximation techniques. Our approach facilitates the determination of local observables with significantly enhanced accuracy at controllable computational costs. The primary source of error in our algorithm stems from approximating loop structures to reduce computational complexity. This approximation is necessitated by the exponential growth of state tensors. While representing the global state remains challenging, tensor network methods such as Matrix Product States (MPS) 31 , Projected Entangled Pair States (PEPS) 39 , and Tree Tensor Networks (TTN) 27 hold promise for the efficient representation of local region-state tensors. Instead of sub-partitioning oversized regions, representing large region tensors via TN ansatzes offers a pathway to higher accuracy, and a hybrid approach combining both techniques is also feasible. We currently employ a greedy heuristic for the N -based approximation. Consequently, the resulting partition is not guaranteed to be optimal and may not minimize the approximation error. This limitation can be addressed by formulating the partitioning as a formal optimization problem and employing advanced combinatorial optimization algorithms. Additionally, in the Supplementary Materials, we introduce an alternative heuristic scheme, which serves as a supplement to the primary N -based approximation. Although the current implementation focuses on algorithmic accuracy on CPUs, the TNDMP framework naturally lends itself to parallel computing and hardware acceleration. The local update operations (Eq. 6 ) for disjoint regions are independent and can be executed simultaneously. Furthermore, tensor contraction, which governs the computational cost, can be significantly accelerated using modern Graphics Processing Units (GPUs) or Tensor Processing Units (TPUs). Future implementations leveraging these hardware capabilities could reduce runtime, enabling the rigorous analysis of significantly larger social and technological networks. Finally, the present approach exhibits high extensibility to variants of the SIR model, such as the SEIR model 19 and rumor spreading 20 . However, significant challenges remain for recurrent models, such as Susceptible-Infected-Susceptible (SIS) dynamics. In the absence of the Susceptible-Induced Factorization property, TNDMP reduces to a probabilistic approximation that lacks the rigorous physical decoupling inherent to the SIR framework. However, the tensor network formalism introduced in this paper provides a promising analytical foundation for characterizing complex dynamics and a powerful tool for representing correlations. Methods Node-wise factorization over the temporal operator We use a node-wise factorization to factorize \mathcal{T} . It originates from a factorization of T(\mathbf{X}^{t+\tau}|\mathbf{X}^{t}) , the probability of the transition from a configuration \mathbf{X}^{t} to another \mathbf{X}^{t+\tau} over a time step \tau . By the locality of interactions in the epidemic models, this global probability is factorized over the neighborhoods of individual nodes: T(\mathbf{X}^{t+\tau}|\mathbf{X}^{t})=\prod_{i\in V}T\left(X_{i}^{t+\tau}|X_{i}^{t},X_{\partial i}^{t}\right), (7) where \partial i denotes the set of immediate neighbors of node i . We reformulate this factorization within a tensor network formalism. The global operator \mathcal{T} decomposes into a contraction of local tensors: \mathcal{T}=\prod_{i\in V}\mathcal{T}_{i,\partial i}\Delta_{i}, (8) Here, the single-node transition tensor \mathcal{T}_{i,\partial i} encodes the local conditional probability W(X_{i}^{t+\tau}|X_{i}^{t},X_{\partial i}^{t}) , acting on the state indices of node i and its neighbors. The tensor \Delta_{i} , a generalized Kronecker delta, ensures the physical consistency of the state X_{i}^{t} on the indices associated with the previous state of i . We show this factorization on a 1-dimensional chain in Fig. 4 (a) Figure 4: The pictorial illustration of Susceptible-Induced Factorization on a 1-dimensional chain. Sketch of the tensor contraction of a susceptible projector \bra{S} and a state tensor \mathcal{P}(t) . (a) The contraction breaks factorized \mathcal{T} into \mathcal{T}_{\mathcal{C}}^{i} . (b) Pictorial function of contracting \bra{S} onto factorized \mathcal{T} . Susceptible-Induced Factorization The computational tractability of our framework rests on a rigorous algebraic property of the SIR dynamics, the “Susceptible-Induced Factorization”. Physically, if a node i is known to be in the susceptible state at time t , its history effectively decouples the dynamical correlations between its neighbors. Mathematically, this is realized by contracting the “susceptible projector” \bra{S_{i}} onto the future index of the global evolution operator \mathcal{T} . This contraction propagates through the network structure, factorizing \mathcal{T} into disconnected components. Specifically, contracting \bra{S_{i}} with the local transition tensor \mathcal{T}_{i,\partial i} yields: \bra{S_{i}}\mathcal{T}_{i,\partial i}=\prod_{j\in\partial i}\bra{U_{j}}\bra{S_{i}}, (9) where we have employed the first-order approximation in \tau , which can be sufficiently small in the derivation. The vector \bra{U}=\bra{S}+(1-\lambda\tau)\bra{I}+\bra{R} represents the constraint imposed on the neighbor j by the fact that node i remained susceptible. Crucially, the diagonal tensor \Delta_{i} copies the projector as a product of \bra{S_{i}} to other indices. Consequently, the contraction \bra{S_{i}}\mathcal{T} shown in Fig. 4 efficiently removes node i from the tensor network of factorized \mathcal{T} , breaking the global operator into a tensor product of operators acting on the disconnected components of the cavity graph G\backslash i : \bra{S_{i}}\mathcal{T}=\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{T}_{\mathcal{C}}^{i}\bra{S_{i}}. (10) Here, \mathbf{C}(G\backslash i) denotes the set of connected components in the graph when node i is removed. This factorization implies that for an uncorrelated initial state \mathcal{P}(0) , the marginal probability of observing node i as susceptible at time T , along with the system’s conditional state, factorizes completely: \bra{S_{i}}\mathcal{P}(t)=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{P}_{\mathcal{C}}^{i}(t). (11) With the tree-assumption, this “Susceptible-Induced Factorization” can immediately derive the key equation of Dynamical Message Passing by summarizing indices of \bra{S_{i}}\mathcal{P}(t) to obtain susceptible marginals: P(S_{i},t)=P(S_{i},0)\prod_{j\in\partial i}H_{j}^{i}(t), (12) where the scalar H_{j}^{i}(t)=\sum_{\mathbf{X}_{\mathcal{C}_{j}}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) is the summation over all configurations of the subnetwork \mathcal{C}_{j} is the DMP message for the SIR model. The labels of neighbors take the place of connected components, since in a tree network each neighbor j corresponds to a unique connected component \mathcal{C}_{j} of the cavity graph G\backslash i . Refer to Supplementary Materials for the derivation of the dynamical equation of H_{j}^{i}(t) . Meanwhile, by keeping the state of two neighbors j and k of node i fixed in \bra{S_{i}}\mathcal{P}(t) , we obtain the pair approximation function: P(X_{j}S_{i}X_{k},t)=\cfrac{P(X_{j}S_{i},t)P(S_{i}X_{k},t)}{P(S_{i},t)}, (13) where the intermediate node is constrained to be susceptible. Most importantly, it allows us to replace the intractable cascading expansion with local message passing updates rigorously, as detailed in the Supplementary Materials. Specifically, as we have mentioned, for a region \alpha where the boundary nodes satisfy specific connectivity constraints (see Eq. 6 ), the influence of the external network is fully captured by scalar messages m_{\partial\alpha}(t) , allowing the exact local update \mathcal{P}_{\alpha}(t+\tau)=\mathcal{T}_{\alpha}(m_{\partial\alpha}(t))\mathcal{P}_{\alpha}(t) . Algorithm: Scalable N -Partitioning To reconcile the competing demands of accuracy and computational tractability, we introduce a hierarchical partitioning scheme governed by a tunable parameter N , representing the maximum allowable region size. This framework leverages the insight that while short-range loops necessitate exact tensor contraction, long-range dependencies can be effectively approximated via dynamical message passing. It is grounded in the decay of correlations with increasing loop length, a premise empirically validated by our experiments on synthetic topologies (Fig. 2 (a-d)). The algorithm proceeds recursively, initially decomposing the network into its fundamental biconnected components. For any component exceeding the size threshold N , we apply a topological “peeling” protocol that iteratively excises edges associated with the longest cycles until the component’s core size satisfies the threshold condition. Crucially, the set of excised edges is not merely treated as residual. Any non-trivial biconnected subgraphs formed by these edges are recursively subjected to the same peeling protocol. Ultimately, the resulting dense cores are retained as tensor network regions for exact evolution, while the remaining edges serve as message-passing channels. This hybrid architecture ensures that the most significant correlations (short loops) are treated rigorously, while constraining the computational complexity of any region to \mathcal{O}(3^{N}) . Time Evolution via Trotter Decomposition The direct contraction of the region operator \mathcal{T}_{\alpha} becomes computationally intensive as the region size grows. To optimize the local update step, we employ a first-order Trotter-Suzuki decomposition, decoupling the evolution into a sequence of sparse, local gate operations: \mathcal{T}_{\alpha}(m_{\partial\alpha}(t))\approx\prod_{i\in\alpha}\mathbf{R}_{i}\prod_{(i,j)\in E_{\alpha}}\mathbf{I}_{ij}\prod_{i\in\alpha}\mathbf{I}_{i}(m_{\partial\alpha\to i}(t)). (14) Here, E_{\alpha} denotes the set of edges strictly contained within region \alpha . The term m_{\partial\alpha\to i}=\sum_{j\in(\partial i\cap\partial\alpha)}m_{j\to i} represents the aggregate infection pressure exerted on node i by its neighbors in the external boundary \partial\alpha . The operators in Eq. ( 14 ) correspond to specific physical processes: \mathbf{R}_{i} acts as a single-site recovery gate; \mathbf{I}_{ij} represents the pairwise infection gate for internal edges; and \mathbf{I}_{i}(m_{\partial\alpha\to i}(t)) is a single-site gate conditioned on the external messages, effectively modeling the ”field” produced by the environment. This decomposition reduces the update cost to a series of low-cost tensor contractions, enabling efficient simulation even for regions with dense internal connectivity. Acknowledgements. A Python implementation of our algorithm and a Jupyter Notebook for reproducing the data of the figures are available at 43 . We are grateful to Yijia Wang and Jing Liu for helpful discussions. We thank Dong-Yang Feng for his assistance with figure preparation. The work is supported by Projects 12325501 and 12447101 of the National Natural Science Foundation of China. SUPPLEMENTARY MATERIALS OF “Tensor network dynamical message passing for epidemic models” I Pair approximation and Dynamical message passing The standard dynamical equations of marginals of the SIR model on networks are: \displaystyle\cfrac{dP(S_{i})}{dt} \displaystyle=-\lambda\sum_{j\in\partial i}P(S_{i}I_{j}), (S1) \displaystyle\cfrac{dP(I_{i})}{dt} \displaystyle=\lambda\sum_{j\in\partial i}P(S_{i}I_{j})-\rho P(I_{i}), (S2) \displaystyle\cfrac{dP(R_{i})}{dt} \displaystyle=\rho P(I_{i}), (S3) \displaystyle\cfrac{dP(S_{i}I_{j})}{dt} \displaystyle=-(\rho+\lambda)P(S_{i}I_{j})+\lambda\sum_{k\in\partial_{j}\backslash i}P(S_{i}S_{j}I_{k})-\lambda\sum_{k\in\partial_{i}\backslash j}P(S_{i}I_{j}I_{k}), (S4) where the hinder of correlation appears as the triple terms which also require dynamical equations to evolve and expand to fourth-order terms. The function of pair approximation as the second moment closure method is: P(X_{i}X_{j}X_{k})=\cfrac{P(X_{i}X_{j})*P(X_{j}X_{k})}{P(X_{j})}, (S5) where i,k are neighbors of j . Applying on the last equation, we have: \cfrac{dP(S_{i}I_{j})}{dt}=-(\rho+\lambda)P(S_{i}I_{j})+\lambda P(S_{i}S_{j})\sum_{k\in\partial_{j}\backslash i}\cfrac{P(S_{j}I_{k})}{P(S_{j})}-\lambda P(S_{i}I_{j})\sum_{k\in\partial_{i}\backslash j}\cfrac{P(S_{i}I_{k})}{P(S_{i})}. (S6) Induces further P(S_{i}I_{j}) , whose dynamical equation with pair approximation is: \cfrac{dP(S_{i}S_{j})}{dt}=-\lambda P(S_{i}S_{j})\sum_{k\in\partial_{j}\backslash i}\cfrac{P(S_{j}I_{k})}{P(S_{j})}-\lambda P(S_{i}S_{j})\sum_{k\in\partial_{i}\backslash j}\cfrac{P(S_{i}I_{k})}{P(S_{i})}. (S7) From the function, we can see that the pair approximation function only applies on terms with susceptible intermediate nodes. Thus, the actual function of PA applied in the SIR models is P(X_{i}S_{j}X_{k})=\cfrac{P(X_{i}S_{j})*P(S_{j}X_{k})}{P(S_{j})}. (S8) The key of the Dynamical Message Passing (DMP) algorithm is the alternative equation of susceptible marginals: P(S_{i},t)=z*\prod_{j\in\partial i}H_{j\to i}(t), (S9) where the message H_{j\to i}(t)=1-\int_{0}(t)\lambda e^{-(\rho+\lambda)\tau}\left[1-z\prod_{k\in\partial j\backslash i}H_{k\to j}(t-\tau)\right]d\tau is defined in an integration form. And the dynamical equation of H_{j\to i}(t) is: \displaystyle\cfrac{dH_{j\to i}(t)}{dt}=\rho-(\lambda+\rho)H_{j\to i}(t)+\lambda z\prod_{k\in\partial j\backslash i}H_{k\to j}(t). (S10) The function of PA and DMP will be re-iterated in the following derivation. II Derivation of Susceptible-Induced Factorization In the derivation, we assume that the time step \tau is sufficiently small that higher-order terms like \tau^{2} are omitted. In tensors, the dimensions of indices are labeled by \{0,1,2\} representing states S, I, and R respectively. In this section, we detail the derivation of Susceptible-Induced Factorization with factorized operator \mathcal{T}=\prod_{i\in V}\mathcal{T}_{i,\partial i}\Delta_{i} , where a tensor \mathcal{T}_{i,\partial i} encodes single-node transition T(X_{i}^{t+\tau}|X_{i}^{t},X_{\partial i}^{t}) and copy tensors \Delta_{i} as generalized Kronecker deltas that copy the contracted basis vector to all other indices. The contraction of \bra{S_{i}} and \mathcal{T}_{i,\partial i} is as follows: \displaystyle\bra{S_{i}}\mathcal{T}_{i,\partial i} \displaystyle=\mathcal{T}_{\partial i}^{S}\bra{S_{i}} (S11) \displaystyle=\left(\prod_{j\in\partial i}\bra{U_{j}}\right)\bra{S_{i}} The first row is straightforward since T(S_{i}^{t+\tau}|X_{i}^{t},X_{\partial i}^{t}) is non-zero only if X_{i}^{t}=S by the dynamic of the SIR model. And the second row \mathcal{T}_{\partial i}^{S}=\prod_{j\in\partial i}\bra{U_{j}} uses an approximation 1-n\lambda\tau\approx(1-\lambda\tau)^{n} that transforms elements of \mathcal{T}_{\partial i}^{S} into production form and \mathcal{T}_{\partial i}^{S} becomes a tensor product of \bra{U}=\bra{S}+(1-\lambda\tau)\bra{I}+\bra{R} By definition, \Delta_{i} contracting \bra{S_{i}} copies this basis vector to other indices. And \mathcal{T}_{j,\partial j},j\in\partial i gets a neighbor i susceptible, the contraction reflects the probability of transition T(X_{j}^{t+\tau}|X_{j}^{t},X_{\partial j\backslash i}^{t},S_{i}^{t}) . S_{i}^{t} has no influence on X_{j}^{t+\tau} such that the probability and the corresponding tensors are simplified to T(X_{j}^{t+\tau}|X_{j}^{t},X_{\partial j\backslash i}^{t}) and \mathcal{T}_{j,\partial j\backslash i} , respectively. As the structure of \mathcal{T} corresponds to network G , the factorized \mathcal{T} after contracting \bra{S_{i}} also corresponds to the cavity network G\backslash i where node i and edges connected to i are removed. Hence, the remaining part of “susceptible factorized” \mathcal{T} potentially becomes a production of independent parts, which is consistent with connected components of G\backslash i , since the connection through indices and edges are broken. Hence, we collect tensors in each independent part and label them by corresponding connected components: \mathcal{T}_{\mathcal{C}}^{i}=\left(\prod_{k\in(\partial i\cap\mathcal{C})}\bra{U_{k}}\right)\left(\prod_{j\in\mathcal{C}}\mathcal{T}_{j,\partial j\backslash i}\Delta_{j}\right). (S12) Hence, we obtain the compact function \bra{S_{i}}\mathcal{T}=\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{T}_{\mathcal{C}}^{i}\bra{S_{i}} Apply the factorization property on the contraction of \bra{S_{i}} and a state \mathcal{P}(t)=\mathcal{T}^{t/\tau}\mathcal{P}(0) we have: \bra{S_{i}}\mathcal{P}(t)=\left(\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{T}_{\mathcal{C}}^{i}\right)^{t/\tau}\bra{S_{i}}\mathcal{P}(0). (S13) Given an uncorrelated initial state \mathcal{P}(0)=\prod_{i\in V}\mathcal{P}_{i}(0) , in which tensor \mathcal{P}_{i}(0)=P(S_{i},0)\ket{S}+P(I_{i},0)\ket{I}+P(R_{i},0)\ket{R} encodes an independent initial state of node i . Then the contraction is as follows: \displaystyle\bra{S_{i}}\mathcal{P}(t) \displaystyle=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{P}_{\mathcal{C}}^{i}(t), (S14) \displaystyle\mathcal{P}_{\mathcal{C}}^{i}(t) \displaystyle=\left(\mathcal{T}^{i}_{\mathcal{C}}\right)^{t/\tau}\prod_{j\in\mathcal{C}}\mathcal{P}_{j}(0). The tensor \mathcal{P}_{\mathcal{C}}^{i}(t) can be roughly viewed as the state of the component \mathcal{C} evolved under the modified operator \mathcal{T}^{i}_{\mathcal{C}} that is not normalized. In next two sections, we will derive DMP, PA and local update equation for our method by this function. III Derivation of dynamical message passing As shown in the main text, the key function of DMP is obtained from calculating susceptible marginal P(S_{i},t) by summarizing all other indices of \bra{S_{i}}\mathcal{P}(t) , which we represent by contracting the summary vectors \bra{\Sigma}=\bra{S}+\bra{I}+\bra{R} : \begin{split}P(S_{i},t)&=\left(\prod_{j\in G\backslash i}\bra{\Sigma_{j}}\right)\bra{S_{i}}\mathcal{P}(t)\\ &=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\left(\prod_{j\in\mathcal{C}}\bra{\Sigma_{j}}\right)\mathcal{P}_{\mathcal{C}}^{i}(t)\\ &=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}H_{\mathcal{C}}^{i}(t),\end{split} (S15) where we denote the scalars by H for consistency with classical DMP and to distinguish them from probabilities. To rigorously transform production from connected components to single neighbors, connected components must consist of only one neighbor of i , which requires that there is no loop consisting of node i . Apply the condition to all nodes in the network, requiring a tree structure without loop. Such that we have the tree-specific function: P(S_{i},t)=P(S_{i},0)\prod_{j\in\partial i}H_{j}^{i}(t). (S16) The label of connected components \mathcal{C} replaced by consisting neighbors j . We have the initial condition of scalars H_{j}^{i}(t) that H_{j}^{i}(0)=\prod_{j\in\mathcal{C}}\bra{\Sigma_{j}}\mathcal{P}_{j}(0)=1 by the normalized probability. Calculating H_{j}^{i}(t) by contracting a sub tensor network in every time step is unfeasible. Hence, dynamical equations are introduced to update H_{j}^{i}(t) like existing DMP methods. The difference of H_{j}^{i}(t) through a time step is: \displaystyle H_{j}^{i}(t+\tau)-H_{j}^{i}(t)= \displaystyle\left(\prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\mathcal{T}^{i}_{\mathcal{C}_{j}}-\prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\right)\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) (S17) \displaystyle= \displaystyle\left(\bra{U_{j}}\prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\mathcal{T}_{k,\partial k\backslash i}\Delta_{k}-\prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\right)\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) \displaystyle= \displaystyle\left(\bra{U_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}-\prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\right)\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) \displaystyle= \displaystyle-\lambda\tau\bra{I_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) The third row is achieved with \prod_{k\in\mathcal{C}_{j}}\bra{\Sigma_{k}}\mathcal{T}_{k,\partial k\backslash i}\Delta_{k}=\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}} , which can be simply derived from the Markovian property of \mathcal{T}_{k,\partial k\backslash i} that \sum_{X_{k}^{t+\tau}}P(X_{k}^{t+\tau}|X_{k}^{t},X_{\partial k}^{t})=1 . Hence, we have the derivative of H_{j}^{i}(t) with \tau\to 0 : \displaystyle\cfrac{dH_{j}^{i}(t)}{dt} \displaystyle=\lim_{\tau\to 0}\cfrac{H_{j}^{i}(t+\tau)-H_{j}^{i}(t)}{\tau} (S18) \displaystyle=-\lambda\bra{I_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(t). Then we further transform the contraction into a close equation with H_{j}^{i}(t) itself. First, we use a trick that \bra{I}=\bra{\Sigma}-\bra{S}-\bra{R} , then we have: \cfrac{dH_{j}^{i}(t)}{dt}=-\lambda\left(\bra{\Sigma_{j}}-\bra{S_{j}}-\bra{R_{j}}\right)\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(t). (S19) Thus, there are three terms in the function: The first term of \bra{\Sigma_{j}} is H_{j}^{i}(t) itself with a factor -\lambda . Recall Eq. S11 , the vector \bra{S_{j}} can also factor \mathcal{T}_{j,\partial j\backslash i} and \Delta_{j} in \mathcal{T}_{\mathcal{C}_{j}}^{i} of \mathcal{P}_{j}^{i}(t) . The transformation of one layer of the operator \mathcal{T}_{\mathcal{C}_{j}}^{i} is: \displaystyle\bra{S_{j}}\mathcal{T}_{\mathcal{C}_{j}}^{i} \displaystyle=\bra{S_{j}}\bra{U_{j}}\prod_{k\in\mathcal{C}_{j}}\mathcal{T}_{k,\partial k\backslash i}\Delta_{k} (S20) \displaystyle=\braket{U_{j}|S_{j}}\prod_{\mathcal{C}\in\mathbf{C}(\mathcal{C}_{j}\backslash j)}\prod_{k\in\mathcal{C}}\mathcal{T}_{k,\partial k\backslash i}\Delta_{k}\bra{S_{j}} \displaystyle=\prod_{k\in\partial j\backslash i}\mathcal{T}_{\mathcal{C}_{k}}^{j}\bra{S_{j}}. The last row is again relied on the tree structure to divide tensors by neighbors. The term with \bra{S_{j}} is simplified as follows: \displaystyle\lambda\bra{S_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{j}^{i}(t) \displaystyle=\lambda P(S_{j},0)\prod_{k\in\partial j\backslash i}\prod_{l\in\mathcal{C}_{k}}\bra{\Sigma_{l}}\mathcal{P}_{\mathcal{C}_{k}}^{j}(t) (S21) \displaystyle=\lambda P(S_{j},0)\prod_{k\in\partial j\backslash i}P_{k}^{j}(t) For the last term, we start by contracting on one layer of operator: \displaystyle\bra{R_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{T}_{\mathcal{C}_{j}}^{i}= \displaystyle\bra{R_{j}}\mathcal{T}_{j,\partial j\backslash i}\bra{U_{j}}\Delta_{j}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{T}_{k,\partial k\backslash i}\Delta_{k} (S22) \displaystyle= \displaystyle\left(\bra{R_{j}}+\rho\tau\bra{I_{j}}\right)\bra{U_{j}}\Delta_{j}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}} \displaystyle= \displaystyle\left(\bra{R_{j}}+\rho\tau\bra{I_{j}}\right)\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}} Here we employ the first order approximation of \tau on \left(\bra{R_{j}}+\rho\tau\bra{I_{j}}\right)\bra{U_{j}}\Delta_{j} , which equals \bra{R_{j}}+\rho\tau(1-\lambda\tau)\bra{I_{j}} and we omit the second order term. The first term in above equation is \bra{R_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}} itself, and the second term with \bra{I_{j}} corresponds to the derivative of H_{j}^{i}(t) . Apply this result, we have: \displaystyle\lambda\bra{R_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(t) \displaystyle=\lambda\bra{R_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(0)+\lambda\sum_{T=0}^{t-\tau}\rho\tau\bra{I_{j}}\prod_{k\in\mathcal{C}_{j}\backslash j}\bra{\Sigma_{k}}\mathcal{P}_{\mathcal{C}_{j}}^{i}(T) (S23) \displaystyle=\lambda R_{j}(0)-\sum_{T=0}^{t-\tau}\rho\tau\cfrac{dH_{j\to i}(T)}{dt} \displaystyle=\lambda R_{j}(0)+\rho\left[1-H_{j\to i}(t)\right] Substitute Eq. ( S21 ) and ( S23 ) to Eq. ( S19 ), \displaystyle\cfrac{dH_{j}^{i}(t)}{dt} \displaystyle=-\lambda H_{j}^{i}(t)+\lambda P(S_{j},0)\prod_{k\in\partial j\backslash i}H_{k}^{j}(t)+\lambda R_{j}(0)+\rho\left[1-H_{j}^{i}(t)\right] (S24) \displaystyle=\rho-(\lambda+\rho)H_{j\to i}^{T}+\lambda P(S_{j},0)\prod_{k\in\partial j\backslash i}H_{k}^{j}(t)+\lambda R_{j}(0). It is the close dynamical equation of H_{j\to i}^{T} , with the condition of a tree graph and uncorrelated initial states. We note that we found an extra term \lambda R_{j}(0) that does not appear in the previous work, as the initial recovery probability is commonly not considered. IV Derivation of tensor network dynamical message passing Another application of Eq. S14 is the joint probabilities such as P(\mathbf{X}_{A}S_{i},t) , where \mathbf{X}_{A}=\{X_{j}|j\in A\} . It is obtained by contracting a production of projectors and sum vectors \left(\prod_{j\in A}\bra{X_{j}}\right)\left(\prod_{k\in G\backslash A,i}\bra{\Sigma_{k}}\right) on \bra{S_{i}}\mathcal{P}(t) : \displaystyle P(\mathbf{X}_{A}S_{i},t) \displaystyle=P(S_{i},0)\left(\prod_{j\in A}\bra{X_{j}}\right)\left(\prod_{k\in G\backslash A,i}\bra{\Sigma_{k}}\right)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\mathcal{P}_{\mathcal{C}}^{i}(t) (S25) \displaystyle=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}\left(\prod_{j\in\mathcal{C}\cap A}\bra{X_{j}}\right)\left(\prod_{k\in\mathcal{C}\backslash A}\bra{\Sigma_{k}}\right)\mathcal{P}_{\mathcal{C}}^{i}(t) \displaystyle=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),A\cap\mathcal{C}\neq\emptyset}H_{\mathcal{C}}^{i}(\mathbf{X}_{A},t)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),A\cap\mathcal{C}=\emptyset}H_{\mathcal{C}}^{i}(t), where H_{\mathcal{C}}^{i}(\mathbf{X}_{A},t)=\left(\prod_{j\in\mathcal{C}\cap A}\bra{X_{j}}\right)\left(\prod_{k\in\mathcal{C}\backslash A}\bra{\Sigma_{k}}\right)\mathcal{P}_{\mathcal{C}}^{i}(t) . For the state with another area B , which satisfies B\cap\mathcal{C}=\emptyset or A\cap\mathcal{C}=\emptyset for each connected component \mathcal{C}\in\mathbf{C}(G\backslash i) , we have: \displaystyle P(\mathbf{X}_{A}S_{i}\mathbf{X}_{B},t) \displaystyle=P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),A\cap\mathcal{C}\neq\emptyset}H_{\mathcal{C}}^{i}(\mathbf{X}_{A},t)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),B\cap\mathcal{C}\neq\emptyset}H_{\mathcal{C}}^{i}(\mathbf{X}_{B},t)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),(A\cup B)\cap\mathcal{C}=\emptyset}H_{\mathcal{C}}^{i}(t) (S26) \displaystyle=P(S_{i},0)\cfrac{P(\mathbf{X}_{A}S_{i},t)}{P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),A\cap\mathcal{C}=\emptyset}H_{\mathcal{C}}^{i}(t)}\cfrac{P(\mathbf{X}_{B}S_{i},t)}{P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),B\cap\mathcal{C}=\emptyset}H_{\mathcal{C}}^{i}(t)}\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i),(A\cup B)\cap\mathcal{C}=\emptyset}H_{\mathcal{C}}^{i}(t) \displaystyle=\cfrac{P(\mathbf{X}_{A}S_{i},t)P(\mathbf{X}_{B}S_{i},t)}{P(S_{i},0)\prod_{\mathcal{C}\in\mathbf{C}(G\backslash i)}H_{\mathcal{C}}^{i}(t)} \displaystyle=\cfrac{P(\mathbf{X}_{A}S_{i},t)P(\mathbf{X}_{B}S_{i},t)}{P(S_{i},t)}. Then it is simple to obtain the pair approximation in SIR-like models by giving A=\{j\},B=\{k\} each containing only one neighbor node of i . And the constrain on A and B is simplified to the pair of neighbors j and k are connected exclusively through the intermediate node i . And the global establishing condition is the tree structure with no loop. For our method, we force the calculation of the state tensor \mathcal{P}_{\alpha}(t) in a local area \alpha , the naive calculation is \displaystyle\mathcal{P}_{\alpha}(t+\tau) \displaystyle=\mathcal{T}_{\alpha,\partial\alpha}\mathcal{P}_{\alpha,\partial\alpha}(t), (S27) \displaystyle\mathcal{T}_{\alpha,\partial\alpha} \displaystyle=\prod_{i\in\alpha}\mathcal{T}_{i,\partial i}\Delta_{i}\prod_{j\in\partial\alpha}\Delta_{j}, (S28) where \mathcal{T}_{\alpha,\partial\alpha} encoding P\left(X_{\alpha}^{t+\tau}|X_{\alpha}^{t},X_{\partial\alpha}^{t}\right) is also factorized into tensors \mathcal{T}_{i,\partial i} and \Delta_{i} . Start with a single node j\in\partial\alpha , which has only one neighbor i\in\alpha and the tensor \Delta_{j} becomes a unit matrix. Then the external index of j in \mathcal{T}_{\alpha,\partial\alpha} only comes from \mathcal{T}_{i,\partial i} . We can peel off the infection from j : \mathcal{T}_{i,\partial i}=\mathcal{T}_{i,\partial i\backslash j}\bra{\Sigma_{j}}+\lambda\tau(\ket{I_{i}}-\ket{S_{i}})\bra{I_{j}}\bra{S_{i}}\prod_{k\in\partial i\backslash j}\bra{\Sigma_{k}}. (S29) Apply on Eq.( S27 ): \mathcal{P}_{\alpha}^{t+\tau}=\left[\mathcal{T}_{i,\partial i\backslash j}\bra{\Sigma_{j}}+\lambda\tau(\ket{I_{i}}-\ket{S_{i}})\bra{I_{j}}\bra{S_{i}}\prod_{k\in\partial i\backslash j}\bra{\Sigma_{k}}\right]\Delta_{i}\prod_{k\in\alpha\backslash i}\mathcal{T}_{k,\partial k}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l}\mathcal{P}_{\alpha,\partial\alpha}^{t}. (S30) For simplicity, we denote \prod_{k\in\alpha\backslash i}\mathcal{T}_{k,\partial k}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l} The first term in the middle bracket is: \mathcal{T}_{i,\partial i\backslash j}\bra{\Sigma_{j}}\Delta_{i}\prod_{k\in\alpha\backslash i}\mathcal{T}_{k,\partial k}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l}\mathcal{P}_{\alpha,\partial\alpha}^{t}=\prod_{k\in\alpha\backslash i}\mathcal{T}_{k,\partial k\backslash j}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l}\mathcal{P}_{\alpha,\partial\alpha\backslash j}^{t}, (S31) without dependence on the state of j . And for the second term: \displaystyle\bra{I_{j}}\bra{S_{i}}\Delta_{i}\mathcal{P}_{\alpha,\partial\alpha}^{t} \displaystyle=\prod_{m\in(\partial i\cap\alpha)}\ket{S_{m}}\bra{I_{j}}\bra{S_{i}}\mathcal{P}_{\alpha,\partial\alpha}(t) (S32) \displaystyle=\prod_{m\in(\partial i\cap\alpha)}\ket{S_{m}}\cfrac{P(I_{j}S_{i},t)}{P(S_{i},t)}\bra{S_{i}}\mathcal{P}_{\alpha,\partial\alpha\backslash j}(t) \displaystyle=m_{j\to i}(t)\bra{S_{i}}\Delta_{i}\mathcal{P}_{\alpha,\partial\alpha\backslash j}(t), where the other factor remains in the derivation. In this part, the message m_{j\to i}(t)=P(I_{j}S_{i},t)/P(S_{i},t) efficiently replaced the dependence on the state of j . Substitute upper function and Eq.( S31 ) to Eq.( S30 ): \displaystyle\mathcal{P}_{\alpha}^{t+\tau} \displaystyle=\left[\mathcal{T}_{i,\partial i\backslash j}+\lambda\tau(\ket{I_{i}}-\ket{S_{i}})m_{j\to i}(t)\bra{S_{i}}\prod_{k\in\partial i\backslash j}\bra{\Sigma_{k}}\right]\Delta_{i}\prod_{k\in\alpha\backslash i}\mathcal{T}_{k}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l}\mathcal{P}_{\alpha,\partial\alpha\backslash j}^{t} (S33) \displaystyle=\mathcal{T}_{i,\partial i\backslash j}(m_{j\to i}(t))\Delta_{i}\prod_{k\in\alpha\backslash i}\mathcal{T}_{k}\Delta_{k}\prod_{l\in\partial\alpha\backslash j}\Delta_{l}\mathcal{P}_{\alpha,\partial\alpha\backslash j}^{t}. We denote \mathcal{T}_{i,\partial i\backslash j}(m_{j\to i}(t)) as the local transition tensor with index of j replaced by m_{j\to i}(t) . Moreover, the influence of multiple neighbors can be simply expressed as the addition of messages as: \mathcal{T}_{i,\partial i\backslash j}(m_{\partial\alpha\to i}(t)) where m_{\partial\alpha\to i}(t)=\sum_{j\in(\partial i\cap\partial\alpha)}m_{j\to i}(t) . Furthermore, assuming that all external neighbors of all nodes in \alpha meet the condition of the previous derivation, we can replace all the indices of \partial\alpha by the corresponding messages. So we have: \displaystyle\mathcal{P}_{\alpha}(t+\tau) \displaystyle=\prod_{i\in\alpha}\mathcal{T}_{i,\partial i\cap\alpha}(m_{\partial\alpha\to i}(t))\Delta_{k}\mathcal{P}_{\alpha}(t) (S34) \displaystyle=\mathcal{T}_{\alpha}(m_{\partial\alpha}(t))\mathcal{P}_{\alpha}(t), we apply \mathcal{T}_{i,\partial i\cap\alpha}(m_{\partial\alpha\to i}(t)) on all nodes, since m_{\partial\alpha\to i}(t)=0 if a node i has not external neighbor. We have obtained the local update function, but it only establishes in special areas whose external neighbors are exclusively connected to the area through a node in the area. There is a trivial case that the update of single node marginals are \mathcal{P}_{i}(t+\tau)=\mathcal{T}_{i}(m_{\partial i}(t))\mathcal{P}_{i}(t) which we use to calculate marginals in our method. In the case of an area with multiple nodes, the condition means that there is no loop crossing the eligible area, that the edges of a loop are either all contained by the area or that no edge of the loop consists of the area. Consequently, to find the eligible areas, we can remove all edges consisting of no loop, that each edge is a minimal eligible area, and the connected components of the left networks are other eligible areas. The areas found in such a method are the minimum units because they cannot be divided into smaller eligible areas (except single nodes) while their combination also fits the condition of Eq. ( S34 ). Hence we call them regions, and they are consistent with theory as biconnected components in graph. V Approximate partition algorithm Figure S1: Exact and approximate partition on an example network and the dolphin social network. (a-c) An application of exact partition and approximate partition with L and N . Dashed lines circle non-trivial regions with different colors and other gray edges are trivial regions, while the common nodes are in gradient coloring. (a): Exact partition, (b): Approximation with L=3 , (c): Approximation with N=4 . (d) The size of largest region of a real-world social network of dolphins, obtained by approximation with L and N . The network has n=62 nodes and the largest exact region has a size of 53. First, we consider an approximation that ignores excessively long loops, parameterized by an upper bound for length L . In this approach, regions collect only short loops (length \leq L ), and edges that only consist of longer loops are divided into single-edge regions. This approximation is based on the widely accepted assumption that the error decreases with growing loop length, a principle widely used in other works to fix loop errors. This approximation is implemented by removing edges from exact regions on the basis of the length of the shortest loop containing them. An example with L=3 in Fig. S1 (b) reduces the region size from 6 to 5 with minimal error. This L -based approximation is not an efficient constraint on region size, as it struggles to split dense-connected regions rich in short loops, as shown in Fig. S1 (d), where a dominant region remains even for L<5 , and the smallest improvement of L=3 results in an intractable region size of 31. Given the impracticality of the L -based approximation for general networks, we introduce the approximation that directly sets a maximal region size N , and divides oversized regions accordingly. In the approximation based on N , an oversized exact region is divided into approximate regions whose size does not exceed the parameter N . This approach is also based on the negative correlation between the length of loops and the corresponding error. In analogy to the approximation with L , we remove edges from regions in the order of the minimum length of loops that contain them. However, in this approximation, the removal continues until the region size is sufficiently small. As a consequence, there could be complete loops in the edges removed. By definition, the approximation with N=\infty is returned to strict, as regions of any size are allowed. At the other extreme, N=2 forces each region to contain only one edge, effectively assuming no loops and degenerating TNDMP into a tensor-method equivalent to the pair approximation. An example with N=4 in Fig. S1 (c) shows a stronger region truncation than the approximation with L=3 . In Fig. S1 (d), the N -based approximation demonstrates a linear reduction in maximum region size (green line ), which has been shown to be more effective than the L -based approach. Furthermore, combined approximation with two parameters L,N is also feasible and have potential on more complex networks. Note that, the homologous two approximation have a relation that approximate regions obtained with N cannot contain loops longer than N , such that they are sub networks of the regions obtained from approximation with L=N . This property is also used in the algorithm. Unlike the L -based method, the partition with a given N is not unique; a greedy heuristic algorithm is used, with optimal partition searching left for future research. Our algorithm of N -based repartitioning on an oversized regions is a recursive procedure that systematically isolates appropriately sized sub-regions. In one iteration, we first obtain the length of the shortest loop encompassing edge e , which is denoted l_{e} . Then we remove all edges with maximum l_{e} if the remaining part has a size still larger than N . If removing present max- l_{e} edges will make the remaining network smaller than N , a secondary criterion is applied. We introduce n(l_{e}) , defined as the number of distinct loops of length l_{e} containing the edge e . Edges with a lower n(l_{e}) are prioritized for removal, under the assumption that their exclusion introduces a smaller error by disrupting fewer long-range correlations. This process continues until the primary component’s size is at most N , at which point this component is accepted as a valid N -approximate region. Unlike the L -based method, the excised edges and their associated vertices are not discarded. Instead, they constitute a new subgraph. The non-trivial biconnected components of this new subgraph are then recursively subjected to the same N -based re-partitioning procedure. This recursion terminates when all remaining components are trivial (i.e., single edges or trees). In realization, we use a trick from aforementioned property that we perform the N -based re-partitioning on L -approximate regions given L=N , instead of exact regions. Therefore, the complete procedure of a N -based approximation is composed of three partitioning in sequence: a biconnected component partitioning, a L -based repartitioning given L=N , and the final N -based repartitioning. The complete procedure is summarized in the provided pseudo-code.