A graph matching method, apparatus and device

By dynamically adjusting the search space size using a neural network model and the A*beamsearch algorithm, the problems of low efficiency and poor accuracy in graph editing distance calculation in existing technologies are solved, achieving efficient and accurate graph matching.

CN115221359BActive Publication Date: 2026-08-04HUAWEI TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2021-04-15
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing technologies rely on experience to set the search space size when calculating graph editing distances, resulting in low computational efficiency or poor accuracy, making it difficult to accurately determine the best-matching graph.

Method used

By using a pre-trained neural network model to determine the search space size between different graphs, and combining it with the A*beamsearch algorithm to calculate the graph edit distance, the search space size is dynamically adjusted to adapt to the characteristics of a specific graph.

Benefits of technology

It improves the accuracy and efficiency of graph matching, and can more accurately determine the best matching graph, applicable to graph matching scenarios with different levels of similarity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115221359B_ABST
    Figure CN115221359B_ABST
Patent Text Reader

Abstract

A graph matching method, device and equipment, in the application, the graph matching device determines the first graph and the plurality of graphs to be matched, respectively acquires a plurality of search space sizes of the first graph and the plurality of graphs to be matched, and the plurality of search space sizes are not completely same. After obtaining the graph edit distance converted from the first graph to the plurality of graphs based on the plurality of search space sizes, the graph matching device determines the graph with the minimum graph edit distance from the first graph from the plurality of graphs as the target graph matched with the first graph. According to the graph matching method provided in the application, the search space size is no longer fixed, and is more targeted, so that the efficiency of the calculation of the graph edit distance can be ensured, and the accuracy of the graph edit distance can be ensured, and then the target graph matched with the first graph can be accurately and efficiently determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of graph technology, and in particular to a graph matching method, apparatus, and device. Background Technology

[0002] A graph is a data structure consisting of nodes and edges connecting the nodes. Graphs have a wide range of applications. For example, graphs can be used in the field of chemistry to represent complex chemical formulas, and they can also be used to describe social networks, road networks, and semantic networks.

[0003] In the graph domain, it is often necessary to identify the best-matching graph for a given graph, i.e., graph matching. The degree of matching between graphs can be represented by the graph edit distance. The graph edit distance refers to the minimum number of operations required to transform two graphs. The smaller the graph edit distance, the more similar the two graphs are, and the higher the degree of matching; the larger the graph edit distance, the greater the difference between the two graphs, and the lower the degree of matching.

[0004] Currently, when calculating the graph edit distance between two graphs, a search tree is typically constructed. This search tree represents all possible mappings between the two graphs during the transformation, with each mapping representing a possible transformation method. For each mapping in the search tree, a candidate graph edit distance can be calculated, and the smallest candidate graph edit distance is the actual graph edit distance.

[0005] To prevent the search tree from becoming too large, the maximum number of candidate graph edit distances retained in the search tree is limited during construction; this is known as the search space size or beam size. Currently, the search space size is set based on experience. However, an excessively large candidate operation set size increases the search tree construction time and computational overhead, ultimately leading to poor graph matching efficiency. Conversely, an excessively small search space size results in a small search tree, which may not cover all graph edit distances, ultimately making it impossible to accurately determine the best-matching graph. Summary of the Invention

[0006] This application provides a graph matching method, apparatus, and device to ensure the accuracy and efficiency of graph matching.

[0007] Firstly, embodiments of this application provide a graph matching method, which can be executed by a graph matching device. After determining a first graph and multiple graphs to be matched, the graph matching device obtains the search space dimensions of the first graph and each of the multiple graphs to be matched. Each graph to be matched has a search space dimension, thus the graph matching device can obtain multiple search space dimensions. These multiple search space dimensions can be different, meaning they are not entirely identical. The search space dimension of the first graph and each graph to be matched can indicate the maximum number of edit paths from the first graph to the graph to be matched. Then, the graph matching device can obtain the graph edit distances from the first graph to the multiple graphs based on the multiple search space dimensions. For each search space dimension of the first graph and each graph to be matched, the graph matching device can obtain the graph edit distance between the first graph and the graph to be matched. Finally, the graph matching device can determine the graph with the smallest graph edit distance to the first graph from the multiple graphs as the target graph to be matched with the first graph.

[0008] Using the method described above, the search space size used to calculate the graph edit distance between two graphs can be different. In other words, the search space size is no longer fixed but determined based on the two graphs to be matched. According to this graph matching method, the search space size is more targeted, thus ensuring both the efficiency and accuracy of the graph edit distance calculation. Consequently, it ensures the accurate and efficient identification of the target graph that matches the first graph.

[0009] In one possible implementation, when the graph matching device obtains the search space size of the first graph and the plurality of graphs to be matched, it can use a pre-trained neural network model; the pre-trained neural network model is called to determine the plurality of search space sizes respectively, and the neural network model is used to determine the search space size of the first graph and any one of the plurality of graphs based on the input first graph and any one of the plurality of graphs respectively.

[0010] The above method makes calculating the search space size using a neural network model simpler and more efficient. Furthermore, since the neural network model determines the search space size of the two input graphs, the search space size is set based on these two graphs, which better reflects their characteristics and ensures the accuracy of the search space size.

[0011] In one possible implementation, the graph edit distance can be calculated using the A*beamsearch algorithm when obtaining the edit distance from a first graph to multiple graphs based on multiple search space sizes. For example, for the transformation from the first graph to any one of the multiple graphs, the beam size in the A*beamsearch algorithm can be set according to the search space size of the first graph and any one of the multiple graphs, and the A*beamsearch algorithm with the set size can be called to calculate the edit distance from the first graph to any one of the multiple graphs.

[0012] Using the above method, the A*beamsearch algorithm for beam size was set. Since beam size better matches the characteristics of the two input graphs, the *beamsearch algorithm is more accurate in calculating the graph edit distance from the first graph to any of the multiple graphs.

[0013] In one possible implementation, when calculating the graph edit distance from the first graph to any one of the multiple graphs, the estimated cost and matching cost of the transformation from the first graph to any one of the multiple graphs can be calculated separately. Then, the graph edit distance from the first graph to any one of the multiple graphs is determined based on the estimated cost and matching cost. Here, the matching cost is the edit cost of matched points in the first graph and any one of the multiple graphs; the estimated cost is the estimated edit cost of unmatched points in the first graph and any one of the multiple graphs, and this estimated cost is essentially an estimate.

[0014] The above method simplifies the calculation of graph edit distance and ensures its efficiency.

[0015] In one possible implementation, the estimated cost can be calculated by the A*beamsearch algorithm or by calling a pre-trained neural network model. The neural network model here can be a different model from the neural network model that calculates the search space size, or it can be the same model. That is, the model has two functions: the search space size calculation function and the estimated cost calculation function.

[0016] Using the above method, the estimated cost can be calculated with the help of a neural network model, making the calculation simpler and more efficient.

[0017] In one possible implementation, the first diagram and any one of the multiple diagrams are used to indicate multiple objects and the relationships between them. The multiple objects indicated by any one of the multiple diagrams and the first diagram can be completely identical or partially identical. The relationships between the same objects indicated by any one of the multiple diagrams and the first diagram can be completely different or not completely identical.

