A subgraph matching method and device

By filtering the data vertices in the query graph twice and connecting them in a preset order, the problem of excessive GPU memory load caused by too many invalid intermediate results in the existing technology is solved, and faster subgraph matching and more efficient memory use are achieved.

CN115905636BActive Publication Date: 2026-05-29AGRICULTURAL BANK OF CHINA

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AGRICULTURAL BANK OF CHINA
Filing Date
2022-11-04
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

The existing subgraph matching filtering methods are inaccurate, resulting in too many invalid intermediate results and causing excessive GPU memory load.

Method used

The method employs two-stage filtering and a preset order connection. First, the data vertices in the query graph are filtered twice to generate a candidate set of query vertices. Then, they are connected according to a preset order of kernel vertices and leaf vertices. Kernel vertices are vertices with a degree of non-one, and leaf vertices are vertices with a degree of one. Zero-copy and unified virtual memory are used to transfer data when necessary.

Benefits of technology

It reduces the generation of invalid intermediate results, improves subgraph matching speed, avoids GPU memory overload, and optimizes memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115905636B_ABST
    Figure CN115905636B_ABST
Patent Text Reader

Abstract

The application provides a subgraph matching method and device. In the execution method, first, store the query graph and the data graph processed into a preset format; then, filter the data vertices in the query graph twice to generate a query vertex candidate set; then, connect the candidate vertices in the query vertex candidate set in a preset order to obtain a subgraph with the same structure as the query graph, and the preset order is to connect the core vertices in the candidate vertices in the query vertex candidate set first, and then connect the leaf vertices in the candidate vertices in the query vertex candidate set. The application filters the data vertices in the query graph twice, so that fewer invalid vertices are screened, and in the connection process, the vertices with a degree of one are connected first, and then the vertices with a degree of one are connected, which produces fewer invalid intermediate results, speeds up the subgraph matching speed, avoids occupying too much GPU memory, and further avoids the problem of excessive GPU memory load.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With large amounts of data stored in the form of graphs, graph data analysis has received widespread attention in various fields. As one of the fundamental problems in graph data analysis, subgraph matching is also becoming more widely known and applied. Subgraph matching can be understood as finding all graphs in the data graph with the same structure as the query graph, given a query graph and a data graph.

[0003] Subgraph matching mainly consists of two processes: filtering and connection. Current GPU-based subgraph matching first filters vertices using information such as vertex type, edge type, and the number of edges of each type. This information is encoded by comparing data vertices and querying their encoding. The connection process first connects candidate vertices from the intermediate results, then verifies whether the connected vertices are truly suitable for inclusion in the intermediate result set by checking other edge information of the connected vertices. However, due to the simplicity of the filtering process, the parallel connection method leads to an excessive number of invalid intermediate results, resulting in slow subgraph matching and issues such as uneven load distribution and redundant memory accesses during the connection process. Summary of the Invention

[0004] In view of this, this application provides a subgraph matching method and apparatus, which aims to solve the problem that the inaccurate filtering method of subgraph matching in the prior art leads to too many invalid intermediate results, thereby causing excessive GPU memory load.

[0005] In a first aspect, this application provides a subgraph matching method applied to a GPU, the method comprising:

[0006] Store and process query graphs and data graphs into preset formats;

[0007] The data vertices in the query graph are filtered twice to generate a candidate set of query vertices;

[0008] The candidate vertices in the query vertex candidate set are connected in a preset order to obtain a subgraph with the same structure as the query graph. The preset order is to first connect the kernel vertices in the candidate vertices of the query vertex candidate set, and then connect the leaf vertices in the candidate vertices of the query vertex candidate set. The kernel vertex is a vertex with a degree of not one, and the leaf vertex is a vertex with a degree of one.

[0009] Optionally, the step of filtering the data vertices in the query graph twice to generate a candidate set of query vertices specifically includes:

[0010] The data vertices in the query graph are first filtered to select vertices of the same type as the data vertices in the query graph.

[0011] The vertices selected in the first filtering process that are of the same type as the data vertices in the query graph are subjected to a second filtering process. The second filtering process is used to filter out vertices whose neighbor type is the same as the neighbor type in the query graph based on neighbor information.

[0012] The vertices selected through the second filtering are used to generate a candidate set of query vertices.

