Graph cardinal number estimation method and system based on query graph decomposition

Through query graph decomposition and tag extension graph structure, combined with GIN+GAT hybrid model, the accuracy and real-time problems of cardinality estimation in the graph database are solved, and accurate capture and low-latency response to complex graph structures are achieved.

CN120448416APending Publication Date: 2025-08-08UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510535645.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-26
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

In the prior art, when estimating cardinal numbers in graph databases, it is difficult to accurately capture global structural information and semantic relationships, especially in multi-step query or complex connection scenarios, and the calculation complexity is high, making it difficult to meet the low latency requirements of real-time query optimization.

Method used

Using a method based on query graph decomposition, the query graph is split into subquery graphs through an adaptive subgraph decomposition algorithm, and a tag extension graph is constructed, and a GIN+GAT hybrid model is used for training, and cardinality prediction is performed in combination with the graph attention module.

Benefits of technology

It significantly improves the accuracy and real-time nature of cardinal estimation, reduces the computational complexity, can process complex graph structures more finely, enhances robustness and generalization capabilities, and adapts to graph database query tasks of different scales and structures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448416A_ABST
    Figure CN120448416A_ABST
Patent Text Reader

Abstract

The invention discloses a graph cardinal number estimation method and system based on query graph decomposition, belongs to the field of cardinal number estimation in graph database query optimization, and solves the problem that global structure information and semantic relationships are difficult to accurately capture in the prior art. The method comprises the following steps: decomposing each query graph in a query graph set based on a self-adaptive sub-graph decomposition algorithm to obtain a sub-query graph set and a skeleton graph corresponding to each query graph; constructing a label expansion graph based on the data graph, obtaining a corresponding label node embedding vector for each label node in the label expansion graph by adopting a Pone algorithm, and obtaining all initial representations as a data set according to the label node embedding vector and the sub-query graph set corresponding to each query graph; training the improved GIN + GAT hybrid model based on the data set to obtain a trained improved GIN + GAT hybrid model; and utilizing the trained improved GIN + GAT hybrid model to carry out cardinality prediction on a to-be-predicted query graph. The method is used for graph cardinal number estimation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] A graph cardinality estimation method and system based on query graph decomposition are used for graph cardinality estimation, belonging to the field of cardinality estimation in graph database query optimization. Background Art

[0002] Currently, mainstream graph databases (such as Neo4j and TigerGraph) rely on cardinality estimation modules to generate optimized query plans. Traditional methods typically use statistical techniques (which rely on independence assumptions and are prone to error accumulation) or sampling methods (which have high sampling failure rates under complex data distributions) to achieve cardinality estimation. Although some learning-based approximation methods have improved this problem to a certain extent, their high computational overhead and task dependence have severely limited their practical applications. In recent years, although graph neural networks (GNNs, including GCN, GIN, and GAT) and random walk models have explored ways to alleviate data scale and complexity issues, existing technologies still have fundamental limitations in capturing complex graph structure information and improving model scalability and universality.

[0003] Based on the above problems, BI-GRAM CARDINALITY ESTIMATION IN A GRAPH DATABASE, application number US16719594. Provides a method and apparatus for estimating the cardinality of graph pattern queries using graph statistics and metadata. In various embodiments, node and edge labels are used to calculate estimates of graph patterns (bipartite graphs), and estimates of these patterns are combined to provide cardinality estimates of longer paths. Bipartite graph calculations are low-cost and can be used with minimal changes to existing query planners in existing database machinery. The resulting estimates are used during query execution to minimize the workload required to complete the query and return true and accurate answers to the user. However, there are the following technical problems:

[0004] 1. Estimation through a combination of node and edge labels (i.e., the bigram method) tends to ignore deeper graph structures and relational complexity. For multi-step queries or complex connections, it is difficult to accurately capture global structural information and semantic relationships.

[0005] 2. Since simple graph statistics are used to estimate the cardinality of long paths, cumulative errors can easily lead to inaccurate cardinality predictions in complex queries.

[0006] 3. When faced with diverse and dynamically changing graph database scenarios, graph-based statistical estimation methods are difficult to cope with data sets of different structures and sizes.

[0007] 4. When the query scale and data graph scale increase significantly, the statistical-based graph cardinality estimation method will lead to a significant increase in time consumption, making it difficult to meet the strict low latency requirements of real-time query optimization. Summary of the Invention

[0008] In response to the above research problems, the purpose of the present invention is to provide a graph cardinality estimation method and system based on query graph decomposition, so as to solve the problem that the existing technology uses a combination of node and edge labels (i.e., a bigram method) for estimation, which easily ignores the deeper graph structure and relationship complexity, and is difficult to accurately capture the global structural information and semantic relationships for multi-step queries or complex connections.

[0009] In order to achieve the above object, the present invention adopts the following technical solutions:

[0010] A graph cardinality estimation method based on query graph decomposition includes the following steps:

[0011] S1. Obtain a query graph set, and decompose each query graph in the query graph set based on an adaptive subgraph decomposition algorithm to obtain a subquery graph set and a skeleton graph corresponding to each query graph;

[0012] S2. Construct a label expansion graph based on the data graph, and use the Prone algorithm to obtain the corresponding label node embedding vector for each label node in the label expansion graph. Then, obtain all initial representations as a data set based on the label node embedding vector and the sub-query graph set corresponding to each query graph;

[0013] S3. Training the improved GIN+GAT hybrid model based on the data set and the skeleton graph to obtain a trained improved GIN+GAT hybrid model;

[0014] S4. Use the trained improved GIN+GAT hybrid model to perform cardinality prediction on the query graph to be predicted.

[0015] Furthermore, the specific steps of step S1 are:

[0016] S1.1, obtain the query graph set, and perform q =(V q , E q ) to determine the scale, if the number of nodes in the node set meets |V q |<τ, then directly use the query graph as a subquery graph and execute S2 directly; otherwise, execute step S1.2, where V q Represents the qth query graph G q The node set, E q Represents the qth query graph G qThe edge set of , τ represents the set threshold, and the query graph represents the query input in the form of a graph. The query graph is converted from the query language of the graph database and is used to estimate the number of matching results on the data graph. The data graph refers to the original graph data to be queried.

[0017] S1.2. Initialize the subquery graph set S to an empty set, that is

[0018] S1.3, in the query graph G q Perform a z-step random walk on the network and randomly select a starting node v0∈V q , then the random walk path W is defined as:

[0019] W={v0,v1,v2,v t , v t+1 …, v z}

[0020] Among them, v t+1 It is by v t In the query graph G q The neighbor set N(v t ) sampling to obtain:

[0021] v t+1 ~P(v|v t )

[0022]

[0023] Among them, household (v|v t ) represents the transition probability, v t and v t+1 They represent the tth and t+1th nodes in the random walk path W respectively;