[0018] The method described above does not limit the similarity between the first image and any of the multiple images. The method provided in this application is applicable to image matching scenarios with varying degrees of similarity, and the scenarios are quite broad.

[0019] In one possible implementation, the first figure and any of the plurality of figures can represent a compound, such as a chemical reagent, drug, etc. Each object in the figure represents a chemical component or chemical element.

[0020] Using the methods described above, graph matching can be applied to the field of chemistry to find identical or similar compounds.

[0021] In one possible implementation, the plurality of graphs includes a second graph and a third graph. The plurality of search space dimensions determined by the graph matching device include a first search space dimension and a second search space dimension. The first search space dimension is used to indicate the maximum number of edit paths from the first graph to the second graph in the plurality of graphs, and the second search space dimension is used to indicate the maximum number of edit paths from the first graph to the third graph in the plurality of graphs. The first search space dimension and the second search space dimension are different. When the graph matching device obtains the edit distance from the first graph to the plurality of graphs based on the plurality of search space dimensions, it can calculate the graph edit distance between the first graph and the second graph based on the first search space dimension; it can calculate the graph edit distance between the first graph and the third graph based on the second search space dimension.

[0022] Using the above method, the graph matching device can specifically calculate the search space size and graph editing distance for the first graph and any one of the plurality of graphs.

[0023] Secondly, embodiments of this application also provide a graph matching device that performs the behaviors described in the method examples of the first aspect. The beneficial effects are described in the first aspect description and will not be repeated here. The functions can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the aforementioned functions. In one possible design, the device structure includes a search space size calculation module, a graph editing distance calculation module, and a target graph determination module. These modules can perform the corresponding functions in the method examples of the first aspect, as detailed in the method examples and will not be repeated here.

[0024] Thirdly, this application also provides a computing device, which includes a processor and a memory, and may further include a communication interface. The processor executes program instructions in the memory to perform the method provided in the first aspect or any possible implementation thereof. The memory is coupled to the processor and stores program instructions and data necessary for determining the graph matching process. The communication interface is used to communicate with other devices, such as acquiring a first graph and multiple graphs to be matched.

[0025] Fourthly, this application provides a computing device system including at least one computing device. Each computing device includes a memory and a processor. The processor of at least one computing device is used to access code in the memory to execute the methods provided in the first aspect or any possible implementation thereof.

[0026] Fifthly, this application provides a computer-readable storage medium that, when executed by a computing device, performs the method provided in the first aspect or any possible implementation thereof. The storage medium stores a program. The storage medium includes, but is not limited to, volatile memory, such as random access memory, and non-volatile memory, such as flash memory, hard disk drive (HDD), and solid-state drive (SSD).

[0027] Sixthly, this application provides a computing device program product, which includes computer instructions that, when executed by a computing device, enable the computing device to perform the methods provided in the first aspect or any possible implementation thereof. The computer program product can be a software installation package, which can be downloaded and executed on a computing device when the methods provided in the first aspect or any possible implementation thereof are required.

[0028] In a seventh aspect, this application also provides a computer chip connected to a memory, the chip being used to read and execute a software program stored in the memory, and to execute the methods described in the first aspect and various possible implementations of the first aspect. Attached Figure Description

[0029] Figure 1 A schematic diagram of the system architecture provided in this application;

[0030] Figures 2A-2B A schematic diagram of the system architecture provided in this application;

[0031] Figure 3A flowchart of a graph matching method provided in this application;

[0032] Figure 4A A schematic diagram of a graph matching method provided in this application;

[0033] Figure 4B A schematic diagram of a training process provided for this application;

[0034] Figure 4C This is a schematic diagram of a subgraph pair generation method provided in this application;

[0035] Figure 5 A schematic diagram of a graph matching device provided in this application;

[0036] Figures 6-7 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation

[0037] Before describing the graph matching method provided in the embodiments of this application, the concepts involved in this application will be explained:

[0038] (1) Editing path, image editing distance

[0039] For two graphs, the sequence of operations required to transform one graph into the other, arranged in the order of operations, is called the edit path. Thus, the graph edit distance can be understood as the number of operations in the shortest sequence of operations in the edit path.

[0040] There are six types of operations required to transform one graph into another: adding nodes, deleting nodes, replacing nodes (also known as changing node labels), adding edges, deleting edges, and changing edge labels.

[0041] For the three operations on edges—adding edges, deleting edges, and changing edge labels—the operations on edges can usually be determined after the changes to nodes (such as adding nodes, deleting nodes, and replacing nodes) are determined. Therefore, in this embodiment, only the changes to nodes need to be considered.

[0042] (2) Matched nodes

[0043] A matching node is a node in one graph that has a substitution relationship with a node in another graph during the transformation process. For example, when Graph 1 is transformed into Graph 2, node A in Graph 1 is replaced by node B in Graph 2. Therefore, node A and node B have a substitution relationship and are considered matching nodes. Similarly, when Graph 1 is transformed into Graph 2, node C in Graph 1 is deleted. Therefore, Graph 2 can be considered to have an empty node (a node that does not actually exist). Node C in Graph 1 and the empty node in Graph 2 have a substitution relationship and are considered matching nodes. Furthermore, when Graph 1 is transformed into Graph 2, a new node D is added to Graph 2. Therefore, Graph 1 can be considered to have an empty node. The empty node in Graph 1 and node D in Graph 2 have a substitution relationship and are considered matching nodes.

[0044] (3) Editing cost, candidate editing cost, candidate image edit distance

[0045] In the process of transforming one graph into another, each operation incurs a cost. The editing cost can be understood as the sum of the costs of all operations. In other words, the editing cost reflects, to some extent, the number of operations used in the graph transformation. The editing cost can be divided into the cost of operations on nodes and the cost of operations on edges. In this embodiment, the editing cost may only consider the cost of operations on nodes; when only node operations are considered, the cost of one operation on a node can be considered to be 1. Thus, the value of the editing cost can be considered to be the same as the number of operations on the editing path, and the minimum editing cost is the graph editing distance.

[0046] In this embodiment, to determine the edit distance, multiple iterations are performed on the two graphs. In each iteration, points in the two graphs are matched. For the matched points, the edit cost of the matched points in both graphs is calculated, which is the cost of the matched points in the two graphs during the transformation process. For the remaining unmatched points, the edit cost of the unmatched points in the two graphs during the transformation process is estimated, which is also the cost of the unmatched points in the two graphs during the transformation process. To distinguish between the two different edit costs, the edit cost of the matched points in the two graphs is called the matching cost; the edit cost of the unmatched points in the two graphs is called the estimated cost. The estimated cost is an estimate, not an exact value.

[0047] In each iteration, the sum of the matching cost and the estimated cost is called the candidate edit cost. The candidate graph edit distance can be obtained from the candidate edit cost. Without considering operations on opposite edges, the candidate edit cost can numerically equal the candidate graph edit distance. Multiple candidate edit costs can be obtained in each iteration, and the candidate graph edit distance determined by the minimum candidate edit cost obtained over multiple iterations is the graph edit distance.