[0013] Optionally, the preset order further includes: if vertices are both kernel vertices or both leaf vertices, then the preset order is that the connection order of vertices with larger degrees is earlier than the connection order of vertices with smaller degrees.

[0014] Optionally, the storage processing into a preset format query graph and data graph specifically includes:

[0015] Store the query graph in the preset format into the GPU;

[0016] If the size of the preset format data map is less than a preset threshold, then the preset format data map is stored in the GPU;

[0017] If the size of the preset format data graph is not less than a preset threshold, then the preset format data graph will be split.

[0018] The edge information of the split data graph is stored in the CPU memory; the vertex information of the split data graph is stored in the GPU.

[0019] Optionally, if the edge information of the split data graph is stored in the CPU memory and the vertex information of the split data graph is stored in the GPU, the method further includes the following steps before sequentially connecting the candidate vertices in the query vertex candidate set in each round:

[0020] If the amount of candidate vertices used for this round of connection is large, then the candidate vertices used for this round of connection are copied to the GPU using a unified virtual memory method;

[0021] If the amount of candidate vertices used for this round of connection is small, then the candidate vertices used for this round of connection are transferred to the GPU via the data bus using a zero-copy method.

[0022] Secondly, this application provides a subgraph matching device applied to a GPU, the device comprising: a storage module, a filtering module, and a connection module;

[0023] The storage module is used to store query graphs and data graphs processed into a preset format;

[0024] The filtering module is used to filter the data vertices in the query graph twice to generate a candidate set of query vertices;

[0025] The connection module is used to connect the candidate vertices in the query vertex candidate set in a preset order to obtain a subgraph with the same structure as the query graph; the preset order is to first connect the kernel vertices in the candidate vertices in the query vertex candidate set, and then connect the leaf vertices in the candidate vertices in the query vertex candidate set; the kernel vertex is a vertex with a degree of not one, and the leaf vertex is a vertex with a degree of one.

[0026] Optionally, the filtering module includes a first filtering unit, a second filtering unit, and a generating unit;

[0027] The first filtering unit is specifically used to perform a first filtering on the data vertices in the query graph, wherein the first filtering is used to select vertices of the same type as the data vertices in the query graph;

[0028] The second filtering unit is specifically used to perform a second filtering on vertices of the same type as the data vertices in the query graph that were selected by the first filtering. The second filtering is used to filter out vertices whose neighbor type is the same as the neighbor type in the query graph through neighbor information.

[0029] The generation unit is specifically used to generate a candidate set of query vertices using the vertices selected by the second filtering.

[0030] Optionally, the device further includes a determining module, which is used to determine the connection order of vertices that are both kernel vertices or both leaf vertices. Specifically, the determining module is used to:

[0031] The connection order of vertices with larger degrees is determined before that of vertices with smaller degrees.

[0032] Optionally, the storage module specifically includes a first storage unit and a second storage unit;

[0033] The first storage unit is specifically used to store the query graph of the preset format into the GPU;

[0034] The second storage unit is specifically used to: store the data graph in the preset format in the GPU if the size of the data graph in the preset format is less than a preset threshold; split the data graph in the preset format if the size of the data graph in the preset format is not less than the preset threshold; store the edge information of the split data graph in the memory CPU; and store the vertex information of the split data graph in the GPU.

[0035] Optionally, the device further includes a first transmission module and a second transmission module. If the second storage unit stores the edge information of the split data graph in the memory CPU and the vertex information of the split data graph in the GPU, before sequentially connecting the candidate vertices in the query vertex candidate set in each round, if the amount of candidate vertex data used for this round of connection is large, the first transmission module is specifically used for:

[0036] The candidate vertices used for this round of connection are copied to the GPU using a unified virtual memory method;

[0037] If the amount of data for candidate vertices used in this round of connection is small, the second transmission module is specifically used for:

[0038] The candidate vertices used for this round of connection are transferred to the GPU via the data bus using a zero-copy method.

[0039] This application provides a subgraph matching method and apparatus. When executing the method, a query graph and a data graph processed into a preset format are first stored; then, the data vertices in the query graph are filtered twice to generate a candidate set of query vertices; then, the candidate vertices in the candidate set are connected in a preset order to obtain a subgraph with the same structure as the query graph. The preset order is to first connect the kernel vertices in the candidate set, and then connect the leaf vertices in the candidate set. The kernel vertex is a vertex with a degree other than one, and the leaf vertex is a vertex with a degree of one. This application reduces the number of invalid vertices by filtering the data vertices in the query graph twice, and by connecting vertices with a degree other than one first, followed by vertices with a degree of one, fewer invalid intermediate results are generated, thus speeding up the subgraph matching process and avoiding excessive GPU memory usage, further preventing excessive GPU memory load. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings used in the description of the embodiment or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 A flowchart of a subgraph matching method provided in an embodiment of this application;

