## 2 Materials and Methods
### Preliminaries
#### 2.2.3 Model  
We present the HMAGNN designed for link prediction, elucidating its effective utilization and learning of both structural and attribute information. The HMAGNN architecture comprises three integral components, illustrated in Figure 3.  
In the node transformation and labeling phase, the heterogeneous graph undergoes a process to obtain the feature matrix \(X\in\mathbf{R}^{N\times F}\) and the adjacency matrix \(A\in\mathbf{R}^{N\times N}\). We use the traditional feature-based GNN to compute the feature-based node representation \(H\) through the joint calculation of the adjacency matrix and the feature matrix. \[H=GNN\big{(}X,\tilde{\text{A}};W\big{)} \tag{2}\]  
where \(X\) is the original feature matrix, \(\tilde{\text{A}}\) is the normalized adjacency matrix, and \(W\) is the parameter matrix. This operation utilizes a GNN to effectively capture and encode the structural information within the heterogeneous graph, providing a learned feature representation \(H\) that will be further utilized in subsequent stages of the model. The multi-head attention mechanism is employed in the node feature generator to enhance the utilization of node information and generate refined feature vectors. This mechanism is introduced to improve predictions for sales links of Xinjiang jujube by considering various aspects of the data. In this mechanism, different features are treated as distinct \"heads\", each assigned its level of importance and correlations among different features. By employing the multi-head attention mechanism, attention can be directed simultaneously to these various features, resulting in a more comprehensive representation of the relationships between nodes. For instance, one head may prioritize sales volume, while another focuses on profit maximization. Each head learns a unique weight matrix to calculate attention for different features, enabling the model to capture multiple aspects of the data simultaneously. The fused feature vector representation \(h_{i}^{t}\) for node \(i\) at layer \(t\) is computed as follows:  
\[h_{i}^{t}=ReLU\Big{(}\sum\
olimits_{j\in\mathcal{N}_{i}}\sum\
olimits_{k=1}^ {K}\alpha_{i,j,k}^{t}W_{k}^{t}h_{j}^{t-1}\Big{)} \tag{3}\]  
Here, _ReLU_ (Rectified Linear Unit) is a commonly used activation function, \(h_{i}^{t}\) represents the feature representation of node \(i\) in the \(t\)-th layer, \(W_{k}^{t}\) denotes the weight matrix  
Figure 3: The HMAGNN framework for link prediction. The process involves node labeling, two Multi-Layer Perceptrons (MLPs), and a multi-head mechanism for node feature generation. The structural vector \(\mathbf{x}\in\mathbf{R}^{N\times 1}\) is transformed into the structural matrix \(X^{s}\in\mathbf{R}^{N\times N}\), and similarity scores are computed and adaptively combined using the parameter \(\mathbf{\alpha}\). (**a**) HMAGNN first transforms the heterogeneous graph into the same feature space through a transformation matrix, and then labels the nodes in the graph; (**b**) HMAGNN learns structural features from the adjacency matrix and considers a multi-head mechanism to generate structural feature vectors; (**c**) Diagonalizes the structural feature vectors to construct a diagonal matrix; (**d**) Computes the loss based on the two node representations Z and h obtained from HMAGNN and GNN, respectively. of the \(k\)-th head in the \(t\)-th layer, \(K\) is the number of heads, and \(\alpha_{i,j,k}^{t}\) represents the \(k\)-th attention coefficient between node \(i\) and node \(i\). The attention coefficient \(\alpha_{i,j,k}^{t}\) is computed using a _LeakyReLU_ activation function as follows:  
\[\alpha_{i,j,k}^{t}=\frac{exp\Big{(}LeakyReLU\Big{(}a_{k}^{T}\Big{[}W_{h}^{t} h_{i}^{t-1}\Big{|}\Big{|}W_{h}^{t}h_{j}^{t-1}\Big{]}\Big{)}\Big{)}}{\sum_{j\in N _{i}}exp\Big{(}LeakyReLU\Big{(}a_{k}^{T}\Big{[}W_{h}^{t}h_{i}^{t-1}\Big{|}\Big{|} W_{h}^{t}h_{i}^{t-1}\Big{]}\Big{)}\Big{)}} \tag{4}\]  
where _LeakyReLU_ is an improvement on _ReLU_, which will give a very small non-zero output.