[0024] S1.4, based on the random walk path W, construct multiple sub-query graphs, if the i-th sub-query graph G i If it is not fully covered, then add the subquery set S=S ∪{G i}, in the query graph G q If G is completely covered, the subquery graph is discarded until all subquery graphs are processed and the process goes to step S1.5. Full coverage refers to the graph consisting of the union of the nodes and edges of the subquery graphs that have been added to the subquery set S. i is a subgraph of this graph, then G i is completely covered, the subquery graph G i The formula is:

[0025] G i =(V i , E j ), V i =W,Ei ={(v a , v b )|v a , v b ∈W,(v a , v b )∈E q}

[0026] Where, v a and v b Respectively represent the ath and bth nodes in the random walk path, V i Represents the i-th subquery graph G i The node set, E i Represents the i-th subquery graph G i The edge set of

[0027] S1.5. Based on the subquery set S, a skeleton graph is constructed to represent the relationship between all subquery graphs. The skeleton graph G sk =(V sk , E sk )'s node set V sk ={i|G i ∈S} represents the subquery index, and the subquery index i in the skeleton graph represents the subquery graph G i , if two subquery graphs G i and G j If there are common nodes, add edges to the skeleton graph And record the overlapping nodes as edges e ij Node label(i, j)=V i ∩V j , and finally output the skeleton graph G sk , where V j Represents the jth subquery graph G in multiple subquery graphs j The node set, i≠j, the final skeleton graph G sk E in sk Contains all edges e that meet the conditions ij , V sk Contains all nodes that meet the conditions.

[0028] Furthermore, the specific steps of step S2 are:

[0029] S2.1. Constructing label extension graph G based on data graph Label , the formula is:

[0030] G Label =(V∪V Label , E ∪ E Label )

[0031] E Labele{(v, l)}|v∈V,l∈V Label}

[0032] Among them, V Label Represents the set of label nodes, E Label Represents the label edge set, each label I∈∑ corresponds to a label node, ∑ represents the set of node and edge labels in the data graph, and the data graph refers to the original graph data that needs to be queried G D =(V, E), where V represents the original graph data G D The node set, E represents the original graph data G D The edge set of

[0033] Step 2.2: Use the ProNE algorithm to learn the graph representation of the label expansion graph. That is, the ProNE algorithm uses truncated SVD to transform the label expansion graph G Label Embed into a low-dimensional vector space to obtain the low-dimensional embedding of each label node, that is, to obtain the node embedding vector of each label node. The formula is:

[0034] Z Label =SVD(P Label , d)

[0035]

[0036] L=ID -1 A

[0037] Among them, Z Label It represents the node embedding vector of each label node output by ProNE, which contains both structural information and label information. d represents the target dimension, n is the propagation order, L represents the normalized Laplace matrix, and L n is the nth order normalized Laplace matrix, w n is the nth-order weight coefficient, which is used to attenuate the information contribution of high-order neighbors. A and D represent the information contribution from the label expansion graph G. Label The adjacency matrix and degree matrix extracted from , I represents the label expansion graph G Label The identity matrix, P Label is the label extension graph G Label The propagation matrix;

[0038] Step 2.3: Expand graph G based on labels Label Each label node in the subquery set S queries whether there is a corresponding label in the node label. If the node has a label corresponding to the label node, the corresponding subquery graph node is frequency-encoded, and the frequency encoding result is concatenated with the node embedding vector of the label node to obtain the initial representation; if the node in the subquery set S has a label but is in the label extension graph G LabelIf there is no corresponding label node in the subquery set S, the embedding vector of the node is directly set to all 1s as a preliminary representation; if the node in the subquery set S has no label, the embedding vector of the node is directly set to all 0s.

[0039] Furthermore, the GIN+GAT hybrid model in step 3 includes an input layer that receives the initial representation, a two-layer GIN network that processes the initial representation to obtain node features corresponding to each sub-query graph, an aggregation layer that aggregates the node features of each sub-query graph obtained by processing the two-layer GIN network to obtain a sub-graph vector aggregation, a graph attention module that calculates the weight of the sub-graph vector based on the skeleton graph, and a multi-layer perceptron MLP that processes the final query graph global vector obtained by multiplying the weight with the sub-graph and performing weighted aggregation to obtain a cardinality.

[0040] Furthermore, the propagation process of the first layer of the two-layer GIN network connected sequentially with the initial representation input is:

[0041] The first layer of the GIN network calculates each subquery graph G based on the initial representation i The embedding representation of each subquery graph G is obtained i =(V i , E i )’s node feature matrix is The edge feature matrix is GIN is used to update the embedding of node features. The graph neural network GIN updates the node features and splices the node features with the edge features for message passing and aggregation. The node feature update steps are as follows:

[0042] Message passing: For the subquery graph G i Each edge (v x , v y ), the node v x and node v y Node features and edge features e xy Put them together to generate the message:

[0043]

[0044] Among them, m xy For node v x Received from neighbor node v y The message is sent by node v x In the k-1th layer GIN features, edge features e xy and node v y The features of GIN in the k-1th layer are concatenated using the Concat operation. Represents node v xUpdated features of GIN at the k-1th layer;

[0045] Message aggregation: Then, all incoming nodes v x The messages are aggregated according to the selected aggregation method:

[0046]

[0047] in, For node v x The updated features of GIN at the kth layer are used to update the representation of the node by aggregating the information of all neighboring nodes, ∑ y∈N(x) For node v x All neighbor nodes v y The summation operation of the transmitted messages is performed, and ReLU is the activation function used to introduce nonlinearity, which truncates negative values to zero;

[0048] The polymerization formula of the polymerization layer is:

[0049]

[0050] Among them, h s,i Represents the i-th subquery graph G in the subquery graph set S i The subgraph vector, V i is the subquery graph G i The set of all node features in h f is the feature of node f;

[0051] The weight calculation formula of the graph attention module is:

[0052]

[0053] Among them, α ij is the subquery graph G i With subquery graph G j The weight between them, the sub-query graph is the learnable parameter of the attention module, and W is the input sub-graph vector h of the previous layer. s,i The linear transformation matrix, || represents the vector splicing operation, is the subquery graph G i The neighbor subquery graph set of G, T represents the transpose, and m represents the subquery graph G i The k-th neighbor subquery graph, LeakyReLU is the activation function LeakyReLU(x)=max(0,x)+αmin(0,x), α is a given constant, x represents the input,;

[0054] The final query graph global vector g is obtained by multiplying the weights and subgraphs and performing weighted aggregation. query The formula is:

[0055]

[0056] Among them, β i is the subquery graph G i The weight in the query graph is calculated by pooling method, Represents the result of multiplying the weight by the subgraph vector, h s,m Represents the subquery graph G i The mth subquery graph in the set of neighbor subquery graphs, α im Represents the subquery graph G i With subquery graph G m The weight between .

[0057] A graph cardinality estimation system based on query graph decomposition, comprising:

[0058] Decomposition module: obtains a query graph set and decomposes each query graph in the query graph set based on an adaptive subgraph decomposition algorithm to obtain a subquery graph set and a skeleton graph corresponding to each query graph;