[0042] Figure 2 This is a schematic diagram of a CSR storage structure provided in an embodiment of this application;

[0043] Figure 3 A schematic diagram of a level-CSR storage structure provided in an embodiment of this application;

[0044] Figure 4 A flowchart of a subgraph matching method provided in an embodiment of this application;

[0045] Figure 5 A flowchart for obtaining kernel vertices and leaf vertices is provided as an embodiment of this application;

[0046] Figure 6 A flowchart illustrating another subgraph matching method provided in this application embodiment;

[0047] Figure 7 This is a schematic diagram of the structure of a subgraph matching device provided in an embodiment of this application. Detailed Implementation

[0048] With large amounts of data stored in the form of graphs, subgraph matching is one of the most fundamental problems in graph data analysis. Subgraph matching can be understood as finding all graphs in the data graph that have the same structure as the query graph, given a query graph and a data graph.

[0049] Subgraph matching has wide applications in many fields such as social networks, knowledge graphs, and biomedicine. In the field of social networks, subgraph matching can help identify specific relationship structures within massive social network data, such as the number of three- or four-person families in society today, or the number of families with one or two children when both parents are only children. Furthermore, subgraph matching can be applied in the financial sector, for example, in anti-fraud and anti-money laundering operations. Criminals often use fixed transfer patterns between multiple accounts during money laundering, forming a fixed directed subgraph. By abstracting the subgraph corresponding to these typical transfer patterns and querying it through subgraph matching, suspicious account groups can be identified and detected at an early stage, curbing telecommunications and online fraud and protecting customer assets.

[0050] Subgraph matching mainly consists of two processes: filtering and joining. Currently, GPU-based subgraph matching primarily employs the following methods:

[0051] Filtering is performed using vertex information, which includes vertex type, edge type, and the number of edges of each type. Existing methods encode the vertex type, edge type, and the number of edges of each type, and then filter by comparing data vertices and querying the vertex encoding information.

[0052] The connection process first connects candidate vertices through the vertices involved in the connection in the intermediate results. Then, it verifies whether the vertices that were just connected can really be added to the intermediate result set by using the other edge information of the vertices involved in the connection in the intermediate results. During the connection process, each warp processes all the connection processes of one intermediate result vertices involved in the connection.

[0053] The simplistic filtering process in existing technologies leads to an excessive number of invalid intermediate results during the join phase. Because GPUs are not adept at logical prediction and non-contiguous access, existing GPU-based subgraph matching employs coarse-grained filtering strategies. This results in a large number of vertices in the queried graph structure being misclassified as candidate vertices for a specific graph structure. Since existing technologies use pre-allocation to write intermediate results in parallel, these invalid candidate points generate a large number of invalid intermediate results during the join phase, not only slowing down subgraph matching but also overburdening or even overflowing the already limited GPU memory.

[0054] Therefore, this application provides a subgraph matching method and apparatus to solve the problem of excessive invalid intermediate results caused by the imprecise filtering method of subgraph matching in the prior art, which in turn leads to excessive GPU memory load.

[0055] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0056] Before introducing the solutions in the embodiments of this application, let's first introduce some relevant terms in this field:

[0057] Query graph: A connected graph structure used for querying data.

[0058] Data graph: A connected graph structure that stores large amounts of information and allows for searching.

[0059] Graph isomorphism: Given a query graph Q and a data graph G, the subgraph isomorphism from Q to G is an injection function that satisfies (1) all vertices in Q are mapped in G; (2) for any edge in Q, there is a mapping in G and the corresponding vertex of the edge has the mapping relationship in (1).

[0060] Subgraph matching: Subgraph matching takes a data graph and a query graph as input and finds all subgraphs in the data graph that are isomorphic to the query graph.

[0061] Active vertices: Candidate vertices that will be connected in the next round of connections.