[0048] (4) Graph embedding

[0049] Graph embedding vectors characterize the features of a graph, such as the nodes and the relationships between them. Graph embedding vectors can be obtained by weighted summation of the features of each node, such as by weighted summation of node embeddings. These node features include, but are not limited to, the node's location and its relationships with neighboring nodes (first-level neighbors are nodes reachable by the node within one hop). In scenarios involving calculating graph edit distance, the features represented by a graph embedding vector can also include the matching relationships between nodes in one graph and nodes in another graph.

[0050] The embodiments of this application do not limit the calculation method of the graph embedding vector. Any vector that can be calculated to represent the features of each node in the graph is applicable to the embodiments of this application. For the specific calculation method of the graph embedding vector, please refer to the relevant descriptions of steps 302 and 404.

[0051] (5) Search space size, also known as beam size

[0052] The search space size defines the size of the search space between two graphs during the transformation process. Specifically, it limits the maximum number of edit paths (or candidate edit costs) that can be retained during the transformation when calculating the graph edit distance between two graphs. By limiting the search space size, the computational cost of calculating the graph edit distance between two graphs can be limited.

[0053] like Figure 1 The diagram shown is a system architecture diagram provided in an embodiment of this application. The system includes a graph matching device 100 and a client 200.

[0054] The client 200 can be deployed close to the user. The user can operate the client 200 to send a request to the graph matching device 100, requesting the graph matching device 100 to determine the target graph that best matches the first graph to be matched from multiple graphs (that is, the graph with the smallest graph editing distance to the first graph among the multiple graphs). The user can also send the first graph and the multiple graphs to the graph matching device 100 by operating the client 200. It should be noted that if the graph matching device 100 has already pre-stored the multiple graphs, such as multiple graphs forming a graph library, it can be pre-stored in the graph matching device 100 or in a device that the graph matching device 100 can interact with. The user can also provide the first graph to the graph matching device 100 through the client 200 and indicate the identifier of the multiple graphs or the identifier of the graph library in which the multiple graphs are located, so that the graph matching device 100 can determine the multiple graphs according to the indication.

[0055] The specific form of the client 200 is not limited in the embodiments of this application. For example, the client 200 can be a client program running on a computing device, such as a browser, or a dedicated application designed for graphs. The client 200 can also be a physical device, such as a computing device deployed on the user side.

[0056] The graph matching device 100 can execute the graph matching method provided in the embodiments of this application. The graph matching device 100 can analyze the first graph and the plurality of graphs, and determine the search space size of the first graph and the plurality of graphs respectively. Then, it determines the graph edit distance between the first graph and the plurality of graphs based on the plurality of search space sizes. Then, it determines the graph with the smallest graph edit distance to the first graph from the plurality of graphs as the graph that best matches the first graph.

[0057] The graph matching device 100 can be a hardware device, such as a server or terminal computing device, or a software device, specifically a software system running on a hardware computing device. The location of the graph matching device 100 is not limited in this embodiment. For example, Figure 2A As shown, the matching device 100 can run on a cloud computing device system (including at least one cloud computing device, such as a server), or on an edge computing device system (including at least one edge computing device, such as a server, desktop computer, etc.), or on various terminal computing devices, such as laptops, personal desktop computers, etc.

[0058] The graph matching device 100 can logically be a device composed of multiple parts. For example, the graph matching device 100 may include a search space size calculation module, a graph editing distance calculation module (the graph editing distance calculation module may include an estimation cost calculation module and a matching cost calculation module), and a target graph determination module. Each component of the graph matching device 100 can be deployed in different systems or servers. For example, Figure 2B As shown, the various parts of the device can operate in one of three environments: a cloud computing device system, an edge computing device system, or a terminal computing device, or in any two of these environments. The cloud computing device system, the edge computing device system, and the terminal computing device are connected by a communication path, enabling them to communicate and transmit data with each other. The graph matching method provided in this embodiment is executed by the combined parts of the graph matching device 100 operating in the three environments (or any two of the three environments).

[0059] The following is in conjunction with the appendix Figure 3 The graph matching method provided in this application embodiment will be described. This method can be executed by the graph matching device 100, and the method includes:

[0060] Step 301: The graph matching device 100 acquires the first graph and multiple graphs to be matched. To facilitate the distinction between the first graph and the multiple graphs to be matched, each graph to be matched is referred to as a candidate graph.

[0061] For example, a user can perform operations on the client 200, such as inputting a first image and multiple candidate images for graph matching, or selecting a first image and multiple candidate images from a graph library. The client 200 can include the first image and multiple candidate images in the graph matching request (e.g., the first image and multiple candidate images are input by the user, or the first image and multiple candidate images are not pre-stored in the graph matching device 100), or include the identifiers of the first image and multiple candidate images in the graph matching request (e.g., the first image and multiple candidate images are selected by the user from a graph library, or the first image and multiple candidate images are pre-stored in the graph matching device 100, or the first image and multiple candidate images are obtained by the graph matching device 100 from other devices through the identifiers of the first image and multiple candidate images), and initiate a graph matching request to the graph matching device 100.

[0062] After receiving a graph matching request, the graph matching device 100 can determine the first graph and multiple candidate graphs based on the graph matching request.

[0063] For example, a user can perform operations on the client 200, such as selecting a first image and a library of multiple candidate images; the client 200 can carry the identifiers of the first image and the library in the image matching request and send an image matching request to the image matching device 100.

[0064] After receiving a graph matching request, the graph matching device 100 can determine the first graph and the plurality of candidate graphs based on the graph matching request.

[0065] The above-described method of obtaining the first image and multiple candidate images by the graph matching device 100 is merely an example. This application does not limit the method of obtaining the first image and multiple candidate images by the graph matching device 100. For example, the user can directly operate the graph matching device 100, input the first image and multiple candidate images into the graph matching device 100, or directly select the first image and multiple candidate images through the graph matching device 100.

[0066] Step 302: After acquiring the first graph and multiple candidate graphs, the graph matching device 100 acquires the search space size of the first graph and multiple candidate graphs respectively; that is, for the first graph and any candidate graph, the graph matching device 100 can determine the search space size of the first graph and the candidate graph; each candidate graph and the first graph can determine a search space size, so the graph matching device 100 can determine multiple search space sizes.

[0067] For example, the candidate graphs include a second graph and a third graph. The graph matching device 100 can determine the first search space size of the first graph and the second graph, as well as the first search space size of the first graph and the third graph, respectively. The first search space size indicates the maximum number of edit paths from the first graph to the second graph, and the second search space size indicates the maximum number of edit paths from the first graph to the third graph. The first search space size and the second search space size can be different.

[0068] Clearly, as can be seen from step 302, the search space size is no longer fixed for different graphs, but can be flexibly changed; different search space sizes can be determined based on different candidate graphs.

[0069] The following example, using a candidate graph, illustrates how to determine the search space size for the first graph and the candidate graphs. The specific steps include:

[0070] Step 3021: The graph matching device 100 determines the graph embedding vectors of the first graph and the candidate graph.

[0071] The following uses the first figure as an example to illustrate a graph embedding vector determination method provided in this application embodiment:

[0072] First, a graph isomorphism network (GIN) can be used to analyze node J in the first graph. i The analysis yields the node vector J of that node. i (k) .

[0073]

[0074] in, For a fully connected neural network layer, ∈ (k) It is a learnable parameter or a fixed value used to represent the weight of a node's self-loop. W(i) represents the vectorized representation of nodes in the graph isomorphic network layer above, and represents the set of numbers of each neighbor node in the first graph.

[0075] Next, we can determine node h in the first graph. i Replacement vectors between nodes in the candidate graph

[0076]

[0077] Where W2 is the set of node numbers in the candidate graph, J l (k-1) For node J in the candidate graph of the upper-level graph isomorphic network layer l The vectorized representation of G can be a node J in the first graph. i With node J in the candidate graph l The replacement weights can be determined in advance based on experience or learning of the graph.

[0078] Next, node J i replacement vector Update the node vector J to node Ji i (k) middle.

[0079]

[0080] Then, the updated node vectors of each node in the first graph are summed to generate the graph embedding vector J1 of the first graph.

[0081]

[0082] Among them, R i This is J i The configured weights can be preset or obtained by learning from the graph.

[0083] It should be noted that the above method of calculating graph embedding vectors is only an example. After determining the graph embedding vectors of the first graph and the candidate graphs, step 3022 can be executed.

[0084] Step 3022: The graph matching device 100 determines the search space size of the first graph and the candidate graph based on the graph embedding vectors of the first graph and the candidate graph.

[0085] Since the graph embedding vector of the first graph can characterize the features of each node in the first graph to a certain extent, and the graph embedding vector of the candidate graph can characterize the features of each node in the candidate graph to a certain extent, by analyzing the graph embedding vectors of the first graph and the candidate graph, the relationship between each node in the first graph and each node in the candidate graph can be determined. Thus, the most suitable search space size for calculating the graph edit distance for the first graph and the candidate graph can be determined.

[0086] Step 302 can be performed by a module of the graph matching device 100, which will be described below.

[0087] Step 303: The graph matching device 100 can obtain the graph edit distance from the first graph to the multiple candidate graphs based on multiple search space dimensions. For the first graph and each candidate graph, the graph matching device 100 can obtain the graph edit distance from the first graph to the candidate graph based on the search space between the first graph and the candidate graph.

[0088] The graph matching device 100 obtains the graph edit distance from the first graph to each candidate graph in a similar way. The following explanation uses the method of obtaining the graph edit distance between the first graph and one of the candidate graphs as an example.

[0089] The graph matching device 100 performs multiple rounds of iteration on the first graph and the candidate graph based on the search space size of the first graph and the candidate graph, until there are no nodes in the first graph and the candidate graph that need to be matched, and then stops the iteration.

[0090] In each iteration, at least one node in the first graph and the candidate graphs is matched, and the candidate edit cost is calculated. In this embodiment, since only the cost of operations on points is considered, the number of candidate edit costs is the same as the number of edit paths. Therefore, the number of candidate edit costs allowed to be retained in each round can be equal to the search space size. The first graph and the candidate graph matched in each iteration include the node matched when the minimum candidate edit cost was obtained in the previous iteration.

[0091] The following uses the first three iterations in a multi-round iterative process as an example to illustrate the calculation method in each iteration and the relationship between adjacent iterations:

[0092] First iteration:

[0093] First, select a node in the first graph. Here, we take node 0 in the first graph as an example. Match node 0 in the first graph with each node in the candidate graph. For each matching node in the candidate graph, calculate the candidate edit cost when node 0 in the first graph matches a node in the candidate graph.

[0094] For example, node 0 in the first graph can be matched with node 0 in the candidate graph. If node 0 in the first graph matches node 0 in the candidate graph, the matching cost between node 0 in the first graph and node 0 in the candidate graph is calculated, and the estimated cost between nodes in the first graph (excluding node 0) and nodes in the candidate graph (excluding node 0) is also estimated. Alternatively, in this embodiment of the invention, the estimated cost is the estimated editing cost of unmatched points in either the first graph or any of the plurality of graphs. The sum of the matching cost and the estimated cost is the candidate editing cost if node 0 in the first graph matches node 0 in the candidate graph. The candidate editing cost can be numerically equal to the candidate editing distance.

[0095] If node 0 in the first graph can be matched with node 1 in the candidate graph, the matching cost between node 0 in the first graph and node 1 in the candidate graph is calculated, and the estimated cost between nodes other than node 0 in the first graph and nodes other than node 1 in the candidate graph is estimated. The sum of the matching cost and the estimated cost is the candidate editing cost when node 0 in the first graph matches node 1 in the candidate graph.

[0096] The matching process for this round of iterations stops when node 0 of the first graph has been matched with all nodes of the candidate graph.

[0097] After the matching process is complete, multiple candidate edit costs can be obtained, and the Q candidate edit costs with the smallest values ​​are retained. Here, Q is the search space size.

[0098] In the first iteration, the candidate node with the minimum edit cost is selected. The nodes that match in the first and candidate graphs when the minimum edit cost is obtained are then included as a subset of the nodes matched in the second iteration. For example, if calculations show that the minimum edit cost is obtained when node 0 in the first graph matches node 0 in the candidate graph, then in the next iteration, node 0 in the first graph and node 0 in the candidate graph are considered as matched nodes.

[0099] Second iteration:

[0100] First, the nodes that match in the first graph and the candidate graph when the minimum candidate edit cost is obtained in the first round of iteration are taken as the matched nodes. For example, the nodes that match in the first graph and the candidate graph when the minimum candidate edit cost is obtained are node 0 in the first graph and node 0 in the candidate graph.

[0101] Select a node in the first graph other than node 0. Here, we take node 1 in the first graph as an example. Match node 1 in the first graph with each node in the candidate graph other than node 0. For each matching node in the candidate graph, calculate the candidate edit cost when matching node 1 in the first graph with a node in the candidate graph.

[0102] For example, node 1 in the first graph can be matched with node 1 in the candidate graph. When node 1 in the first graph matches node 1 in the candidate graph, the matching cost between node 0 and node 1 in the first graph and node 0 and node 1 in the candidate graph is calculated, and the estimated cost between nodes other than node 0 and node 1 in the first graph and nodes other than node 0 and node 1 in the candidate graph is estimated. The sum of the matching cost and the estimated cost is the candidate editing cost when node 0 in the first graph matches node 0 in the candidate graph and when node 1 in the first graph matches node 1 in the candidate graph.

[0103] If node 1 in the first graph can be matched with node 2 in the candidate graph, then when node 1 in the first graph matches node 2 in the candidate graph, calculate the matching cost between node 0 and node 1 in the first graph and node 0 and node 2 in the candidate graph, and estimate the estimated cost between nodes other than node 0 and node 1 in the first graph and nodes other than node 0 and node 2 in the candidate graph. The sum of the matching cost and the estimated cost is the candidate editing cost when node 0 in the first graph matches node 0 in the candidate graph and when node 1 in the first graph matches node 2 in the candidate graph.