[0059] Dataset construction module: Construct a label extension graph based on the data graph, and use the Prone algorithm to obtain the corresponding label node embedding vector for each label node in the label extension graph. Then, all initial representations are obtained as the dataset based on the label node embedding vector and the sub-query graph set corresponding to each query graph;

[0060] Model construction module: train the improved GIN+GAT hybrid model based on the dataset and skeleton graph to obtain the trained improved GIN+GAT hybrid model;

[0061] Prediction module: Use the trained improved GIN+GAT hybrid model to perform cardinality prediction on the query graph to be predicted.

[0062] Furthermore, the specific implementation steps of the decomposition module are:

[0063] S1.1, obtain the query graph set, and perform q =(V q , E q ) to determine the scale, if the number of nodes in the node set meets |V q |<τ, then directly use the query graph as a subquery graph and execute S2 directly; otherwise, execute step S1.2, where V q Represents the qth query graph G q The node set, E q Represents the qth query graph G qThe edge set of , T represents the set threshold, and the query graph represents the query input in the form of a graph. The query graph is converted through the query language of the graph database and is used to estimate the number of matching results on the data graph. The data graph refers to the original graph data to be queried;

[0064] S1.2. Initialize the subquery graph set S to an empty set, that is

[0065] S1.3, in the query graph G q Perform a z-step random walk on the network and randomly select a starting node v0∈V q , then the random walk path W is defined as:

[0066] W={v0,v1,v2,v t , v t+1 …, v z}

[0067] Among them, v t+1 It is by v t In the query graph G q The neighbor set N(v t ) sampling to obtain:

[0068] v t+1 ~P(v|v t )

[0069]

[0070] Among them, P(v|v t ) represents the transition probability, v t and v t+1 They represent the tth and t+1th nodes in the random walk path W respectively;

[0071] S1.4, based on the random walk path W, construct multiple sub-query graphs, if the i-th sub-query graph G i If it is not fully covered, then add the subquery set S=S∪{G i}, in the query graph G q If G is completely covered, the subquery graph is discarded until all subquery graphs are processed and go to step S1.5. Full coverage refers to the graph consisting of the union of nodes and edges of the subquery graphs that have been added to the subquery set S. i is a subgraph of this graph, then G i is completely covered, the subquery graph G i The formula is:

[0072] G i =(V i , E j ), V i =W,Ei ={(v a , v b )|v a , v b ∈W,(v a , v b )∈E q}

[0073] Where, v a and v b Respectively represent the ath and bth nodes in the random walk path, V i Represents the i-th subquery graph G i The node set, E i Represents the i-th subquery graph G i The edge set of

[0074] S1.5. Based on the subquery set S, a skeleton graph is constructed to represent the relationship between all subquery graphs. The skeleton graph G sk =(V sk , E sk )'s node set V sk ={i|G i ∈S} represents the subquery index, and the subquery index i in the skeleton graph represents the subquery graph G i , if two subquery graphs G i and G j If there are common nodes, add edges to the skeleton graph And record the overlapping nodes as edges e ij Node label(i, j)=V i ∩V j , and finally output the skeleton graph G sk , where V j Represents the jth subquery graph G in multiple subquery graphs j The node set, i≠j, the final skeleton graph G sk E in sk Contains all edges e that meet the conditions ij , V sk Contains all nodes that meet the conditions.

[0075] Furthermore, the specific implementation steps of the dataset construction module are:

[0076] S2.1. Constructing label extension graph G based on data graph Label , the formula is:

[0077] G Label =(V∪V Label , E∪E Label )

[0078] ELabel ={(v, l)}|v∈V,l∈V Label}

[0079] Among them, V Label Represents the set of label nodes, E Label Represents the label edge set, each label l∈∑ corresponds to a label node, ∑ represents the set of node and edge labels in the data graph, and the data graph refers to the original graph data that needs to be queried G D =(V, E), where V represents the original graph data G D The node set, E represents the original graph data G D The edge set of

[0080] Step 2.2: Use the ProNE algorithm to learn the graph representation of the label expansion graph. That is, the ProNE algorithm uses truncated SVD to transform the label expansion graph G Label Embed into a low-dimensional vector space to obtain the low-dimensional embedding of each label node, that is, to obtain the node embedding vector of each label node. The formula is:

[0081] Z Label =SVD(P Label , d)

[0082]

[0083] L=ID -1 A

[0084] Among them, Z Label It represents the node embedding vector of each label node output by ProNE, which contains both structural information and label information. d represents the target dimension, n is the propagation order, L represents the normalized Laplace matrix, and L n is the nth order normalized Laplace matrix, w n is the nth-order weight coefficient, which is used to attenuate the information contribution of high-order neighbors. A and D represent the information contribution from the label expansion graph G. Label The adjacency matrix and degree matrix extracted from , I represents the label expansion graph G Label The identity matrix, P Label is the label extension graph G Label The propagation matrix;

[0085] Step 2.3: Expand graph G based on labels Label Each label node in the subquery set S queries whether there is a corresponding label in the node label. If the node has a label corresponding to the label node, the corresponding subquery graph node is frequency-encoded, and the frequency encoding result is concatenated with the node embedding vector of the label node to obtain the initial representation; if the node in the subquery set S has a label but is in the label extension graph G LabelIf there is no corresponding label node in the subquery set S, the embedding vector of the node is directly set to all 1s as a preliminary representation; if the node in the subquery set S has no label, the embedding vector of the node is directly set to all 0s.

[0086] Furthermore, the GIN+GAT hybrid model in the model construction module includes an input layer that receives the initial representation, a two-layer GIN network that processes the initial representation to obtain node features corresponding to each sub-query graph, an aggregation layer that aggregates the node features of each sub-query graph obtained by processing the two-layer GIN network to obtain sub-graph vector aggregation, a graph attention module that calculates weights of sub-graph vectors based on the skeleton graph, and a multi-layer perceptron MLP that processes the final query graph global vector obtained by multiplying the weight with the sub-graph and performing weighted aggregation to obtain the cardinality.

[0087] Furthermore, in the model building module, the process of propagation of the first layer G1N network in the two layers of GIN networks connected sequentially to the initial representation input is as follows:

[0088] The first layer of the GIN network calculates each subquery graph G based on the initial representation i The embedding representation of each subquery graph G is obtained i =(V i , E i )’s node feature matrix is The edge feature matrix is GIN is used to update the embedding of node features. The graph neural network GIN updates the node features and splices the node features with the edge features for message passing and aggregation. The node feature update steps are as follows:

[0089] Message passing: For the subquery graph G i Each edge (v x , v y ), the node v x and node v y Node features and edge features e xy Put them together to generate the message:

[0090]

[0091] Among them, m xy For node v x Received from neighbor node v y The message is sent by node v x In the k-1th layer GIN features, edge features e xy and node v y The features of GIN in the k-1th layer are concatenated using the Concat operation. Represents node v xUpdated features of GIN at the k-1th layer;

[0092] Message aggregation: Then, all incoming nodes v x The messages are aggregated according to the selected aggregation method:

[0093]