[0062] Intermediate result set: In the process of connecting data vertices to form a query graph, the query graph subgraphs generated in the process of gradually forming the query graph become intermediate results, and all intermediate results constitute the intermediate result set.

[0063] A warp consists of 32 consecutive threads and is the basic unit of thread scheduling. Threads in a warp execute commands in parallel using a single instruction multiple data method.

[0064] Unified memory: All processors share all physical memory consistently.

[0065] Unified Virtual Memory: Unified Virtual Memory is a unified memory access method based on a page replacement algorithm. It allows data to be automatically migrated between main memory and GPU memory. When a page not in GPU memory is accessed, a page fault is triggered, pausing thread execution until the requested page has been migrated. It is suitable for scenarios involving continuous access to large amounts of data.

[0066] Zero-copy memory: Zero-copy is a direct access mode that translates thread requests into memory requests via a bus. It allows access to main memory data as if it were GPU memory, without requiring page migration. Data accessed via zero-copy can be located anywhere in the system that can be memory-mapped to the shared bus. It is suitable for fine-grained data access.

[0067] See Figure 1 , Figure 1 A flowchart of a subgraph matching method provided in this application embodiment includes:

[0068] S101. Store the query graph and data graph processed into a preset format.

[0069] Traditional graph data is mostly stored in a compressed sparse row (CSR) matrix storage format. See the diagram for a specific CSR structure. Figure 2 The structure consists of two arrays: one array stores the position of the first neighboring vertex, with the array index being the vertex number; the other array stores all edge information, meaning that the starting position of an edge can be located through a vertex.

[0070] In this application, the query graph and data graph are processed into a preset format. This preset format can be a hierarchical sparse matrix (level-CSR) storage method, which involves segmenting the edge information of high-degree vertices and adding an array between the two CSR arrays to store the starting positions of the slices after segmentation. This allows high-degree vertices to locate their edges more quickly without traversing all edges. See the detailed level-CSR structure diagram below. Figure 3 .

[0071] After processing the query graph and data graph into level-CSR format, they are stored as query graphs and data graphs in a preset format. This allows for faster location of edges for high-degree vertices without traversing all edges, avoiding unnecessary memory accesses.

[0072] S102. Filter the data vertices in the query graph twice to generate a candidate set of query vertices.

[0073] See Figure 4 , Figure 4 The flowchart for subgraph matching is shown in Figure (a). (a) shows the data graph and the query graph. First, the candidate vertex set for each query vertex is obtained by filtering, as shown in Figure (b). Then, the order of addition is determined according to the characteristics of the query vertex, as shown in Figure (c). Then, the connection is performed step by step. (d) is the intermediate state in the connection process. The candidate vertices of gray vertices and white vertices have been connected, and the generated result becomes the intermediate result set. The next step is to connect the black vertices. The black vertex candidate points are the active vertices in this round. The final subgraph matching result (e) is obtained through connection.

[0074] The data vertices in the query graph are filtered twice. First, the data vertices in the query graph are filtered using vertex features to identify vertices of the same type as those in the query graph. Then, the vertices selected in the first filtering are filtered a second time using neighbor information to identify vertices whose neighbor type is the same as that in the query graph. The neighbor information can be edge information.

[0075] To illustrate the above process, consider a query graph where the vertices are A, B, and C. In the data graph, vertices a, b, and c are of the same type as A, B, and C. The first filter identifies a, b, and c, filtering vertices by type. After identifying the vertices, further filtering of a, b, and c is performed based on neighbor information. Since there may be multiple a, b, and c vertices, neighbor information can further determine if a vertex is of the same type as a vertex in the query graph. For example, if A and B in the query graph are connected by an edge of type L, the second filter needs to identify vertices where a and b are also connected by edge type L, filtering out vertices not connected by edge type L.

[0076] A candidate set of query vertices is generated using the vertices obtained after two filtering processes.

[0077] S103. Connect the candidate vertices in the query vertex candidate set in a preset order to obtain a subgraph with the same structure as the query graph.

[0078] First, it is necessary to determine the preset order of connecting candidate vertices in the query vertex candidate set. The specific determination process can be carried out in the following way:

[0079] The vertices in the query graph are divided into kernel vertices and leaf vertices. Kernel vertices are vertices with a degree of not equal to one, and leaf vertices are vertices with a degree of one. For example, ... Figure 5 As shown, Figure 5 To illustrate the process of obtaining kernel vertices and leaf vertices, firstly, vertices with a degree of 1 are removed from the graph. Then, vertices with a degree of 1 are removed from the remaining graph until no more vertices with a degree of 1 can be removed. The remaining vertices are kernel vertices, and the removed vertices are leaf vertices. Vertices in the candidate set corresponding to the vertex type in the query graph are also divided into kernel vertices and leaf vertices. The connection order of kernel vertices in the candidate set is set to be earlier than the connection order of leaf vertices; that is, kernel vertices are connected first, followed by leaf vertices.

[0080] If the vertices are of the same type, that is, both are kernel vertices or both are leaf vertices, the vertices are connected in the order that the vertices with larger degrees are connected before the vertices with smaller degrees.

[0081] Once the connection order is determined, the candidate vertices in the query vertex candidate set are connected in sequence. When all candidate vertices are connected, a subgraph with the same structure as the query graph is obtained, which means the subgraph matching is complete.

[0082] After each candidate vertex is connected, vertex verification is required. The other edges of the candidate vertex are used to verify whether the candidate vertex can be truly added to the intermediate result.

[0083] This application provides a subgraph matching method. When executing the method, a query graph and a data graph, processed into a preset format, are first stored. Then, the data vertices in the query graph are filtered twice to generate a candidate set of query vertices. Next, the candidate vertices in the candidate set are connected in a preset order to obtain a subgraph with the same structure as the query graph. The preset order is to first connect the kernel vertices in the candidate set, and then connect the leaf vertices. The kernel vertex is a vertex with a degree other than one, and the leaf vertex is a vertex with a degree of one. This application reduces the number of invalid vertices by filtering the data vertices in the query graph twice. Furthermore, by connecting vertices with degrees other than one first, and then connecting vertices with degrees of one, fewer invalid intermediate results are generated, accelerating the subgraph matching speed and avoiding excessive GPU memory consumption, thus preventing excessive GPU memory load.

[0084] Furthermore, in an optional embodiment of this application, step S101 can be implemented in the following manner:

[0085] The query graph in a preset format is stored in the GPU. If the size of the preset format data graph is less than a preset threshold (e.g., 1GB), it is considered small and stored in the GPU. If the size of the preset format data graph is greater than the preset threshold, it is split into smaller parts. The edge information of the split data graph is stored in the CPU memory, while the vertex information is stored in the GPU. This avoids the problem of insufficient GPU memory. Even with a large data graph, subgraph matching can still be performed, unlike existing technologies that store the data graph in the GPU and cannot process it when its size exceeds the GPU's storage capacity.

[0086] Furthermore, in an optional embodiment of this application, if the edge information of the split data graph is stored in the CPU memory and the vertex information of the split data graph is stored in the GPU, before sequentially connecting the candidate vertices in the query vertex candidate set in each round, if the amount of data for the candidate vertices used for this round of connection is large and needs to be accessed continuously, the data stored in the CPU for this round of connection needs to be transferred to the GPU through a unified virtual memory; if the amount of data for the candidate vertices used for this round of connection is small, the candidate vertices used for this round of connection are transferred to the GPU through the data bus using a zero-copy method. This achieves efficient transmission while avoiding bus resource waste and read amplification. The data size is determined based on the GPU's memory.

[0087] To determine which transmission method to use, we can collect information on active vertices in the next round of connections. These active vertices are the vertices that need to be connected in the next round. We can also organize and classify the information on active vertices by subgraph, perform cost analysis on the information on active vertices in each subgraph, and select the transmission method based on the analysis results.

[0088] See Figure 6 , Figure 6 The flowchart of another subgraph matching method provided in this application embodiment is as follows: First, the CPU processes the query graph and the data graph into a level-CSR structure format and stores it. Then, it filters the vertex and edge information of the query graph. After filtering all vertices, it generates a vertex addition order according to the vertex information. Then, it adds vertices one by one according to the vertex addition order to form a subgraph. If the obtained subgraph has the same structure as the query graph, a subgraph matching result is generated. If the obtained subgraph has a different structure from the query graph, it is determined whether the intermediate result of the subgraph is empty. If it is not empty, vertices are added. If it is empty, the addition of vertices is terminated.

[0089] The above describes some specific implementations of a subgraph matching method provided in this application. Based on this, this application also provides a corresponding subgraph matching device. The device provided in this application will be described below from the perspective of functional modularity.