[0104] The matching process for this round of iterations stops when node 1 in the first graph has been matched with all nodes in the candidate graph except node 0.

[0105] After the matching process is complete, multiple candidate edit costs can be obtained, including the Q smallest candidate edit costs among the multiple candidate edit costs retained in the first iteration and the multiple candidate edit costs obtained in this iteration. Here, Q is the search space size.

[0106] The candidate edit cost with the minimum value is selected from the remaining Q candidate edit costs. The nodes that match in the first graph and the candidate graphs when the minimum candidate edit cost is obtained are considered as part of the nodes matched in the third iteration. For example, calculations show that the minimum candidate edit cost is obtained when node 0 in the first graph matches node 0 in the candidate graph, and node 1 in the first graph matches node 2 in the candidate graph. Therefore, in the next iteration, node 0 in the first graph and node 0 in the candidate graph, and node 1 in the first graph and node 2 in the candidate graph, are considered as the nodes matched in the next iteration.

[0107] Third iteration:

[0108] First, the nodes that match in the first graph and the candidate graph when the minimum candidate edit cost is obtained in the first two iterations are taken as the matched nodes. For example, the nodes that match in the first graph and the candidate graph when the minimum candidate edit cost is obtained are node 0 of the first graph and node 0 of the candidate graph, as well as node 1 of the first graph and node 2 of the candidate graph.

[0109] Select one node from the first graph other than node 0 and node 1. Here, we take node 2 from the first graph as an example. Match node 2 from the first graph with each node in the candidate graph other than node 0 and node 2. For each node in the candidate graph that is matched, calculate the candidate edit cost when node 2 from the first graph is matched with a node in the candidate graph.

[0110] If node 2 in the first graph can be matched with node 1 in the candidate graph, and node 1 in the first graph matches node 1 in the candidate graph, the matching cost between node 0, node 1, and node 2 in the first graph and node 0, node 2, and node 1 in the candidate graph is calculated. The matching cost is equal to the sum of the editing cost of converting node 0 in the first graph to node 0 in the candidate graph, the editing cost of converting node 1 in the first graph to node 2 in the candidate graph, and the editing cost of converting node 2 in the first graph to node 2 in the candidate graph.

[0111] The estimated cost is calculated for nodes in the first graph other than nodes 0, 1, and 2, and nodes in the candidate graph other than nodes 0, 2, and 1. The sum of the matching cost and the estimated cost is the candidate editing cost when node 0 in the first graph matches node 0 in the candidate graph, node 1 in the first graph matches node 2 in the candidate graph, and node 2 in the first graph matches node 1 in the candidate graph.

[0112] If node 2 in the first graph can be matched with node 3 in the candidate graph, and node 2 in the first graph matches node 3 in the candidate graph, calculate the matching cost between node 0, node 1, and node 2 in the first graph and node 0, node 2, and node 3 in the candidate graph. The matching cost is equal to the sum of the editing cost of converting node 0 in the first graph to node 0 in the candidate graph, the editing cost of converting node 1 in the first graph to node 2 in the candidate graph, and the editing cost of converting node 2 in the first graph to node 3 in the candidate graph.

[0113] The estimated cost is calculated for nodes in the first graph other than nodes 0, 1, and 2, and nodes in the candidate graph other than nodes 0, 2, and 3. The sum of the matching cost and the estimated cost is the candidate editing cost when node 0 in the first graph matches node 0 in the candidate graph, node 1 in the first graph matches node 2 in the candidate graph, and node 2 in the first graph matches node 3 in the candidate graph.

[0114] The matching process for this round of iterations stops when node 2 in the first graph has been matched with all nodes in the candidate graph except for node 0 and node 2.

[0115] After the matching process is complete, multiple candidate edit costs can be obtained. The Q candidate edit costs with the smallest values ​​are selected from the candidate edit costs retained in the first two iterations and the candidate edit costs obtained in this current iteration. Here, Q is the search space size.

[0116] The candidate edit cost with the minimum value is selected from the remaining Q candidate edit costs. The nodes that match in the first graph and the candidate graphs when the minimum candidate edit cost is obtained are considered as part of the nodes matched in the fourth iteration. For example, calculations show that the minimum candidate edit cost is obtained when node 0 in the first graph matches node 0 in the candidate graph, node 1 in the first graph matches node 2 in the candidate graph, and node 2 in the first graph matches node 3 in the candidate graph. Therefore, in the next iteration, nodes 0 in the first graph and node 0 in the candidate graph, nodes 1 in the first graph and node 2 in the candidate graph, and nodes 2 in the first graph and node 3 in the candidate graph are considered as matched nodes.

[0117] It should be noted that when the number of nodes in the first graph and the candidate graph are inconsistent (e.g., the number of nodes in the first graph is greater than the number of nodes in the candidate graph), one or more blank nodes can be virtually created in the candidate graph. These blank nodes can represent nodes that need to be deleted. When a node in the first graph matches a blank node in the candidate graph, it means that the node in the first graph needs to be deleted. Conversely, if the number of nodes in the first graph is less than the number of nodes in the candidate graph, one or more blank nodes can be virtually created in the first graph. These blank nodes can represent nodes that need to be added. When a blank node in the first graph matches a node in the candidate graph, it means that the node in the first graph needs to be added.

[0118] The iteration stops when there are no more matching nodes in the first graph and the candidate graph.

[0119] After the final iteration, the edit distance determined by the smallest edit cost among the Q remaining candidate edit costs is the graph edit distance between the first graph and the candidate graphs.

[0120] Step 304: The graph matching device 100 can determine the graph with the smallest graph editing distance to the first graph from multiple candidate graphs as the target graph to match the first graph.

[0121] Using the above method, we can determine the first image that best matches from among the multiple candidate images, that is, the image with the highest similarity.

[0122] After determining the target image, the image matching device 100 can display the target image to the user through the client 200.

[0123] It should be noted that the method provided in the embodiments of this application can be used to select the graph that best matches the first graph from multiple candidate graphs in the above description. The method provided in the embodiments of this application can also be applied to other scenarios, such as in the scenario of determining graph similarity; the graph matching device 100 can calculate the graph edit distance of multiple sets of graphs, each set of graphs includes two graphs, and the graph matching device 100 can determine the graph edit distance of the two graphs in each set of graphs. Since the graph edit distance can reflect the similarity of the set of graphs, that is, when the graph edit distance of multiple sets of graphs is calculated, the similarity of the two graphs in each set of graphs can be determined accordingly; when the graph matching device 100 calculates the graph edit distance of a new set of graphs, it can compare it with the graph edit distance of the previous multiple sets of graphs, and then determine the similarity of the two graphs in the new set of graphs.