[0094] in, For node v x The updated features of GIN at the kth layer are used to update the representation of the node by aggregating the information of all neighboring nodes, ∑ y∈N(x) For node v x All neighbor nodes v y The summation operation of the transmitted messages is performed, and ReLU is the activation function used to introduce nonlinearity, which truncates negative values to zero;

[0095] The polymerization formula of the polymerization layer is:

[0096]

[0097] Among them, h s,i Represents the i-th subquery graph G in the subquery graph set S i The subgraph vector, V i is the subquery graph G i The set of all node features in h f is the feature of node f;

[0098] The weight calculation formula of the graph attention module is:

[0099]

[0100] Among them, α ij is the subquery graph G i With subquery graph G j The weight between them, the sub-query graph is the learnable parameter of the attention module, and W is the input sub-graph vector h of the previous layer. s,i The linear transformation matrix, || represents the vector splicing operation, is the subquery graph G i The neighbor subquery graph set of G, T represents the transpose, and m represents the subquery graph G i The k-th neighbor subquery graph, LeakyReLU is the activation function LeakyReLU(x)=max(0,x)+αmin(0,x), α is a given constant, x represents the input,;

[0101] The final query graph global vector g is obtained by multiplying the weights and subgraphs and performing weighted aggregation. query The formula is:

[0102]

[0103] Among them, β i is the subquery graph G i The weight in the query graph is calculated by pooling method, Represents the result of multiplying the weight by the subgraph, h s,m Represents the subquery graph G i The mth subquery graph in the set of neighbor subquery graphs, α im Represents the subquery graph G i With subquery graph G m The weight between .

[0104] Compared with the prior art, the present invention has the following beneficial effects:

[0105] This paper uses a unique query graph decomposition and label expansion graph construction method to deeply explore the complex correlation between the query graph and the data graph, thereby significantly improving the accuracy and real-time performance of cardinality estimation. This application method not only makes up for the shortcomings of traditional methods, but is also reflected in the following aspects:

[0106] 1. When using a query graph to query a data graph, the present invention uses a query graph decomposition algorithm to decompose the input query graph into subgraphs. Since the query graph contains a large number of nodes and edges, its complex structure easily leads to information loss and increased computational burden. By splitting the query graph into multiple independently modeled subquery graphs, not only the computational complexity is significantly reduced, but also the key structural information is completely retained, laying the foundation for subsequent accurate estimation. That is, the GIN+GAT hybrid model is combined with subquery graph decomposition. By intelligently decomposing the query graph and introducing a label extension graph and label nodes, the multi-dimensional information of the graph data can be comprehensively reflected. In combination with the attention module, complex local and global structures are captured, which significantly improves the accuracy of cardinality estimation. Compared with the two-tuple statistical method, the present invention can process complex graph structures more finely and avoid the problem of cumulative error.

[0107] 2. The present invention comprehensively utilizes the feature information of the query graph and the data graph (i.e., the original data graph), and constructs a label extension graph by introducing label nodes into the original data graph. These label nodes provide unique contextual information for the data graph. The ProNE algorithm is used to embed the label nodes into a low-dimensional vector space and fuse them with the original node representation, which greatly improves the quality and robustness of the overall embedding representation and effectively captures the potential information in the data graph. That is, the unique data enhancement graph construction method is adopted to effectively solve the information interaction problem between the data graph and the query graph. The present invention introduces contextual information by fusing label nodes in the construction of the label extension graph, and adopts back propagation for iterative update in the training of the GIN+GAT hybrid model, so that the GIN+GAT hybrid model can still maintain stable estimation performance when facing data noise or partial attribute deviations. Compared with the binary statistical method that relies too much on local statistical information, this solution has obvious advantages in robustness.

[0108] 3. The GIN+GAT hybrid model is used to characterize each sub-query graph, and each sub-query graph is mapped into a vector to capture its local structural features. To further enhance the model's expressiveness, the GIN+GAT hybrid model in this invention introduces an attention module to dynamically calculate the importance of each sub-query graph and perform weighted aggregation, ultimately forming a global vector representation of the query graph of the complete query graph, thereby achieving an effective combination of local and global information. That is, a combination of graph decomposition and the GIN+GAT hybrid model is adopted, so that the GIN+GAT hybrid model can not only quickly capture local features, but also take into account global information, and adapt to graph database query tasks of different scales and structures. In order to enhance the generalization ability of the model The present invention is trained on different data sets (i.e., the size and type of the query graph of the data set and the size of the data graph are gradually increased for model training, and all have good performance). The amount of data gradually increases, and the size and type of the query graph are also increasingly rich. Compared with the bigram statistical method, the present invention can still maintain good generalization ability in scenarios with fewer data sets or higher query complexity. At the same time, since the present invention uses an estimation method based on the GIN+GAT hybrid model, the time for graph cardinality estimation depends on the size of the GIN+GAT hybrid model rather than the data graph, so the size of the data graph has no effect on the estimation time. Compared with the bigram statistical method, the present invention has a faster response time on large data sets. BRIEF DESCRIPTION OF THE DRAWINGS

[0109] Figure 1 It is the overall flow chart of the present invention;

[0110] Figure 2 It is a flowchart of the diagram decomposition of the present invention;

[0111] Figure 3 Flowchart for decomposing and initializing subgraph vectors for the extended graph and graph representation algorithm in the present invention;

[0112] Figure 4 This is a flow chart of the multi-level feature transfer module in the present invention. DETAILED DESCRIPTION

[0113] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0114] A graph cardinality estimation method based on query graph decomposition includes the following steps:

[0115] S1. Obtain a query graph set, and decompose each query graph in the query graph set based on an adaptive subgraph decomposition algorithm to obtain a subquery graph set and a skeleton graph corresponding to each query graph;

[0116] The specific steps are:

[0117] S1.1, obtain the query graph set, and perform q =(V q , E q ) to determine the scale, if the number of nodes in the node set meets |V q |<τ, then directly use the query graph as a subquery graph and execute S2 directly; otherwise, execute step S1.2, where V q Represents the qth query graph G q The node set, E q Represents the qth query graph G q The edge set, T represents the set threshold, such as 3, we get Figure 1 In the decomposition shown, the query graph represents the query input in the form of a graph. The query graph is converted from the query language of the graph database and is used to estimate the number of matching results on the data graph. The data graph refers to the original graph data to be queried.

[0118] S1.2. Initialize the subquery graph set S to an empty set, that is

[0119] S1.3, such as Figure 2 Generate a 3-node subgraph in the query graph G q Perform z (e.g. 3) steps of random walk on the node and randomly select a starting node v0∈V q , then the random walk path W is defined as:

[0120] W={v0,v1,v2,v t , v t+1 …, v z}

[0121] Among them, v t+1 It is by v t In the query graph G qThe neighbor set N(v t ) sampling to obtain:

[0122] v t+1 ~P(v|v t )

[0123]

[0124] Among them, P(v|v t ) represents the transition probability, v t and v t+1 They represent the tth and t+1th nodes in the random walk path W respectively;

