Graph similarity search method, device, computer-readable storage medium, and program
By setting the maximum similarity threshold and the lower bound estimation method of the largest common subgraph, the graph pairs in the graph database are screened, which solves the problems of slow graph similarity search and low candidate set filtering efficiency in the existing technology and realizes more efficient graph similarity search.
Patent Information
- Application Number
- CN202410540182.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2044-04-30
AI Technical Summary
Existing graph similarity search algorithms have slow calculation speed when processing complex graph data, and low efficiency in candidate set filtering, which affects the search speed.
By setting the maximum similarity threshold τmax, the graph edit distance GED of all graph pairs in the graph database is calculated, and the graph pairs with GED≤τmax are screened out to form a new graph database E. The maximum common subgraph MCS of each class is extracted, and the graph gi in the database E is preliminarily filtered using lbL(q, g)≤τ. The lower bound estimation method of MCS is combined to screen the candidate set to reduce the calculation of dissimilar graphs.
It improves the speed and efficiency of graph similarity search, reduces computational cost and mapping space, and can more efficiently screen out similar graphs, narrow the candidate set, and improve search performance.
Smart Images

Figure CN118445445B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph computing, and in particular to a graph similarity search method, device, computer-readable storage medium, and program. Background Art
[0002] Graph data is widely used in many fields, and searching for similar graphs in graph databases has become a fundamental operation. However, in real-world graph data, due to inconsistencies, natural noise, and the inevitable presence of different event representations, searching for graphs completely similar to the query graph may yield few or no results in many applications, which is insufficient for the application. Therefore, a straightforward solution is to search for graphs that are approximately identical—that is, to retrieve all graphs in the database that are similar to the query graph. This has recently been widely studied. Graph Edit Distance (GED), as a measure of graph similarity, is widely used because it is applicable to all types of graphs and can capture subtle structural differences. However, calculating GED has proven difficult to achieve in linear time when the graph data becomes complex. Consequently, optimizing graph similarity algorithms has garnered widespread attention in the industry.
[0003] In recent years, graph similarity search frameworks based on filtering and verification have become widely used. In the filtering phase, graphs in the database are filtered based on the characteristics of the query graph, and the remaining graphs form a candidate set that may be similar to the query graph. In the verification phase, the graphs in the candidate set are sequentially compared with the query graph to perform an accurate GED calculation. Finally, the graphs that meet the requirements are retained to form a result set similar to the query graph.
[0004] Sanfeliu et al. (A. Sanfeliu and K. Fu, “A distance measure between attributed relational graphs for pattern recognition,” IEEE Trans. Systems, Man, and Cybernetics, vol. 13, no. 3, pp. 353–362, 1983) proposed the concept of GED and used it to quantify the similarity between graphs. Zeng et al. (Zeng Z, Tung AKH, Wang J, et al. Comparing stars: On approximating graph edit distance [J]. Proceedings of the VLDB Endowment, 2009, 2(1): 25-36) proved that it is impossible to calculate the optimal result of GED in linear time. Therefore, many methods have been tried to optimize the calculation of GED. Inves (Kim J, Choi D H, Li C. Inves: Incremental Partitioning-Based Verification for Graph Similarity Search [C] / / EDBT. 2019: 229-240.) uses the information collected from partitioning to search the space of possible vertex mappings between graphs using a new method and the A*-GED algorithm to efficiently calculate their GED. AStar-LSa (L. Chang, X. Feng, X. Lin, L. Qin, W. Zhang and D. Ouyang, "Speeding Up GED Verification for Graph Similarity Search," 2020 IEEE 36th International Conference on Data Engineering (ICDE), Dallas, TX, USA, 2020, pp. 793-804.) directly uses the query graph to compare with the database. Figure 1A Star-LSa (AStar-LSa) performs GED verification calculations, and outperforms methods such as Inves. BMa (L. Chang, X. Feng, K. Yao, L. Qin and W. Zhang, "Accelerating Graph Similarity Search via Efficient GED Computation," in IEEE Transactions on Knowledge and Data Engineering, vol. 35, no. 5, pp. 4485-4498, May 2023) proposed an anchor-aware lower bound calculation method. Compared to AStar-LSa, it consumes less memory but takes more time. Therefore, they relaxed the lower bound and proposed BMao, achieving a balance between time and memory consumption. Nass (KIM J. Boosting graph similarity search through pre-computation [C] / / Proceedings of the 2021 International Conference on Management of Data. 2021: 951-963.) proposed a completely different approach. This approach precomputes the GED of all graph pairs in the database to construct an index table. During the search, the first graph similar to the query graph is found, and then this graph is used for a replacement query using the triangle inequality. Nass achieves simultaneous filtering and verification, significantly reducing the verification workload. However, the above methods still produce a large number of candidate sets, which affects the search speed.
[0005] Currently, the optimization of graph similarity search algorithms is still in the development stage. Existing technical methods have solved certain problems, but there is still a lot of room for improvement. How to improve the speed of graph similarity search and save the mapping space used during calculation is a future improvement direction. Summary of the Invention
[0006] The first object of the present invention is to provide a graph similarity search algorithm with better performance.
[0007] In order to achieve the above technical objectives, the present invention adopts the following scheme:
[0008] A graph similarity search method, comprising:
[0009] S1 sets the maximum similarity threshold τ max , calculate the graph edit distance GED of all graph pairs in the graph database and keep GED≤τ maxThe selected graphs form a new graph database E; the graph pairs with GED values within the range of τ1 are divided into one category, τ1≤τ max , and extract the maximum common subgraph MCS of each class j ;
[0010] S2 sets the query graph q and uses lb L (q, g)≤τ for graph g in database E i Perform preliminary filtering to obtain candidate set C:
[0011] lb L (q, g) = Γ(L V (q), L V (g))+Γ(L E (q), L E (g))
[0012] Where, L V (q) and L E (q) are the sets of vertices and edges of q, L V (g i ) and L E (g i ) are g i The set of vertices and edges of , Γ(A, B) = max(|A|, |B|) - (|A∩B|), |x| refers to the number of elements in the set x;
[0013] S3 Compute Query Graph q and MCS i The GED value ged(q, MCS i ), filter the classes constructed in S1 and remove lb MCS (q, MCS j )>τ class;
[0014] lb MCS (q, MCS j )=ged(q,MCS j )-||q|-| M CS j ||
[0015] For the remaining classes, for graphs g in the same class and in the candidate set C, i Screening: If ged(q, MCS i )-|g i |+|MCS i |>τ, g i Delete from the candidate set C, if ged(q, MCS j )+|g i |-|MCS j |≤τ, then g iAdd the result set res and delete it from the candidate set C;
[0016] S4 If C is not empty, search for the remaining elements in the candidate set C to obtain the final result set.
[0017] As a preferred implementation manner, in S1, after calculating the GED values of all graph pairs in the graph database, construct a GED index table, and perform category division by querying the GED values of the graph pairs in the GED index table.
[0018] As a preferred implementation manner, in S1, the classification method of the graph pairs is:
[0019] i) According to g i the number of graphs, establish an initial class Cl <关于图的数量建立初始类Cl i i in which each element is a graph whose GED value with g max is within τ;
[0020] ii) Classify the classes obtained in i) with τ1 as the threshold.
[0021] [[ID=Note]]在翻译过程中,原内容中“
[0022] ”这两行没有实际文本内容,所以翻译中也保留原样。“<关于图的数量建立初始类Cl”这部分内容似乎存在一些混淆或不完整的表述,按照要求保留原样。 Furthermore, in i), after establishing the initial classes, sort them in ascending order according to the number of graphs in each class, and delete duplicate classes.
[0022] Furthermore, in ii), after classification, perform union and intersection correction on the graph classes, including:
[0023] a) If there is an inclusion relationship A ∈ B between different classes A and B, then remove the A elements in class B to form a new class C;
[0024] b) Sort them in ascending order according to the size of the classes. When a graph in a class appears in a class with a higher order in the sorting, then remove the graph from the current class.
[0025] As a preferred implementation manner, in S4, when finding a graph g i in C whose GED value with q is less than τ, add the graph g i to the result set res and delete it from C, and use g i to replace q and continue to query for similar graphs.
[0026] Furthermore, let ged(q, g i [[ID=Note]]原内容中“)=δ≤τ”这部分表述不太清晰,可能存在格式问题,按照要求保留原样。 ) = δ ≤ τ, use g i to replace q and continue to query for similar graphs;
[0027] When ged(g <关于图的数量建立初始类Cl in C whose GED value with q is less than τ, add the graph g i max max max max max max max [[ID=6s]] i i i <000005z> max i i 10 [[ID=Note]]原内容中这部分存在较多不清晰或疑似错误的表述,按照要求保留原样。 10 11 <000
[0028] A second object of the present invention is to provide a computer device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above method.
[0029] A third object of the present invention is to provide a computer-readable storage medium having a computer program / instruction stored thereon, which implements the steps of the above method when the computer program / instruction is executed by a processor.
[0030] A fourth object of the present invention is to provide a computer program product comprising a computer program / instruction, which implements the steps of the above method when executed by a processor.
[0031] The present invention has the following beneficial effects:
[0032] (1) By reusing pre-calculation, the present invention divides the graphs in the database into classes and extracts the MCS of each class as a class label, thereby achieving better filtering effects and improving search performance during the query search phase. The present invention performs filtering by class rather than by individual graphs, thus achieving more efficient filtering.
[0033] (2) The present invention proposes a lower bound estimation method based on MCS, which plays a role in filtering dissimilar class graphs in the database. By using MCS to sort and filter class graphs, the similarity between the common structure of the class graphs and the query graph is taken into account. This can achieve the purpose of screening without having to compare each graph one by one, thereby improving the overall performance of graph similarity search. In addition, the lower bound estimation method based on MCS can also determine the order of calculation with each type of graph, and pre-screen certain dissimilar graphs without performing GED calculations, thereby determining part of the result set in advance, thereby achieving the purpose of narrowing the candidate set.
[0034] (3) The present invention can reduce the search time, reduce the computational cost and save the computational space. At the same time, any GED computation algorithm can be embedded. Only a small amount of modification is required to the relevant algorithm to improve its performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is the example database D used in the present invention.
[0036] Figure 2 For the present invention, τ is set max = 9, all graphs in D are GED in τ max Index table within.
[0037] Figure 3 The present invention is based on maxFor the classification constructed for the example database D, the graphs in the class are all GED with respect to each other within τ max Inside.
[0038] Figure 4 It is the largest common subgraph extracted by the present invention for each category.
[0039] Figure 5 This is a graph similarity search framework based on the maximum common subgraph of the present invention.
[0040] Figure 6 is the query graph used in the embodiment. DETAILED DESCRIPTION
[0041] The technical solution of the present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.
[0042] The specific technical solutions adopted in the present invention are as follows:
[0043] 1. Set the maximum similarity threshold to τ max , and calculate the graph database D (see Figure 1 ) and the GED values of all other graphs. Each graph in the database has a label of points and edges, and the GED values of the graph can be calculated in an acceptable time and in τ max The GED values and corresponding graph IDs in the database are filtered out to form a new database E. Each graph corresponds to an index item, and a GED index table is constructed (see Figure 2 ), there are 11 graphs in E, so the index table size is a 11*11 matrix.
[0044] 2. Set the classification threshold τ1≤τ max , using the index table to classify the graphs in the database (the present invention uses Cl i Represents the i-th class, see Figure 3 ), the classification principle is: using the index table, if a group of graphs is found such that the GED values between them are within τ1, then the group of graphs is divided into one class.
[0045] The specific classification process is as follows:
[0046] 2.1 Class Cl based on index table i Initialize and establish 11 classes, each class Cl i The elements in g i The GED value at τ max Figures within (including g i This figure), sort them in ascending order according to the number of graphs in the class, and delete duplicate classes.
[0047] 2.2, for the classes obtained in 2.1, classify them with τ1 as the threshold.
[0048] 2.3 Further refine the classes so that there is no intersection-union relationship between classes. When a class A contains class B, delete the part of B in A to form a new class C.
[0049] Sort in ascending order according to the class size (i.e. the number of graphs in the class). If a graph has appeared in the previous class, it will be deleted from the current class.
[0050] For this embodiment, taking τ1=5 as an example, the classification process is as follows:
[0051] First, for class Cl i Initialize and establish 11 classes, that is, the 11 initialized classes are:
[0052] Cl1=Cl3=Cl4=Cl5=Cl7=Cl8=Cl 10 ={g1,g2,g3,g4,g5,g6,g7,g8,g9,g 10 , g 11}
[0053] Cl2=Cl6={g1,g2,g3,g4,g5,g6,g7,g8,g 10 , g 11}
[0054] Cl9={g1,g3,g4,g5,g7,g8,g 10 , g 11}
[0055] Arrange the graphs in ascending order according to the number of graphs in the class and delete the duplicate classes, and we can get:
[0056] Cl1={g1,g3,g4,g5,g7,g8,g 10 , g 11}
[0057] Cl2={g1,g2,g3,g4,g5,g6,g7,g8,g 10 , g 11}
[0058] Cl3={g1, g2, g3, g4, g5, g6, g7, g8, g9, g 10 , g 11}
[0059] Using τ1=5 as the threshold to classify Cl1, Cl2 and Cl3, we can get:
[0060] Cl1={g1, g3, g4, g5}, Cl2={g7, g8}, Cl3={g 10 , g 11}, Cl4={g1, g2, g3, g4, g5, g6}, Cl5=Cl2, Cl6=Cl3, Cl7=Cl4, Cl8={g7, g8, g9}, Cl9=Cl3.
[0061] Delete duplicates and sort in descending order. If a graph appears in the previous class, delete it. Finally, for database E, three classes can be obtained in this embodiment: Cl1 = {g1, g2, g3, g4, g5, g6}, Cl2 = {g7, g8, g9}, Cl3 = {g 10 , g 11}.
[0062] 3. Extract the MCS of each class (see Figure 4 ), the present invention proposes a graph search framework based on the largest common subgraph (see Figure 5 ), the specific process is as follows:
[0063] 3.1 Extract the largest common subgraph for each class.
[0064] 3.2 Construction of indicator lb L Perform a preliminary screening of database E and calculate lb MCS :
[0065] Let the query graph be q (such as Figure 6 ), the similarity threshold is T = 3. To find all graphs in database E whose GED values are within τ of q, first, we need to find the lower bound lb of the label set of the query graph q. L Perform preliminary filtering on E to obtain candidate set C, according to lb L Sort the graphs in C from smallest to largest.
[0066] lb L (q, g i )=Γ(L V (q), L V (g i ))+Γ(L E (q), L E (g i ))
[0067] Among them, L V (q) and L E (q) represents the set of q vertex and edge labels, L V (g i ) and L E (g i ) represent a graph g in the graph database E i The set of vertex and edge labels, Γ(A, B) = max(|A|, |B|) - (|A∩B|), |x| refers to the number of elements in the set x.
[0068] Using lb L The graph database E is preliminarily screened and all the L (q, g i )≤τg i Figure, obtain set C, in this embodiment, except lb L (q, g2) = 5, the rest of the figure lb L Are not greater than 3, that is, C = {g 11 ,g3,g4,g5,g6,g8,g9,g 10 , g1, g7}.
[0069] Next, calculate the GED of the largest common subgraph of each class in q and E and the lower bound value lb based on the largest common subgraph MCS :
[0070] lb MCS (q, MCS j )=ged(q,MCS j )-||q|-|MCS j ||
[0071] Among them, MCS j is the maximum common subgraph of the jth class (j = 1, 2, 3), |q| represents the sum of the number of vertices and edges of q, |MCS j | indicates MCS j The sum of the number of vertices and edges.
[0072] The calculation result is: ged(q, MCS1) = 8, lb MCS (q,MCS1)=3;ged(q,MCS2)=3,lb MCS (q,MCS2)=0;ged(q,MCS3)=8,lb MCS (q, MCS3)=7.
[0073] 3.3 Screening candidate sets: For each graph g in the candidate set C i Before calculating its GED with q, the GED and lb of the largest common subgraph of the class to which it belongs and q are calculated. MCS Conduct a second round of screening.
[0074] First, according to 3.2 lb MCS The calculation results of lb are used to filter the class. MCS >τ, then this class is directly eliminated, because Ib MCS (q, MCS3) = 7 > τ, so the graph in Cl3 is deleted from C, and lb MCS (q, MCS1), lb MCS(q, MCS2) are both ≤ 3, so continue with the next round of calculation for the elements in Cl1 and Cl2:
[0075] If ged(q, MCS j ) - |g i | + |MCS j | > τ, |g i | is the sum of the number of vertices and edges of g i , delete g i from C. If ged(q, MCS j ) + |g i | - |MCS j | ≤ τ, add g i to the result set res and delete it from C.
[0076] For the graphs in Cl1 and existing in C, ged(q, MCS1) - |g1| + |MCS1| = 6 > τ, ged(q, MCS1) - |g3| + |MCS1| = 4 > τ, ged(q, MCS1) - |g4| + |MCS1| = 4 > τ, ged(q, MCS1) - |g5| + |MCS1| = 4 > τ, ged(q, MCS1) - |g6| + |MCS1| = 4 > τ. So delete g1, g3, g4, g5, and g6 from C. At this time, C = {g8, g9, g7}.
[0077] For the graphs in Cl2 and existing in C, ged(q, MCS2) + |g7| - |MCS3| = 3 ≤ τ, g8 and g9 do not satisfy the above two equations. So delete g7 from C and add g7 to the result set res, keep g8 and g9. At this time, C = {g8, g9}.
[0078] 3.4 GED calculation: Arrange the calculation order of each type from small to large according to lb MCS
[0079] When finding a graph g i whose GED value with q is less than τ, at this time use the triangle inequality to use g i to replace q and continue to query for similar graphs. Since in the pre - calculation, the present invention has already calculated the GED values of g i with the remaining graphs in E, so screening can be directly performed without calculation. Let ged(q, g i ) = δ ≤ τ. When ged(g i , r) ≤ τ - δ, then ged(q, r) ≤ τ, add r to the result set res; when τ - δ < ged(g, r) ≤ τ + δ, keep r in the candidate set C; when τ + δ < ged(g, r), delete r from C.
[0080] When using g i After the screening is completed, if C is not empty, continue to use q and the graph in C for calculation, repeat the above steps until C is empty, the calculation is completed, and the final result set res is obtained.
[0081] In this embodiment, after step 3.3, we get res = {g7}, C = {g8, g9}. Both g8 and g9 belong to Cl2, so the order of the graphs in C remains unchanged. Since ged(q, g8) = 2 < τ, g8 is added to res and deleted from C, and then g8 is used to replace q for search. Knowing that ged(g8, g9) = 2, 3-2≤ged(g8, g9)≤2+3, g9 is retained in C, and C = {g9}. ged(q, g9) = 4 > τ, g9 is deleted from C, and now Calculation completed, res = {g7, g8}.
Claims
1. A graph similarity search method, characterized in that: include: S1 sets the maximum similarity threshold , calculate the graph edit distance GED of all graph pairs in the graph database and retain GED The selected graphs form a new graph database E; the GED value is The graph pairs within the range are divided into one category. , and extract the largest common subgraph for each class ; S2 sets the query graph q and uses E database Perform preliminary filtering to obtain candidate set C: ; Where, and are the sets of vertices and edges of q respectively, and They are The set of vertices and edges of , Refers to the number of elements in the set x; S3 computes the query graph q and GED value , filter the classes constructed in S1 and remove Class; ; In the formula, |q| represents the sum of the number of vertices and edges of q, express The sum of the number of vertices and edges of ; For the remaining classes, for the graphs in the same class and in the candidate set C, To filter: If ,Will Delete from candidate set C if , then Add to the result set res and delete from the candidate set C; for The sum of the number of vertices and edges of ; If S4 is not empty, search the remaining elements in the candidate set C to obtain the final result set.
2. The method according to claim 1, characterized in that In S1, the GED values of all graph pairs in the graph database are calculated and then a GED index table is constructed. The GED values of the graph pairs in the GED index table are queried for classification.
3. The method according to claim 1, characterized in that In S1, the classification method of the image pairs is: i) According to The number of graphs to establish the initial class , the elements in each initial class are The GED value is The figure within; ii) For the class obtained in i) is the threshold classification.
4. The method according to claim 3, characterized in that In i), after the initial classes are established, they are sorted in ascending order according to the number of graphs in the class, and duplicate classes are deleted.
5. The method according to claim 3 or 4, characterized in that In the above ii), after classification, the intersection and union of graph classes are corrected, including: a) If there is an inclusion relationship A∈B between different classes A and B, then the elements A in class B are removed to form a new class C; b) Sort in ascending order according to the size of the class. If a graph in a class has appeared in the class with the highest order, the graph will be removed from the current class.
6. The method according to claim 2, characterized in that In S4, when a graph is found in C With a GED value of q less than When the graph Join the result set res and remove it from C, and use Replace q and continue to query similar graphs.
7. The method according to claim 6, characterized in that set up ,use Continue to query similar graphs instead of q; when When Add to the result set res; when When Continue to remain in the candidate set C; when When Delete from C; refer to and GED value.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Set similarity-based sub-graph matching method in big graph database
CN107085594A
Graph similarity search method and device and computer storage medium
CN116628286A