[0124] For example, the graph matching device 100 constructs multiple sets of graphs using a first graph and multiple reference graphs, each set including the first graph and a reference graph. The graph matching device 100 can obtain the search space size of each set of graphs, obtain the graph edit distance of that set based on the search space size, and determine the similarity of each set of graphs based on the graph edit distance. Then, the graph matching device 100 calculates the graph edit distance of a new set of graphs in a similar manner, this new set including the first graph and candidate graphs. For a set of graphs (including the first graph and reference graphs) whose graph edit distance is the same as or close to the graph edit distance of the new set, it indicates that the similarity between the first graph and the reference graph in this set is consistent with the similarity between the first graph and the candidate graph in the new set, and also indicates that the reference graph in this set has a high similarity to the candidate graph in the new set.

[0125] In this embodiment, steps 302 and 303 can be executed using modules in the graph matching device 100. For ease of explanation, the module executing step 302 is referred to as the search space size calculation module. This search space size calculation module can be pre-trained, such as a neural network model.

[0126] The training process for the search space size calculation module is described below:

[0127] Step 401: Determine graphs G1 and G2 from the training set. Graphs G1 and G2 in the training set have been matched, and the matching nodes in graphs G1 and G2 have been determined.

[0128] Step 402: Determine multiple sets of subgraphs based on graphs G1 and G2. Each set of subgraphs includes two subgraphs, one of which is a subgraph of graph G1 and the other is a subgraph of graph G2.

[0129] The following describes a method for generating multiple sets of subgraphs:

[0130] First, select a node in graph G1 and a node in graph G2 that matches a node in graph G1, and replace both of these nodes with supernodes. Supernodes can be connected to any node in their respective graphs.

[0131] Then, for each set of matching nodes deleted from graph G1 and graph G2, a subgraph is generated. This continues until there are no more nodes to delete in graph G1 and graph G2.

[0132] Step 403: For each group of subgraphs, predetermine the search space size corresponding to that group of subgraphs.

[0133] The embodiments of this application do not limit the method of determining the search space size corresponding to the group of subgraphs. For example, the A*beamsearch algorithm can be used in advance to calculate the graph edit distance based on different beam sizes. The beam size based on which the computational efficiency and accuracy are highest can be selected as the search space size corresponding to the group of subgraphs. Alternatively, the search space size corresponding to the group of subgraphs can be determined by an expert based on their experience.

[0134] For example, considering the computation time and error of graph edit distance calculation, under different requirements for computation time and error, the A*beamsearch algorithm is used to calculate the graph edit distance based on different beam sizes, determining the specific values ​​of computation time and error for different beam sizes. The computation time can be determined using the computation time of the A*beamsearch algorithm, and the error can be determined by comparing the A*beamsearch algorithm's calculation results with the actual graph edit distance. In this case, the purpose of training the search space size calculation module is to learn the correspondence between different beam sizes and the computation time and error of graph edit distance. In addition to the graph embedding vectors of the two graphs, the input to the search space size calculation module during training and testing also needs to be the computation time and error of the graph edit distance.

[0135] Step 404: Determine the graph embedding vector for each group of subgraphs.

[0136] The following uses subgraph G11 of graph G1 as an example to illustrate a graph embedding vector determination method provided in this application embodiment:

[0137] First, a graph isomorphism network can be used to analyze node i in subgraph G11 of graph G1 to obtain the node vector h of that node. i (k) .

[0138]

[0139] in, For a fully connected neural network layer, ∈ (k) h is a learnable parameter or a fixed value used to represent the weight of a node's self-loop. i (k-1) For the vectorized representation of nodes in the upper-level graph isomorphic network layer, N(i) represents node h in subgraph G11. i The set of IDs for each neighboring node.

[0140] Next, we can determine node h in subgraph G11. i Replacement vectors between nodes in subgraph G22 of graph G2

[0141]

[0142] Where W2 is the set of node numbers in the candidate graph, h l (k-1) For the candidate node h in the graph isomorphic network layer above l The vectorized representation of G can be a node h in the first graph. i With node h in the candidate graph l Replacement weights, This indicates that if node h in the first graph... i With node h in the candidate graph l If the match is found, the replacement weight is 0; otherwise, it is 1.

[0143] Then, node h i replacement vector Update the node vector h to node hi i (k) middle.

[0144]

[0145] Next, the updated node vectors of each node in subgraph G11 are summed to generate the graph embedding vector of subgraph G11.

[0146]

[0147] Where σ is the activation function, This refers to the transpose of the vectorized representation of node i. It refers to a similarity index in vector space. Let h represent the vectorized representation of the nodes in the k-th layer of the graph isomorphic network, and h iThis represents the vectorized representation of the last layer (i.e., the final) node.

[0148] Step 404: Input the graph embedding vector of each subgraph group into the search space size calculation module, and train the search space size calculation module using the search space size corresponding to each subgraph group until the search space size output by the search space size calculation module is closer to the predetermined search space size (i.e., the loss function converges).

[0149] It should be noted that, considering the graph edit distance calculation time and error, the search space size calculation module requires not only the graph embedding vector of each subgraph group but also the graph edit distance calculation time and error. The training objective is to make the search space size output by the search space size calculation module the same as or closer to the pre-determined search space size under the given graph edit distance calculation time and error (i.e., loss function convergence). This consideration of graph edit distance calculation time and error is merely an example; in actual training and computation, other features (such as computational efficiency) can be considered, or only the graph edit distance calculation time or error can be considered.

[0150] In this embodiment of the application, during step 302, it is also necessary to calculate the estimated cost of the graph in each iteration. This can also be performed using a module in the graph matching device 100. For ease of explanation, the module for calculating the estimated cost can be the estimated cost calculation module in the distance calculation module. This estimated cost calculation module can be pre-trained, such as a neural network model.

[0151] The training process of this cost estimation module is explained below:

[0152] Step 501: Determine graphs G1 and G2 from the training set. In the training set, the matching relationships between nodes in graphs G1 and G2 and the graph edit distance between graphs G1 and G2 have been predetermined.

[0153] Step 502: Determine multiple sets of subgraphs based on Figure G1 and Figure G2. For details, please refer to step 402; these will not be repeated here.

[0154] Step 503: Determine the graph embedding vector for each group of subgraphs. See step 404 for details; it will not be repeated here.

[0155] Step 504: Train the cost estimation module using the graph embedding vector of each subgraph and the graph edit distance between graph G1 and graph G2.

[0156] It should be noted that when training the cost estimation module, the target estimated cost can be determined using the graph edit distance between graphs G1 and G2. This target estimated cost is the target that the estimated cost output by the cost estimation module needs to approach. For example, the edit paths (edit paths involving operations on points) of graphs G1 and G2 can be deleted starting from the last operation. After deleting each operation, the edit distance corresponding to the remaining operations can be considered numerically equal to the matching cost, and the difference between the graph edit distance and the matching cost is numerically equal to the target estimated cost.

[0157] The loss function for the cost estimation module can be set as follows or transformed according to the following formula, where ε refers to the set of matching nodes and D refers to the set of subgraph pairs. It refers to the graph edit distance of the θ-th subgraph pair. This refers to the expected error between the graph edit distance and the ground truth for all graph pairs in the training set. The predicted graph edit distance is calculated as the difference between the graph embedding vectors of the two graphs. This gap can be represented by a neural tensor network layer and a fully connected network layer, and the transformed value represents the predicted graph editing distance.