[0125] S1.4, based on the random walk path W, construct multiple sub-query graphs, such as Figure 2 In the subgraph decomposition, if the i-th subquery graph G i If it is not fully covered, then add the subquery set S=S∪{G i}, in the query graph G q If G is completely covered, the subquery graph is discarded until all subquery graphs are processed and go to step S1.5. Full coverage refers to the graph consisting of the union of nodes and edges of the subquery graphs that have been added to the subquery set S. i is a subgraph of this graph, then G i is completely covered, the subquery graph G i The formula is:

[0126] G i =(V i , E j ), V i =W,E i ={(v a , v b )|v a , v b ∈W,(v a , v b )∈E q}

[0127] Where, v a and v b Respectively represent the ath and bth nodes in the random walk path, V i Represents the i-th subquery graph G i The node set, E i Represents the i-th subquery graph G i The edge set of

[0128] S1.5. Based on the subquery set S, a skeleton graph is constructed to represent the relationship between all subquery graphs, such as Figure 2 The subgraph skeleton thumbnail in the skeleton graph Gsk =(V sk , E sk )'s node set V sk ={i|G i ∈S} represents the subquery index, and the subquery index i in the skeleton graph represents the subquery graph G i , if two subquery graphs G i and G j If there are common nodes, add edges to the skeleton graph And record the overlapping nodes as edges e ij Node label(i, j)=V i ∩V j , and finally output the skeleton graph G sk , where V j Represents the jth subquery graph G in multiple subquery graphs j The node set, i≠j, the final skeleton graph G sk E in sk Contains all edges e that meet the conditions ij , V sk Include all nodes that meet the conditions, such as q2 and q3 in the graph. These two sub-query graphs serve as nodes 2 and 3 of the skeleton graph. Then, since the two sub-query graphs have common nodes 3 and 4 of the original query graph, {3, 4} is added to the label node.

[0129] An adaptive subgraph decomposition algorithm is introduced. This algorithm dynamically adjusts the decomposition granularity and subgraph size, effectively reducing computational complexity while preserving key structural information of the query graph. Compared to traditional heuristic decomposition methods, this algorithm utilizes a subgraph importance metric to determine which parts must be retained, thereby achieving precise decomposition. This mechanism is applied to the query graph cardinality estimation problem, ensuring efficient and accurate subsequent computations.

[0130] S2. Construct a label expansion graph based on the data graph, and use the Prone algorithm to obtain the corresponding label node embedding vector for each label node in the label expansion graph. Then, obtain all initial representations as a data set based on the label node embedding vector and the sub-query graph set corresponding to each query graph;

[0131] The specific steps are:

[0132] S2.1、Based on the data graph (such as Figure 3 Original data graph G) Construct label expansion graph G Label , the formula is:

[0133] G Label =(V∪V Label , E∪E Label )

[0134] ELabel ={(v, l)}|v∈V,l∈V Label}

[0135] Among them, V Label Represents the set of label nodes, E Label Represents the label edge set, each label I∈∑ corresponds to a label node, ∑ represents the set of node and edge labels in the data graph, and the data graph refers to the original graph data that needs to be queried G D =(V, E), where V represents the original graph data G D The node set, E represents the original graph data G D The edge set of

[0136] Step 2.2: Use the ProNE algorithm to learn the graph representation of the label expansion graph (e.g. Figure 3 As shown), the ProNE algorithm uses truncated SVD to expand the label graph G Label Embed into a low-dimensional vector space to obtain the low-dimensional embedding of each label node, that is, to obtain the node embedding vector of each label node. The formula is:

[0137] Z Label =SVD(P Label , d)

[0138]

[0139] L=ID -1 A

[0140] Among them, Z Label It represents the node embedding vector of each label node output by ProNE, which contains both structural information and label information. d represents the target dimension, n is the propagation order, L represents the normalized Laplace matrix, and L n is the nth order normalized Laplace matrix, w n is the nth-order weight coefficient, which is used to attenuate the information contribution of high-order neighbors. A and D represent the information contribution from the label expansion graph G. Label The adjacency matrix and degree matrix extracted from , I represents the label expansion graph G Label The identity matrix, P Label is the label extension graph G Label The propagation matrix;

[0141] Step 2.3: Expand graph G based on labels Label Each label node in the subquery set S queries whether there is a corresponding label in the node label. If the node has a label corresponding to the label node, the corresponding subquery graph node is frequency-encoded, and the frequency encoding result is concatenated with the node embedding vector of the label node to obtain the initial representation; if the node in the subquery set S has a label but is in the label extension graph GLabel If there is no corresponding label node in the subquery set S, the embedding vector of the node is directly set to all 1s as a preliminary representation; if the node in the subquery set S has no label, the embedding vector of the node is directly set to all 0s.

[0142] Based on subgraph decomposition, label nodes with contextual semantic information are introduced into the original data graph to construct an augmented graph. This label node embedding and vector information fusion strategy uses label nodes as a bridge to effectively integrate multi-source feature information from the query graph and data graph, enhancing graph representation capabilities. Unlike existing technologies that rely solely on structural information, this invention offers significant advantages in feature fusion.

[0143] S3. Based on the data set and the skeleton graph, the improved GIN+GAT hybrid model is trained to obtain the trained improved GIN+GAT hybrid model; Figure 4 As shown, the GIN+GAT hybrid model includes an input layer that receives the initial representation, a two-layer GIN network that processes the initial representation to obtain the node features corresponding to each sub-query graph, an aggregation layer that aggregates the node features of each sub-query graph obtained by the two-layer GIN network to obtain a sub-graph vector aggregation, a graph attention module that calculates the weight of the sub-graph vector based on the skeleton graph, and a multi-layer perceptron MLP that processes the final query graph global vector obtained by multiplying the weight with the sub-graph and performing weighted aggregation to obtain the cardinality.

[0144] The process of propagation of the first layer of the two-layer GIN network connected in sequence with the initial representation input is:

[0145] like Figure 3 As shown, the first layer of the GIN network calculates each subquery graph G based on the initial representation i The embedding representation of each subquery graph G is obtained i =(V i , E i )’s node feature matrix is In the experiment, the matrix size is 3*128, and the edge feature matrix is The actual value is |E i |×128, since the number of edges is uncertain, |E i |Not fixed. GIN is used to update the embedding of node features. GIN updates node features and splices node features with edge features for message passing and aggregation. The node feature update steps are as follows:

[0146] Message passing: For the subquery graph G i Each edge (v x , v y ), the node v xand node v y Node features and edge features e xy Put them together to generate the message:

[0147]

[0148] Among them, m xy For node v x Received from neighbor node v y The message is sent by node v x In the k-1th layer GIN features, edge features e xy and node v y The features of GIN in the k-1th layer are concatenated using the Concat operation. Represents node v x Updated features of GIN at the k-1th layer;

[0149] like Figure 4 As shown, for each edge (v x , v y ),like Figure 4 The edge (1, 4) in the graph is the feature of node 1 and node 4 as well as the edge feature e 14 Put them together to generate the message:

[0150]

[0151] Among them, m 14 Node 1 receives a message from neighbor 4, which is composed of node 1’s features at layer 0 and edge features e 14 and the feature of node 4 at layer 0. Concat is a concatenation operation that connects different vectors (node features, edge features) into a larger vector.

[0152] Message aggregation: Then, all incoming nodes v x The messages are aggregated according to the selected aggregation method:

[0153]

[0154] in, For node v x The updated features of GIN at the kth layer are used to update the representation of the node by aggregating the information of all neighboring nodes, ∑ y∈N(x) For node v x All neighbor nodes v y The summation operation of the transmitted messages is performed, and ReLU is the activation function used to introduce nonlinearity, which truncates negative values to zero;

[0155] For example, all messages incoming to node 1 will be aggregated according to the selected aggregation method:

[0156]

[0157] The updated feature of node 1 in the first layer is used to update the node representation by aggregating the information of all neighboring nodes. y∈N(1) For all neighbor nodes v of node 1 y (Here, only 4 neighbor nodes are 1) are summed up. ReLU is an activation function used to introduce nonlinearity, which truncates negative values to zero. The same operation is performed on other nodes to obtain the updated sub-query graph embedding (such as Figure 4 Upper left k=1 level subquery graph);

[0158] The polymerization formula of the polymerization layer is:

[0159]

[0160] Among them, h s,i Represents the i-th subquery graph G in the subquery graph set S i The subgraph vector, V i is the subquery graph G i The set of all node features in h f is the feature of node f;

[0161] The weight calculation formula of the graph attention module is:

[0162]

[0163] Among them, α ij is the subquery graph G i With subquery graph G j The weight between them, the sub-query graph is the learnable parameter of the attention module, and W is the input sub-graph vector h of the previous layer. s,i The linear transformation matrix, || represents the vector splicing operation, is the subquery graph G i The neighbor subquery graph set of T represents transposition, and k represents the subquery graph G i The k-th neighbor subquery graph, LeakyReLU is the activation function LeakyReLU(x)=max(0,x)+αmin(0,x), α is a given constant, x represents the input,;

[0164] The GAT layer multiplies the weights with the subgraphs and then performs weighted aggregation to obtain the final query graph global vector q query The formula is:

[0165]

[0166] Among them, β i is the subquery graph G i The weight in the query graph is calculated by pooling method, Represents the result of multiplying the weight by the subgraph vector, h s,m Represents the subquery graph G i The mth subquery graph in the set of neighbor subquery graphs, α im Represents the subquery graph G i With subquery graph G m The weight between .

[0167] Query graph global vector g query Input to the multi-layer perceptron to achieve the mapping from high-dimensional embedding to the final single cardinality estimate. Figure 4 The multilayer perceptron part in:

[0168]

[0169] in, is the final predicted value of the cardinality estimation. MLP is a multi-layer perceptron that includes nonlinear activation functions and fully connected layers to learn the complex patterns of the query graph. For the vector representation of the sub-query graph, the present invention introduces an attention mechanism based on the use of the GIN+GAT hybrid model to capture local features, dynamically assigning the weight of each sub-graph in the global query graph representation. This sub-query graph vector aggregation method combined with the attention mechanism can more comprehensively reflect the relationship between local and global structures, ensuring that the model takes into account both details and overall information in cardinality estimation.

[0170] S4. Use the trained improved GIN+GAT hybrid model to perform cardinality prediction on the query graph to be predicted.

[0171] In summary, the present invention processes complex query graphs efficiently and accurately.

[0172] The above are only representative embodiments of the present invention in many specific application scopes and do not constitute any limitation on the protection scope of the present invention. Any technical solutions formed by transformation or equivalent replacement fall within the scope of protection of the present invention.

Claims

1. A graph cardinality estimation method based on query graph decomposition, characterized in that: The steps include: S1. Obtain a query graph set, and decompose each query graph in the query graph set based on an adaptive subgraph decomposition algorithm to obtain a subquery graph set and a skeleton graph corresponding to each query graph; S2. Construct a label expansion graph based on the data graph, and use the Prone algorithm to obtain the corresponding label node embedding vector for each label node in the label expansion graph. Then, obtain all initial representations as a data set based on the label node embedding vector and the sub-query graph set corresponding to each query graph; S3. Training the improved GIN+GAT hybrid model based on the data set and the skeleton graph to obtain a trained improved GIN+GAT hybrid model; S4. Use the trained improved GIN+GAT hybrid model to perform cardinality prediction on the query graph to be predicted.

2. A graph cardinality estimation method based on query graph decomposition according to claim 1, characterized in that: The specific steps of step S1 are: S1.1, obtain the query graph set, and perform q =(V q , E q ) to determine the scale, if the number of nodes in the node set meets |V q |<τ, then directly use the query graph as a subquery graph and execute S2 directly; otherwise, execute step S1.2, where V q Represents the qth query graph G q The node set, E q Represents the qth query graph G q The edge set of , τ represents the set threshold, and the query graph represents the query input in the form of a graph. The query graph is converted from the query language of the graph database and is used to estimate the number of matching results on the data graph. The data graph refers to the original graph data to be queried. S1.

2. Initialize the subquery graph set S to an empty set, that is S1.3, in the query graph G q Perform a z-step random walk on the network and randomly select a starting node v0∈V q , then the random walk path W is defined as: W={v0,v1,v2,v t ,v t+1 …,v z } Among them, v t+1 It is by v t In the query graph G q The neighbor set N(v t ) sampling to obtain: v t+1 ~P(v|v t ) Among them, P(v|v t ) represents the transition probability, v t and v t+1 They represent the tth and t+1th nodes in the random walk path W respectively; S1.4, based on the random walk path W, construct multiple sub-query graphs, if the i-th sub-query graph G i If it is not fully covered, then add the subquery set S=S∪{G i }, in the query graph G q If G is completely covered, the subquery graph is discarded until all subquery graphs are processed and the process goes to step S1.

5. Full coverage refers to the graph consisting of the union of the nodes and edges of the subquery graphs that have been added to the subquery set S. i is a subgraph of this graph, then G i is completely covered, the subquery graph G i The formula is: G i =(V i ,E j ),V i =W,E i ={(v a ,v b )|v a ,v b ∈W,(v a ,v b )∈E q } Where, v a and v b Respectively represent the ath and bth nodes in the random walk path, V i Represents the i-th subquery graph G i The node set, E i Represents the i-th subquery graph G i The edge set of S1.

5. Based on the subquery set S, a skeleton graph is constructed to represent the relationship between all subquery graphs. The skeleton graph G sk =(V sk , E sk )'s node set V sk ={i|G i ∈S} represents the subquery index, and the subquery index i in the skeleton graph represents the subquery graph G i , if two subquery graphs G i and G j If there are common nodes, add edges to the skeleton graph And record the overlapping nodes as edges e ij Node label(i, j)=V i ∩V j , and finally output the skeleton graph G sk , where V j Represents the jth subquery graph G in multiple subquery graphs j The node set, i≠j, the final skeleton graph G sk E in sk Contains all edges e that meet the conditions ij , V sk Contains all nodes that meet the conditions.

