## 2 Materials and Methods
### Methods
#### 2.2.1 Knowledge-Guided Framework Based on Physical Constraints  
When data-driven models are used for flood prediction, only from a data perspective, the known physical constraints between observed and unobserved processes cannot be utilized, and they lack discrimination against some common-sense errors. The added physical constraint complies with the physical laws of the corresponding watershed derived from the observation data. A penalty term in the neural network loss function can be used to  
Figure 1: Model diagram of data-driven and knowledge-guided based heterogeneous graphs and temporal convolution networks (DK-HTAN). describe the degree of deviation between the neural network prediction and the constraint when this physical constraint is introduced into the model, particularly when the physical mechanism has been simplified into straightforward control equations. In this study, the theoretical guidance framework was better demonstrated by taking the flood discharge problem in small and medium-sized watershed areas as an example. In sections with tributaries, if the inflow of tributaries is large, the interference between the floods of the main and tributaries cannot be ignored. Therefore, this article adds the physical equation of the synthetic flow method for flood forecasting in river sections as a constraint mechanism. The specific structure is shown in Figure 2. River section flood forecasting is based on the operation and deformation laws of flood waves in the river section, using the measured flow of the upper section of the river section to predict the future flow of the lower section of the river section. This article mainly uses the synthetic flow method for river section floods. The specific formula is shown in Equation (5) below. \[Q_{t}=f\left(\sum\
olimits_{i=1}^{n}Q_{i,t-\tau_{i}}\right) \tag{5}\]  
\(Q_{t}\) represents the flow of downstream stations at time \(t\); \(\tau_{i}\) represents the time when the flood from each \(i\)-th upstream station reaches the downstream station; \(n\) represents the number of upstream main and tributary stations; and \(Q_{i}\) represents the flow of the \(i\)-th upstream station at time \(t\). Under different water conditions, the time for flow propagation from upstream stations to downstream stations may vary, but the difference is within a certain time range, and the span of that time range is limited. Therefore, this article estimates the \(\tau_{i}\) as the center, expand a time range forward to form a time window, and synthesize the linear combination of flow rates of all upstream stations within the time window as a prediction of flow rates of downstream stations. The specific relationship formula is:  
\[Q_{t}=f\left(\sum\limits_{i=1}^{n}\sum\limits_{j=-m}^{m}Q_{i,t-\tau_{i}+j} \varphi_{i,t-\tau_{i}+j}\right) \tag{6}\]  
\(M\) represents the time span of opening the window forward, and the size of the time window can be expressed as \(L=2m+1\); \(\varphi\) is the weight coefficient of traffic at each time within the window. Record the number of stations on the upstream main and tributaries as \(n\), and \(L\) is the time span for window opening. There are already \(N\) corresponding flow  
Figure 2: Loss framework guided by physical constraints of knowledge-guided module. data for upstream and downstream stations in the historical data; \(X_{i}\in R^{N(2L+1)}\) is the matrix formed by the flow data of the \(i\)-th upstream station within \(N\) time windows.