[0158]

[0159] It should be noted that the search space size calculation module and the cost estimation calculation module can be two independent modules or the same module. In other words, after training, the module has both the search space size calculation function and the cost estimation calculation function.

[0160] During step 302, the matching cost of the graph also needs to be calculated in each iteration. This matching cost can be calculated using a module in the graph matching device 100. For ease of explanation, the module for calculating the matching cost can be the matching cost calculation module in the graph matching device 100. This matching cost calculation module can be constructed using the A* algorithm or the A*beasearch algorithm.

[0161] The following is in conjunction with the appendix Figures 4A-4C The graph matching method provided in this application is described in the context of its application in the field of chemistry. See [link to relevant documentation]. Figure 4A This application provides a flowchart of a graph matching method, which is divided into two parts: a training process and a testing process. The testing process can be executed after the training process is completed.

[0162] See Figure 4ADuring training, multiple subgraph pairs are first prepared for training, each pair consisting of two graphs. Then, existing algorithms such as A*beamsearch and graph isomorphic networks are used to analyze each subgraph pair to obtain a training set. Finally, the graph path networks (GPN) are trained based on the training set.

[0163] See Figure 4B The diagram illustrates the training process, which can be divided into two types: training on the search space size and training on the estimated cost. Figure 4B The GPN in this paper has both the function of calculating the search space size and the function of estimating the cost.

[0164] During the training process for the search space size, see [link / reference]. Figure 4C This is a method of decomposing drug molecule 1 and drug molecule 2 to generate multiple sets of sub-graph pairs.

[0165] First, the A* algorithm is used to generate the edit paths for drug molecule graph pairs, identifying matching nodes in drug molecule 1 and drug molecule 2, assuming there are N pairs of nodes with replacement relationships. Based on these replacement relationships, drug molecule 1 and drug molecule 2 are decomposed into N drug molecule subgraph pairs. Specifically, when a node in one of the two drug molecules matches, that matching node is deleted, and a supernode is added. This supernode is then connected to every node in that drug molecule, forming a connected graph, thus generating a set of drug molecule subgraph pairs.

[0166] Next, a graph embedding vector for each drug molecule's subgraph within the subgraph pair is generated. The graph embedding vector is equal to the weighted sum of the embedding vectors of each node, with each node's vector including a substitution vector. For the graph embedding vector of any drug molecule's subgraph, an initial embedding vector and substitution vector for each node in the drug molecule can be determined using a graph isomorphism network. The substitution vector is then updated to the node's initial embedding vector. The similarity between each node and its supernode in the drug molecule is calculated using cosine similarity or a multilayer fully connected network, and this similarity value is used as the node's weight coefficient. The weight coefficients of all nodes in the drug molecule are then weighted and summed with the node's updated initial embedding vector to obtain the final graph embedding vector for the drug molecule.

[0167] Next, the graph embedding vector of each drug molecule subgraph pair is input into the GPN. Other feature information, such as graph editing distance calculation time and calculation error, can also be input into the GPN. The GPN is then trained based on a pre-determined search space size for each subgraph pair.

[0168] During the training process for the search space size, the graph embedding vector of each drug molecule subgraph pair is input into the GPN, and the GPN is trained according to the pre-determined target estimation cost of each drug molecule subgraph pair.

[0169] See Figure 4A The testing process involves calculating the graph edit distance between two drug molecules. First, the GPN is called to determine the search space size of the two drug molecules (e.g., drug molecule A and drug molecule B). Then, this search space size is set as the beam size in the A*beamsearch algorithm. After that, the graph edit distance is calculated using the A*beamsearch algorithm. During the calculation of the graph edit distance, the GPN is called to calculate the estimated cost.

[0170] Based on the same inventive concept as the method embodiments, this application also provides a graph matching device for executing the method performed by the graph matching device 100 in the above method embodiments. For example... Figure 5 As shown, the graph matching device 500 includes a search space size calculation module 501, a graph editing distance calculation module 502, and a target graph determination module 503. Specifically, in the graph matching device, the modules are connected through a communication path.

[0171] The search space size calculation module 501 is used to obtain the search space size of the first image and the multiple images to be matched, respectively. Each image to be matched can determine a search space size; that is, the search space size calculation module 501 can obtain multiple search space sizes of the first image and the multiple images to be matched. These multiple search space sizes are not identical, and one of the search space sizes indicates the maximum number of edit paths required to transform from the first image to one of the multiple images. The search space size calculation module 501 can perform operations such as... Figure 3 Step 302 is shown.

[0172] The graph editing distance calculation module 502 is used to obtain the graph editing distance from the first graph to multiple graphs based on multiple search space dimensions. The graph editing distance calculation module can use the search space dimensions of the first graph and any one of the multiple graphs to obtain the graph editing distance from the first graph to any one of the multiple graphs. The graph editing distance calculation module 502 can perform the following... Figure 3 Step 303 is shown.

[0173] The target image determination module 503 is used to determine, from multiple images, the image with the smallest edit distance to the first image as the target image matching the first image. The target image determination module 503 can perform actions such as... Figure 3 Step 304 is shown.

[0174] As one possible implementation, when the search space size calculation module 501 obtains the search space size of the first image and the multiple images to be matched, it can use a pre-trained neural network model to determine the multiple search space sizes respectively. The neural network model is used to determine the search space size of the first image and any one of the multiple images based on the input first image and any one of the multiple images respectively.

[0175] As one possible implementation, when the graph edit distance calculation module 502 obtains the graph edit distance from the first graph to multiple graphs based on multiple search space sizes, for any graph from the first graph to any of the multiple graphs, it sets the A*beamsearch algorithm according to the search space size of the first graph and any of the multiple graphs, such as using the search space size of the first graph and any of the multiple graphs to set the beam size in the A*beamsearch algorithm. Then, it calls the set A*beamsearch algorithm to calculate the graph edit distance from the first graph to any of the multiple graphs.

[0176] As one possible implementation, the graph edit distance from the first graph to any one of the multiple graphs is determined based on the estimated cost of the transformation from the first graph to any one of the multiple graphs and the matching cost; wherein, the matching cost is the edit cost of the matched points in the first graph and any one of the multiple graphs; and the estimated cost is the estimated edit cost of the unmatched points in the first graph and any one of the multiple graphs.

[0177] As one possible implementation, the cost is estimated by calling a pre-trained neural network model.

[0178] As one possible implementation, the first figure and multiple figures are used to indicate multiple objects and the relationships between the multiple objects. The multiple figures and the first figure indicate the same objects, and the relationships between the same objects indicated by the multiple figures and the first figure are not completely the same.

[0179] As one possible implementation, each object is used to characterize a chemical component or chemical element.

[0180] The module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in the various embodiments of this application can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0181] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a terminal device (which may be a personal computer, mobile phone, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0182] This application also provides, for example Figure 6 The computing device 600 shown includes a bus 601, a processor 602, a communication interface 603, and a memory 604. The processor 602, the memory 604, and the communication interface 603 communicate with each other via the bus 601.