[0090] See Figure 7 , Figure 7 This is a schematic diagram of a subgraph matching device provided in an embodiment of the present application. The device is applied to a GPU and includes: a storage module 701, a filtering module 702, and a connection module 703.

[0091] The storage module 701 is used to store query graphs and data graphs processed into a preset format;

[0092] The filtering module 702 is used to filter the data vertices in the query graph twice to generate a candidate set of query vertices.

[0093] The connection module 703 is used to connect the candidate vertices in the query vertex candidate set in a preset order to obtain a subgraph with the same structure as the query graph; the preset order is to first connect the kernel vertices in the candidate vertices in the query vertex candidate set, and then connect the leaf vertices in the candidate vertices in the query vertex candidate set; the kernel vertex is a vertex with a degree of not one, and the leaf vertex is a vertex with a degree of one.

[0094] This application provides a subgraph matching apparatus. A method for performing corresponding subgraph matching includes, when executing the method, first storing a query graph and a data graph processed into a preset format; then filtering the data vertices in the query graph twice to generate a candidate set of query vertices; then connecting the candidate vertices in the candidate set in sequence to obtain a subgraph with the same structure as the query graph. This application, by filtering the data vertices in the query graph twice, reduces the number of invalid vertices selected, resulting in fewer invalid intermediate results during the connection process, avoiding excessive GPU memory consumption, and further preventing the problem of excessive GPU memory load.

[0095] Furthermore, in an optional embodiment of this application, the filtering module 702 includes a first filtering unit, a second filtering unit, and a generating unit;

[0096] The first filtering unit is specifically used to perform a first filtering on the data vertices in the query graph, wherein the first filtering is used to select vertices of the same type as the data vertices in the query graph;

[0097] The second filtering unit is specifically used to perform a second filtering on vertices of the same type as the data vertices in the query graph that were selected by the first filtering. The second filtering is used to filter out vertices whose neighbor type is the same as the neighbor type in the query graph through neighbor information.

[0098] The generation unit is specifically used to generate a candidate set of query vertices using the vertices selected by the second filtering.

[0099] Furthermore, in an optional embodiment of this application, the apparatus further includes a determining module, which is used to determine the connection order of vertices that are both kernel vertices or both leaf vertices. Specifically, the determining module is used to:

[0100] The connection order of vertices with larger degrees is determined before that of vertices with smaller degrees.

[0101] Furthermore, in an optional embodiment of this application, the storage module specifically includes a first storage unit and a second storage unit;

[0102] The first storage unit is specifically used to store the query graph of the preset format into the GPU;

[0103] The second storage unit is specifically used to: store the data graph in the preset format in the GPU if the size of the data graph in the preset format is less than a preset threshold; split the data graph in the preset format if the size of the data graph in the preset format is not less than the preset threshold; store the edge information of the split data graph in the memory CPU; and store the vertex information of the split data graph in the GPU.

[0104] Further, in an optional embodiment of this application, the device further includes a first transmission module and a second transmission module. If the second storage unit stores the edge information of the split data graph in the memory CPU and the vertex information of the split data graph in the GPU, before sequentially connecting the candidate vertices in the query vertex candidate set in each round, if the amount of data of the candidate vertices used for connection in this round is large, the first transmission module is specifically used for:

[0105] The candidate vertices used for this round of connection are copied to the GPU using a unified virtual memory method;

[0106] If the amount of data for candidate vertices used in this round of connection is small, the second transmission module is specifically used for:

[0107] The candidate vertices used for this round of connection are transferred to the GPU via the data bus using a zero-copy method.

[0108] In the embodiments of this application, the terms "first" and "second" are used only as name identifiers and do not represent the order of first and second.

[0109] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus a general-purpose hardware platform. Based on this understanding, the technical solution of this application can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as a read-only memory (ROM) / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the methods described in various embodiments or some parts of the embodiments of this application.

[0110] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0111] The above description is merely an exemplary implementation of this application and is not intended to limit the scope of protection of this application.

Claims

