Efficient and accurate graph editing distance calculation method and device
By dividing the graph into matched graphs, unmatched graphs and cross-edges, and using neural networks and traditional algorithms to calculate graph editing distance (GED) values of each part, the problem that existing methods require pre-calculation of editing paths is solved, and efficient and accurate graph editing distance estimation is achieved in the case of less training data.
Patent Information
- Application Number
- CN202411617571.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-11-13
AI Technical Summary
Existing hybrid methods require pre-calculate the editing path of the training set when calculating the graph editing distance, resulting in a significant decrease in the accuracy of predictions with less training data.
By dividing the graph into matched graphs, unmatched graphs and cross-edges, and using neural networks and traditional algorithms to calculate graph editing distance (GED) values for each part, these values are finally added to obtain an estimate of graph editing distance.
With less training data, the graph editing distance can be estimated accurately and efficiently, which improves the accuracy on multiple data sets, and specifically increases by 3.5%-6.4%.
Smart Images

Figure CN119785058A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of bioinformatics, drug discovery, data mining, and more specifically to a method and device for efficiently and accurately estimating a graph edit distance and measuring the similarity between two graphs. Background Art
[0002] Graph Edit Distance (GED) is a metric used to measure the similarity between two graphs. It measures the minimum number of edit operations required to transform one graph into another, including inserting, deleting, and modifying nodes, and inserting, deleting, and modifying edges.
[0003] At present, the calculation methods of graph edit distance can be roughly divided into three categories. One is the traditional graph algorithm. This type of method can accurately calculate GED, but it also faces the problem of being time-consuming - it cannot calculate the GED of a graph with more than 16 nodes in a reasonable time. One is a pure machine learning algorithm. This type of method is scalable and rapid, but it can only output the GED value but cannot predict the graph editing path. The last type of method combines traditional graph algorithms and machine learning algorithms. It can predict both the GED value of large-scale graphs and their editing paths. However, most of the last type of methods require the editing path of the training set to be calculated in advance, otherwise the accuracy of the prediction will drop significantly. Summary of the invention
[0004] In order to overcome the problem that the existing hybrid method needs to pre-calculate the editing path of the training set, the present invention provides an efficient and accurate graph edit distance calculation method and device that only needs GED values as training data.
[0005] The technical solution adopted by the present invention to solve its technical problem is:
[0006] An efficient and accurate graph edit distance calculation method includes the following steps:
[0007] The graph is divided into a matched graph, an unmatched graph, and cross-edges, wherein the matched graph contains matched nodes, the unmatched graph contains unmatched nodes, and the matched nodes and the unmatched nodes are connected by cross-edges;
[0008] Calculate the GED value of the matched graph, the GED value of the unmatched graph, and the GED value across the edge;
[0009] The GED value of the matched graph, the GED value of the unmatched graph, and the GED value across the edge are added together to obtain the final GED estimate.
[0010] Furthermore, the GED value of the matched graph is calculated according to the matching pairs.
[0011] Furthermore, the GED value of the unmatched graph is estimated by a neural network.
[0012] Furthermore, the calculation process of the GED value of the unmatched graph includes:
[0013] Input the graph pair into the graph neural network;
[0014] Use the graph convolutional network GCN to calculate the embedding information of the two graphs in the graph pair and obtain the node embedding vector;
[0015] Aggregate the node embedding vectors in the graph to generate an embedded representation of the graph;
[0016] The embedding representations of the two graphs are interacted using the neural tensor network NTN and the multi-layer perceptron MLP to obtain the GED value of the unmatched graph.
[0017] Furthermore, an interaction layer based on an attention mechanism is introduced when calculating the node embedding vector.
[0018] Furthermore, the calculation process of the cross-edge GED value includes:
[0019] Calculate the GED value across the edge from the perspective of the matched nodes;
[0020] Calculate the GED value across the edge from the perspective of the unmatched node;
[0021] The maximum GED value across the edge obtained from the two perspectives is taken.
[0022] Furthermore, the calculation of the GED value of the cross-edge from the perspective of the matched nodes is to estimate the GED value as the sum of the differences in the number of cross-edges connecting the matched node pairs.
[0023] An efficient and accurate graph edit distance calculation device, comprising:
[0024] A graph segmentation module is used to divide the graph into a matched graph, an unmatched graph, and cross-edges, wherein the matched graph contains matched nodes, the unmatched graph contains unmatched nodes, and the matched nodes and the unmatched nodes are connected through cross-edges;
[0025] The GED value calculation module is used to calculate the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge, and add the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge to obtain the final GED estimation value.
[0026] The beneficial effects of the present invention are:
[0027] The efficient and accurate graph edit distance calculation method of the present invention optimizes the algorithm for estimating the GED value of a partially matched graph (only a portion of the nodes are matched) in the original A* algorithm (which can be used to estimate the GED value of two undirected graphs). The present invention can accurately and efficiently estimate the GED value when there is less training data (missing the actual edit path). Specifically, compared with the existing methods, the accuracy of the method of the present invention on multiple data sets is improved by 3.5%-6.4%. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is the core idea of this method - a schematic diagram of dividing the graph into three parts, dividing the query graph into three parts, the matched graph, the unmatched graph and the cross-edge between the matched graph and the unmatched graph.
[0029] Figure 2 It is a model diagram for predicting the GED value of unmatched graphs using neural networks.
[0030] Figure 3 It is a schematic diagram of using traditional algorithms to estimate the GED values of the unmatched graph and the cross-edges between the matched graph and the unmatched graph, from the perspectives of the matched nodes (left side) and the unmatched nodes (right side). DETAILED DESCRIPTION
[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below through specific embodiments and drawings.
[0032] The existing graph edit distance calculation method based on the A* algorithm only considers the matching and unmatched parts of the graph pair, but fails to consider the edges connecting the matching and unmatched parts, which leads to inaccurate GED estimation. Figure 1 As shown in , the present invention divides the graph into three parts: matched graph, unmatched graph and border edges. The matched graph contains matched nodes, and the unmatched graph contains unmatched nodes. Both the unmatched graph and the border edges of the graph pair contribute to the GED estimation. The former is estimated by a neural network, and the latter is estimated from multiple angles using traditional algorithms.
[0033] When using the existing A* algorithm to calculate the graph edit distance (GED), first define the state as a set of partial matches and edit operations between two graphs. Next, select a heuristic function to estimate the minimum cost from the current state to the fully matched state. Use a priority queue to store the states to be explored, where the priority of the state is determined by the sum of the actual cost of the matched state and the heuristic estimated cost. Take the state with the lowest cost from the priority queue, add a new pair of matching nodes on this basis and put the new state into the priority queue. Repeat this process until a fully matched state is found, and the total cost at this time is the GED value. The present invention splits the cost from the current state to the fully matched state into two parts: the GED value caused by the unmatched graph and the GED value caused by the cross-edge between the matched and unmatched graphs.
[0034] Figure 2 It is a framework diagram of graph neural network. Its input is a graph pair (including node features and topological information), and its output is the normalized GED value of the two graphs, that is, the GED value of the unmatched graph. First, the graph convolutional network (GCN) is used to calculate the embedding information of the two graphs respectively to obtain the node embedding vector. When calculating the node embedding vector, an interaction layer based on the attention mechanism is also introduced. Then the node embedding vectors in the graph are aggregated to generate the embedding representation of the graph. Finally, the embedding representations of the two graphs are interacted using the Neural Tensor Network (NTN) and the Multi-Layer Perceptron (MLP) to obtain the GED value of the unmatched part.
[0035] Among them, the interaction layer based on the attention mechanism is used to improve the accuracy of prediction.
[0036] Among them, the neural tensor network and the multi-layer perceptron are used to interact, specifically, the graph-level embeddings of the two graphs are interacted, and finally a scalar representing the similarity is output.
[0037] Figure 3 Two methods are proposed to estimate the GED value caused by cross-edge. The first method is to calculate from the perspective of the already matched nodes, such as Figure 3As shown in the left part. Its GED value is estimated as the sum of the differences in the number of cross-edges connecting the matching node pairs (there may be more than one pair of matching node pairs, and the difference in the number of cross-edges needs to be calculated for each pair, and then the sum operation is performed). For example, there is a pair of matching nodes u and v, where node u comes from graph G1 and node v comes from graph G2. Node u is connected to two unmatched nodes, and node v is connected to one unmatched node, so the contribution of this part to the GED value is |2-1|=1. In addition, if node u in G1 matches an empty node in G2, then the contribution to GED is the number of unmatched nodes connected to node u.
[0038] However, relying solely on this perspective may result in an underestimated GED value. Figure 3 As shown on the right, there are three matched nodes and one unmatched node in G1, and this unmatched node is connected to all matched nodes; there are three matched nodes and three unmatched nodes in G2, and each unmatched node is connected to a matched node. The estimated value of GED obtained according to the above rules is 0, while the actual value is undoubtedly greater than 0. Therefore, the present invention proposes a second method to estimate from the perspective of unmatched nodes to improve the accuracy of the estimation. It is assumed that unmatched nodes with more cross-edge connections will be matched together. Therefore, assuming that u1, u2, and u3 in G1 are paired with v1, v2, and v3 in G2 respectively, and the only remaining unmatched node in G1 is paired with any remaining unmatched node in G2, the cross-edge contribution to GED is calculated to be |3-1|+|0-1|+|0-1|=4, which is closer to the true value. In summary, the present invention takes the maximum value of the estimated values obtained from these two perspectives to improve accuracy.
[0039] According to the above description, the A* algorithm can be combined to efficiently and accurately estimate the graph edit distance, wherein the steps of the heuristic function calculation method include:
[0040] 1) Divide the graph into three parts: matched graph, unmatched graph and cross-edge;
[0041] 2) Calculate the GED value of the matched graph, the GED value of the unmatched graph, and the GED value of the cross-edge;
[0042] 3) Add the GED value of the matched graph, the GED value of the unmatched part, and the GED value across the edge to get the final GED estimate.
[0043] Specific application scenarios of the present invention:
[0044] The graph edit distance calculation method of the present invention can be used to measure the similarity between two graphs, and can be used in the fields of bioinformatics, drug discovery, data mining, etc.
[0045] For example, in the field of drug discovery, the method of the present invention can be used to calculate the graph edit distance between the molecular structure of a known effective drug and the molecule to be screened, thereby obtaining a similarity, and based on the similarity, a candidate molecule with potential therapeutic activity can be quickly identified. Specifically, a similarity threshold can be set, and the calculated similarity can be compared with the threshold. If it is greater than the threshold, the molecule to be screened is determined to be a candidate molecule with potential therapeutic activity.
[0046] For example, in the field of data mining, the method of the present invention can be used to calculate the graph edit distance of the social network graph of two users (or multiple users), thereby obtaining the similarity. Based on the similarity, it can be determined whether the friend structures of the two users are similar, thereby analyzing the potential friendship circles and community affiliations of the users. Specifically, a similarity threshold can be set, and the calculated similarity can be compared with the threshold. If it is greater than the threshold, it is determined that the friend structures of the two users are similar, that is, the two users belong to the same community.
[0047] Another embodiment of the present invention provides an efficient and accurate graph edit distance calculation device, comprising:
[0048] A graph segmentation module is used to divide the graph into a matched graph, an unmatched graph, and cross-edges, wherein the matched graph contains matched nodes, the unmatched graph contains unmatched nodes, and the matched nodes and the unmatched nodes are connected through cross-edges;
[0049] The GED value calculation module is used to calculate the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge, and add the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge to obtain the final GED estimation value.
[0050] The division of the above modules is only an example. In actual applications, the above functions can be assigned to different functional modules as needed to complete all or part of the functions described in the above method. The specific working process of each module can refer to the corresponding process in the above method embodiment, which will not be repeated here.
[0051] Another embodiment of the present invention provides a computer device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present invention.
[0052] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk), wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the steps of the method of the present invention are implemented.
[0053] The specific embodiments of the present invention disclosed above are intended to help understand the content of the present invention and implement it accordingly. It can be understood by those skilled in the art that various replacements, changes and modifications are possible without departing from the spirit and scope of the present invention. The present invention should not be limited to the contents disclosed in the embodiments of this specification, and the scope of protection of the present invention shall be subject to the scope defined in the claims.
Claims
1. An efficient and accurate method for calculating graph edit distance, characterized in that: The following steps are involved: The graph is divided into a matched graph, an unmatched graph, and cross-edges, wherein the matched graph contains matched nodes, the unmatched graph contains unmatched nodes, and the matched nodes and the unmatched nodes are connected by cross-edges; Calculate the GED value of the matched graph, the GED value of the unmatched graph, and the GED value across the edge; The GED value of the matched graph, the GED value of the unmatched graph, and the GED value across the edge are added together to obtain the final GED estimate.
2. The method according to claim 1, characterized in that Calculate the GED value of the matched graph based on the matching pairs.
3. The method according to claim 1, characterized in that The GED value of the unmatched graph is estimated by a neural network.
4. The method according to claim 3, characterized in that The calculation process of the GED value of the unmatched graph includes: Input the graph pair into the graph neural network; Use the graph convolutional network GCN to calculate the embedding information of the two graphs in the graph pair and obtain the node embedding vector; Aggregate the node embedding vectors in the graph to generate an embedded representation of the graph; The embedding representations of the two graphs are interacted using the neural tensor network NTN and the multi-layer perceptron MLP to obtain the GED value of the unmatched graph.
5. The method according to claim 4, characterized in that An interaction layer based on the attention mechanism is introduced when calculating the node embedding vector.
6. The method according to claim 1, characterized in that The calculation process of the cross-edge GED value includes: Calculate the GED value across the edge from the perspective of the matched nodes; Calculate the GED value across the edge from the perspective of the unmatched node; The maximum GED value across the edge obtained from the two perspectives is taken.
7. The method according to claim 1, characterized in that The calculation of the GED value of the cross-edge from the perspective of the matched nodes is to estimate the GED value as the sum of the differences in the number of cross-edges connecting the matched node pairs.
8. An efficient and accurate graph edit distance calculation device, characterized in that: include: A graph segmentation module is used to divide the graph into a matched graph, an unmatched graph, and cross-edges, wherein the matched graph contains matched nodes, the unmatched graph contains unmatched nodes, and the matched nodes and the unmatched nodes are connected through cross-edges; The GED value calculation module is used to calculate the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge, and add the GED value of the matched graph, the GED value of the unmatched graph and the GED value across the edge to obtain the final GED estimation value.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Estimation method of law field graph editing distance based on Sim-GNN
CN114492567A
Graph matching method, device and equipment
CN115221359A
Mountain area image geographic positioning method and system based on scene semantic graph
CN116863121A
Code similarity detection method and device based on graph neural network and medium
CN118916714A
Graph edit distance determination in drug-like chemical spaces
WO2024206225A2