[0183] The processor 602 may be a central processing unit (CPU). The memory 604 may include volatile memory, such as random access memory (RAM). The memory 604 may also include non-volatile memory, such as read-only memory (ROM), flash memory, HDD, or SSD. The memory stores executable code, which the processor 602 executes to perform the aforementioned actions. Figure 3 The method described. The memory 604 may also include other software modules required for running processes, such as an operating system (as shown in the multiple modules in the matching device 500). The operating system may be LINUX. TM UNIX TM WINDOWS TM wait.

[0184] This application also provides a computing device system, the computing device system including at least one such as Figure 7The computing device 700 shown includes a bus 701, a processor 702, a communication interface 703, and a memory 704. The processor 702, memory 704, and communication interface 703 communicate with each other via the bus 701. At least one computing device 700 in the computing device system communicates with each other via a communication path.

[0185] The processor 702 may be a CPU. The memory 704 may include volatile memory, such as random access memory (RAM). The memory 704 may also include non-volatile memory, such as read-only memory (ROM), flash memory, HDD, or SSD. The memory 704 stores executable code, which the processor 702 executes to perform the aforementioned actions. Figure 3 The described method may include any part or all of it. The memory may also include other software modules required for running processes, such as the operating system. The operating system may be Linux. TM UNIX TM WINDOWS TM wait.

[0186] At least one computing device 700 in the computing device system establishes communication with each other through a communication network, and each computing device 700 runs any one or any multiple modules of the map matching device 500.

[0187] The descriptions of the processes corresponding to the above-mentioned figures each have their own emphasis. For parts of a process that are not described in detail, please refer to the relevant descriptions of other processes.

[0188] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, in the form of a computer program product. A computer program product includes computer program instructions, which, when loaded and executed on a computer, generate, in whole or in part, the product according to the embodiments of the present invention. Figure 3 The process or function described.

[0189] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., SSD).

[0190] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A graph matching method, characterized in that, The method includes: A first request is received, the first request being used to request the determination of a target graph that best matches the first graph from a plurality of graphs to be matched, wherein any one of the first graph and the plurality of graphs represents one of a compound, a social network, a road network, and a semantic network; In response to the first request, the search space size of the first graph and the plurality of graphs to be matched are obtained respectively to obtain a plurality of search space sizes, wherein the plurality of search space sizes are not completely identical, and one of the plurality of search space sizes is used to indicate the maximum number of edit paths from the first graph to one of the plurality of graphs; The graph edit distance from the first graph to each of the multiple graphs is obtained based on the multiple search space dimensions. The graph with the smallest graph edit distance to the first graph is determined from the plurality of graphs and is identified as the target graph that matches the first graph.

2. The method as described in claim 1, characterized in that, The step of obtaining the search space size of the first image and the multiple images to be matched includes: A pre-trained neural network model is invoked to determine the multiple search space sizes, wherein the neural network model is used to determine the search space size of the first graph and any one of the multiple graphs based on the input first graph and any one of the multiple graphs.

3. The method as described in claim 1 or 2, characterized in that, The step of obtaining the graph edit distance from the first graph to the multiple graphs based on the multiple search space sizes includes: For the transformation from the first image to any of the plurality of images, A is set according to the search space size of the first image and any of the plurality of images. The beamsearch algorithm, calling the configured A... The beamsearch algorithm calculates the graph edit distance from the first graph to any of the plurality of graphs.

4. The method as described in claim 3, characterized in that, The graph edit distance from the first graph to any one of the plurality of graphs is determined based on the estimated cost and matching cost of the transformation from the first graph to any one of the plurality of graphs; wherein, the matching cost is the edit cost of matched points in the first graph and any one of the plurality of graphs; and the estimated cost is the estimated edit cost of unmatched points in the first graph and any one of the plurality of graphs.

5. The method as described in claim 4, characterized in that, The estimated cost is calculated by calling a pre-trained neural network model.

6. The method according to any one of claims 1 to 5, characterized in that, The first diagram and the plurality of diagrams are used to indicate multiple objects and the relationships between the multiple objects. There are the same objects among the multiple objects indicated by the first diagram and the plurality of diagrams. The relationships between the same objects indicated by the multiple diagrams and the first diagram are not completely the same.

7. The method as described in claim 6, characterized in that, Each object is used to characterize a chemical component or chemical element.

8. A graph matching device, characterized in that, The device includes: The search space size calculation module is configured to receive a first request, which requests the determination of a target image that best matches a first image from a plurality of images to be matched, wherein any one of the first image and the plurality of images represents a compound, a social network, a road network, or a semantic network; in response to the first request, the module obtains the search space size of the first image and the plurality of images respectively to obtain a plurality of search space sizes, wherein the plurality of search space sizes are not completely identical, and one of the plurality of search space sizes is used to indicate the maximum number of edit paths from the first image to one of the plurality of images; The graph editing distance calculation module is used to obtain the graph editing distance from the first graph to the multiple graphs based on the multiple search space sizes; The target image determination module is used to determine the image with the smallest image editing distance to the first image from the plurality of images as the target image that matches the first image.

9. The apparatus as claimed in claim 8, characterized in that, When the search space size calculation module obtains the search space size of the first image and the multiple images to be matched, it is used for: A pre-trained neural network model is invoked to determine the multiple search space sizes, wherein the neural network model is used to determine the search space size of the first graph and any one of the multiple graphs based on the input first graph and any one of the multiple graphs.

10. The apparatus as claimed in claim 8 or 9, characterized in that, When the graph edit distance calculation module obtains the graph edit distance from the first graph to the multiple graphs based on the multiple search space sizes, it is used for: For the transformation from the first image to any of the plurality of images, A is set according to the search space size of the first image and any of the plurality of images. The beamsearch algorithm, calling the configured A... The beamsearch algorithm calculates the graph edit distance from the first graph to any of the plurality of graphs.

11. The apparatus as claimed in claim 10, characterized in that, The graph edit distance from the first graph to any one of the plurality of graphs is determined based on the estimated cost and matching cost of the transformation from the first graph to any one of the plurality of graphs; wherein, the matching cost is the edit cost of matched points in the first graph and any one of the plurality of graphs; and the estimated cost is the estimated edit cost of unmatched points in the first graph and any one of the plurality of graphs.

12. The apparatus as claimed in claim 11, characterized in that, The estimated cost is calculated by calling a pre-trained neural network model.

13. The apparatus according to any one of claims 8 to 12, characterized in that, The first diagram and the plurality of diagrams are used to indicate multiple objects and the relationships between the multiple objects. There are the same objects among the multiple objects indicated by the first diagram and the plurality of diagrams. The relationships between the same objects indicated by the multiple diagrams and the first diagram are not completely the same.

14. The apparatus as claimed in claim 13, characterized in that, Each object is used to characterize a chemical component or chemical element.

15. A computing device, characterized in that, The computing device includes a processor and memory; The memory is used to store computer program instructions; The processor executes computer program instructions in the memory to perform the method as described in any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that, When the computer-readable storage medium is executed by a computing device, the computing device performs the method according to any one of claims 1 to 7.