1. A subgraph matching method, characterized in that, Applied to a GPU, the method includes: Store and process query graphs and data graphs into preset formats; The data vertices in the query graph are filtered twice to generate a candidate set of query vertices; The candidate vertices in the query vertex candidate set are connected in a preset order to obtain a subgraph with the same structure as the query graph. The preset order is to first connect the kernel vertices in the candidate vertices of the query vertex candidate set, and then connect the leaf vertices in the candidate vertices of the query vertex candidate set. The kernel vertex is a vertex with a degree of not one, and the leaf vertex is a vertex with a degree of one. The step of filtering the data vertices in the query graph twice to generate a candidate set of query vertices specifically includes: The data vertices in the query graph are first filtered to select vertices of the same type as the data vertices in the data graph. The vertices selected in the first filtering process that are of the same type as the data vertices in the query graph are subjected to a second filtering process. The second filtering process is used to filter out vertices whose neighbor type is the same as the neighbor type in the data graph based on neighbor information. The vertices selected through the second filtering process are used to generate a candidate set of query vertices. The storage processing into query graphs and data graphs in a preset format specifically includes: Store the query graph in the preset format into the GPU; If the size of the preset format data map is less than a preset threshold, then the preset format data map is stored in the GPU; If the size of the preset format data graph is not less than a preset threshold, then the preset format data graph will be split. The edge information of the split data graph is stored in the CPU memory; the vertex information of the split data graph is stored in the GPU. If the edge information of the split data graph is stored in the CPU memory and the vertex information of the split data graph is stored in the GPU, the method further includes the following steps before sequentially connecting the candidate vertices in the query vertex candidate set in each round: If the amount of candidate vertices used for this round of connection is large, then the candidate vertices used for this round of connection are copied to the GPU using a unified virtual memory method; If the amount of candidate vertices used for this round of connection is small, then the candidate vertices used for this round of connection are transferred to the GPU via the data bus using a zero-copy method.

2. The method according to claim 1, characterized in that, The preset order also includes: If vertices are both kernel vertices or both leaf vertices, then the preset order is that the connection order of vertices with larger degrees is earlier than the connection order of vertices with smaller degrees.

3. A subgraph matching device, characterized in that, For use with GPUs, the device includes: a storage module, a filtering module, and a connection module; The storage module is used to store query graphs and data graphs processed into a preset format; The filtering module is used to filter the data vertices in the query graph twice to generate a candidate set of query vertices; The connection module is used to connect the candidate vertices in the query vertex candidate set in a preset order to obtain a subgraph with the same structure as the query graph; the preset order is to first connect the kernel vertices in the candidate vertices in the query vertex candidate set, and then connect the leaf vertices in the candidate vertices in the query vertex candidate set; the kernel vertex is a vertex with a degree of not one, and the leaf vertex is a vertex with a degree of one. The filtering module includes a first filtering unit, a second filtering unit, and a generating unit; The first filtering unit is specifically used to perform a first filtering on the data vertices in the query graph, wherein the first filtering is used to select vertices of the same type as the data vertices in the data graph; The second filtering unit is specifically used to perform a second filtering on vertices of the same type as the data vertices in the query graph that were selected by the first filtering. The second filtering is used to filter out vertices whose neighbor type is the same as the neighbor type in the data graph through neighbor information. The generation unit is specifically used to generate a candidate set of query vertices using the vertices selected by the second filtering. The storage module specifically includes a first storage unit and a second storage unit; The first storage unit is specifically used to store the query graph of the preset format into the GPU; The second storage unit is specifically used to: if the size of the preset format data graph is less than a preset threshold, store the preset format data graph in the GPU; if the size of the preset format data graph is not less than the preset threshold, split the preset format data graph; store the edge information of the split data graph in the memory CPU; and store the vertex information of the split data graph in the GPU. The device further includes a first transmission module and a second transmission module. If the second storage unit stores the edge information of the split data graph in the memory CPU and the vertex information of the split data graph in the GPU, before sequentially connecting the candidate vertices in the query vertex candidate set in each round, if the amount of candidate vertex data used for this round of connection is large, the first transmission module is specifically used for: The candidate vertices used for this round of connection are copied to the GPU using a unified virtual memory method; If the amount of data for candidate vertices used in this round of connection is small, the second transmission module is specifically used for: The candidate vertices used for this round of connection are transferred to the GPU via the data bus using a zero-copy method.

4. The apparatus according to claim 3, characterized in that, The device further includes a determining module, which is used to determine the connection order of vertices that are both kernel vertices or both leaf vertices. Specifically, the determining module is used to: The connection order of vertices with larger degrees is determined before that of vertices with smaller degrees.