3. A graph cardinality estimation method based on query graph decomposition according to claim 2, characterized in that: The specific steps of step S2 are: S2.

1. Constructing label extension graph G based on data graph Label , the formula is: G Label =(V∪V Label ,E∪E Label ) E Label ={(v,l)}|v∈V,l∈V Label } Among them, V Label Represents the set of label nodes, E Label Represents the label edge set, each label I∈∑ corresponds to a label node, ∑ represents the set of node and edge labels in the data graph, and the data graph refers to the original graph data that needs to be queried G D =(V, E), where V represents the original graph data G D The node set, E represents the original graph data G D The edge set of Step 2.2: Use the ProNE algorithm to learn the graph representation of the label expansion graph. That is, the ProNE algorithm uses truncated SVD to transform the label expansion graph G Label Embed into a low-dimensional vector space to obtain the low-dimensional embedding of each label node, that is, to obtain the node embedding vector of each label node. The formula is: Z Label =SVD(P Label ,d) L=I-D -1 A Among them, Z Label It represents the node embedding vector of each label node output by ProNE, which contains both structural information and label information. d represents the target dimension, n is the propagation order, L represents the normalized Laplace matrix, and L n is the nth order normalized Laplace matrix, w n is the nth-order weight coefficient, which is used to attenuate the information contribution of high-order neighbors. A and D represent the information contribution from the label expansion graph G. Label The adjacency matrix and degree matrix extracted from , I represents the label expansion graph G Label The identity matrix, P Label is the label extension graph G Label The propagation matrix; Step 2.3: Expand graph G based on labels Label Each label node in the subquery set S queries whether there is a corresponding label in the node label. If the node has a label corresponding to the label node, the corresponding subquery graph node is frequency-encoded, and the frequency encoding result is concatenated with the node embedding vector of the label node to obtain the initial representation; if the node in the subquery set S has a label but is in the label extension graph G Label If there is no corresponding label node in the subquery set S, the embedding vector of the node is directly set to all 1s as a preliminary representation; if the node in the subquery set S has no label, the embedding vector of the node is directly set to all 0s.

4. A graph cardinality estimation method based on query graph decomposition according to claim 3, characterized in that: The GIN+GAT hybrid model in step 3 includes an input layer that receives the initial representation, a two-layer GIN network that processes the initial representation to obtain node features corresponding to each sub-query graph, an aggregation layer that aggregates the node features of each sub-query graph obtained by the two-layer GIN network to obtain a sub-graph vector aggregation, a graph attention module that calculates the weight of the sub-graph vector based on the skeleton graph, and a multi-layer perceptron MLP that processes the final query graph global vector obtained by multiplying the weight with the sub-graph and performing weighted aggregation to obtain the cardinality.

5. A graph cardinality estimation method based on query graph decomposition according to claim 4, characterized in that: The process of propagation of the first layer of the two-layer GIN network connected in sequence with the initial representation input is: The first layer of the GIN network calculates each subquery graph G based on the initial representation i The embedding representation of each subquery graph G is obtained i =(V i , E i )’s node feature matrix is The edge feature matrix is GIN is used to update the embedding of node features. The graph neural network GIN updates the node features and splices the node features with the edge features for message passing and aggregation. The node feature update steps are as follows: Message passing: For the subquery graph G i Each edge (v x , v y ), the node v x and node v y Node features and edge features e xy Put them together to generate the message: Among them, m xy For node v x Received from neighbor node v y The message is sent by node v x In the k-1th layer GIN features, edge features e xy and node v y The features of GIN in the k-1th layer are concatenated using the Concat operation. Represents node v x Updated features of GIN at the k-1th layer; Message aggregation: Then, all incoming nodes v x The messages are aggregated according to the selected aggregation method: in, For node v x The updated features of GIN at the kth layer are used to update the representation of the node by aggregating the information of all neighboring nodes, ∑ y∈N(x) For node v x All neighbor nodes v y The summation operation of the transmitted messages is performed, and ReLU is the activation function used to introduce nonlinearity, which truncates negative values to zero; The polymerization formula of the polymerization layer is: Among them, h s,i Represents the i-th subquery graph G in the subquery graph set S i The subgraph vector, V i is the subquery graph G i The set of all node features in h f is the feature of node f; The weight calculation formula of the graph attention module is: Among them, α ij is the subquery graph G i With subquery graph G j The weight between them, the sub-query graph is the learnable parameter of the attention module, and W is the input sub-graph vector h of the previous layer. s,i The linear transformation matrix, || represents the vector splicing operation, is the subquery graph G i The neighbor subquery graph set of G, T represents the transpose, and m represents the subquery graph G i The k-th neighbor subquery graph, LeakyReLU is the activation function LeakyReLU(x)=max(0,x)+αmin(0,x), α is a given constant, x represents the input,; The final query graph global vector g is obtained by multiplying the weights and subgraphs and performing weighted aggregation. query The formula is: Among them, β i is the subquery graph G i The weight in the query graph is calculated by pooling method, Represents the result of multiplying the weight by the subgraph, h s,m Represents the subquery graph G i The mth subquery graph in the set of neighbor subquery graphs, α im Represents the subquery graph G i With subquery graph G m The weight between .

6. A graph cardinality estimation system based on query graph decomposition, characterized in that: include: Decomposition module: obtains a query graph set and decomposes each query graph in the query graph set based on an adaptive subgraph decomposition algorithm to obtain a subquery graph set and a skeleton graph corresponding to each query graph; Dataset construction module: Construct a label extension graph based on the data graph, and use the Prone algorithm to obtain the corresponding label node embedding vector for each label node in the label extension graph. Then, all initial representations are obtained as the dataset based on the label node embedding vector and the sub-query graph set corresponding to each query graph; Model construction module: train the improved GIN+GAT hybrid model based on the dataset and skeleton graph to obtain the trained improved GIN+GAT hybrid model; Prediction module: Use the trained improved GIN+GAT hybrid model to perform cardinality prediction on the query graph to be predicted.

7. A graph cardinality estimation system based on query graph decomposition according to claim 6, characterized in that: The specific implementation steps of the decomposition module are: S1.1, obtain the query graph set, and perform q =(V q , E q ) to determine the scale, if the number of nodes in the node set meets |V q |<τ, then directly use the query graph as a subquery graph and execute S2 directly; otherwise, execute step S1.2, where V q Represents the qth query graph G q The node set, E q Represents the qth query graph G q The edge set of , τ represents the set threshold, and the query graph represents the query input in the form of a graph. The query graph is converted from the query language of the graph database and is used to estimate the number of matching results on the data graph. The data graph refers to the original graph data to be queried. S1.

2. Initialize the subquery graph set S to an empty set, that is S1.3, in the query graph G q Perform a z-step random walk on the network and randomly select a starting node v0∈V q , then the random walk path W is defined as: W={v0,v1,v2,v t ,v t+1 …,v z } Among them, v t+1 It is by v t In the query graph G q The neighbor set N(v t ) sampling to obtain: v t+1 ~P(v|v t ) Among them, household (v|v t ) represents the transition probability, v t and v t+1 They represent the tth and t+1th nodes in the random walk path W respectively; S1.4, based on the random walk path W, construct multiple sub-query graphs, if the i-th sub-query graph G i If it is not fully covered, then add the subquery set S=S∪{G i }, in the query graph G q If G is completely covered, the subquery graph is discarded until all subquery graphs are processed and the process goes to step S1.

5. Full coverage refers to the graph consisting of the union of the nodes and edges of the subquery graphs that have been added to the subquery set S. i is a subgraph of this graph, then G i is completely covered, the subquery graph G i The formula is: G i =(V i ,E j ),V i =W,E i ={(v a ,v b )|v a ,v b ∈W,(v a ,v b )∈E q } Where, v a and v b Respectively represent the ath and bth nodes in the random walk path, V i Represents the i-th subquery graph G i The node set, E i Represents the i-th subquery graph G i The edge set of S1.

5. Based on the subquery set S, a skeleton graph is constructed to represent the relationship between all subquery graphs. The skeleton graph G sk =(V sk , E sk )'s node set V sk ={i|G i ∈S} represents the subquery index, and the subquery index i in the skeleton graph represents the subquery graph G i , if two subquery graphs G i and G j If there are common nodes, add edges to the skeleton graph And record the overlapping nodes as edges e ij Node label(i, j)=V i ∩V j , and finally output the skeleton graph G sk , where V j Represents the jth subquery graph G in multiple subquery graphs j The node set, i≠j, the final skeleton graph G sk E in sk Contains all edges e that meet the conditions ij ,V sk Contains all nodes that meet the conditions.

8. The graph cardinality estimation system based on query graph decomposition according to claim 7, characterized in that: The specific implementation steps of the dataset construction module are: S2.

1. Constructing label extension graph G based on data graph Label , the formula is: G Label =(V∪V Label ,E∪E Label ) E Label ={(v,l)}|v∈V,l∈V Label } Among them, V Label Represents the set of label nodes, E Label Represents the label edge set, each label I∈∑ corresponds to a label node, ∑ represents the set of node and edge labels in the data graph, and the data graph refers to the original graph data that needs to be queried G D =(V, E), where V represents the original graph data G D The node set, E represents the original graph data G D The edge set of Step 2.2: Use the ProNE algorithm to learn the graph representation of the label expansion graph. That is, the ProNE algorithm uses truncated SVD to transform the label expansion graph G Label Embed into a low-dimensional vector space to obtain the low-dimensional embedding of each label node, that is, to obtain the node embedding vector of each label node. The formula is: Z Label =SVD(P Label ,d) L=I-D -1 A Among them, Z Label It represents the node embedding vector of each label node output by ProNE, which contains both structural information and label information. d represents the target dimension, n is the propagation order, L represents the normalized Laplace matrix, and L n is the nth order normalized Laplace matrix, w n is the nth-order weight coefficient, which is used to attenuate the information contribution of high-order neighbors. A and D represent the information contribution from the label expansion graph G. Label The adjacency matrix and degree matrix extracted from , I represents the label expansion graph G Label The identity matrix, P Label is the label extension graph G Label The propagation matrix; Step 2.3: Expand graph G based on labels Label Each label node in the subquery set S queries whether there is a corresponding label in the node label. If the node has a label corresponding to the label node, the corresponding subquery graph node is frequency-encoded, and the frequency encoding result is concatenated with the node embedding vector of the label node to obtain the initial representation; if the node in the subquery set S has a label but is in the label extension graph G Label If there is no corresponding label node in the subquery set S, the embedding vector of the node is directly set to all 1s as a preliminary representation; if the node in the subquery set S has no label, the embedding vector of the node is directly set to all 0s.

9. The graph cardinality estimation system based on query graph decomposition according to claim 8, characterized in that: The GIN+GAT hybrid model in the model construction module includes an input layer that receives the initial representation, a two-layer GIN network that processes the initial representation to obtain node features corresponding to each sub-query graph, an aggregation layer that aggregates the node features of each sub-query graph obtained by processing the two-layer GIN network to obtain sub-graph vector aggregation, a graph attention module that calculates weights of sub-graph vectors based on a skeleton graph, and a multi-layer perceptron MLP that processes the final query graph global vector obtained by multiplying the weights with the sub-graphs and performing weighted aggregation to obtain a cardinality.

10. The graph cardinality estimation system based on query graph decomposition according to claim 9, characterized in that: In the model building module, the process of propagation in the first layer of the two-layer GIN network connected sequentially with the initial representation input is as follows: The first layer of the GIN network calculates each subquery graph G based on the initial representation i The embedding representation of each subquery graph G is obtained i =(V i , E i )’s node feature matrix is The edge feature matrix is GIN is used to update the embedding of node features. The graph neural network GIN updates the node features and splices the node features with the edge features for message passing and aggregation. The node feature update steps are as follows: Message passing: For the subquery graph G i Each edge (v x , v y ), the node v x and node v y Node features and edge features e xy Put them together to generate the message: Among them, m xy For node v x Received from neighbor node v y The message is sent by node v x In the k-1th layer GIN features, edge features e xy and node v y The features of GIN in the k-1th layer are concatenated using the Concat operation. Represents node v x Updated features of GIN at the k-1th layer; Message aggregation: Then, all incoming nodes v x The messages are aggregated according to the selected aggregation method: in, For node v x The updated features of GIN at the kth layer are used to update the representation of the node by aggregating the information of all neighboring nodes, ∑ y∈N(x) For node v x All neighbor nodes v y The summation operation of the transmitted messages is performed, and ReLU is the activation function used to introduce nonlinearity, which truncates negative values to zero; The polymerization formula of the polymerization layer is: Among them, h s,i Represents the i-th subquery graph G in the subquery graph set S i The subgraph vector, V i is the subquery graph G i The set of all node features in h f is the feature of node f; The weight calculation formula of the graph attention module is: Among them, α ij is the subquery graph G i With subquery graph G j The weight between them, the sub-query graph is the learnable parameter of the attention module, and W is the input sub-graph vector h of the previous layer. s,i The linear transformation matrix, || represents the vector splicing operation, is the subquery graph G i The neighbor subquery graph set of G, T represents the transpose, and m represents the subquery graph G i The k-th neighbor subquery graph, LeakyReLU is the activation function LeakyReLU(x)=max(0,x)+αmin(0,x), α is a given constant, x represents the input,; The final query graph global vector g is obtained by multiplying the weights and subgraphs and performing weighted aggregation. query The formula is: Among them, β i is the subquery graph G i The weight in the query graph is calculated by pooling method, Represents the result of multiplying the weight by the subgraph vector, h s,m Represents the subquery graph G i The mth subquery graph in the set of neighbor subquery graphs, α im Represents the subquery graph G i With subquery graph G m The weight between .