Frequent subgraph mining method and device for a single graph
By generating a standardized adjacency matrix and building a suboptimal standardized adjacency matrix tree, the problem of frequent subgraph mining efficiency in the existing technology is solved, and more efficient search space reduction and subgraph growth are achieved.
Patent Information
- Application Number
- CN202011254159.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-11
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2040-11-11
AI Technical Summary
The existing frequent subgraph mining algorithm engine for massive data is not a dedicated engine for graph computing optimization, which greatly affects the mining efficiency of frequent subgraph algorithms.
By generating a standard adjacency matrix of a single graph and numbering the graph nodes, a suboptimal standard adjacency matrix tree is built, sub-graph growth is used to meet the matrix requirements, and mark invalid subgraphs are pre-pruned to reduce search space.
Through multi-faceted pruning technology, the search space is significantly reduced, the mining efficiency of frequent subgraphs is improved, and invalid subgraph growth is avoided.
Smart Images

Figure CN114490799B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data mining, and in particular to a method and device for mining frequent subgraphs of a single graph. Background Art
[0002] With the rapid development of big data technology, the use of graph structures to describe data is gradually being applied to massive data. Traditional big data analysis technology is usually based on SQL or SQL-like table analysis tools with relatively general analysis engines, but massive graph data, due to its complexity and particularity of relational storage, often requires a dedicated computing and analysis engine to implement.
[0003] Graphs are highly abstract structures. Frequent subgraph mining is one of the key graph mining technologies. It has a wide range of applications in social networks, intelligence mining, bioengineering, communication network optimization, text mining, knowledge reasoning, and other fields, such as protein structure analysis, link prediction, sensitive group identification, image classification, etc. At the same time, the results of frequent subgraph mining can also serve as the basis for data classification, clustering, retrieval, matching, and similarity analysis.
[0004] Traditional frequent subgraph mining algorithms are highly complex and are mostly stand-alone serial algorithms, mainly divided into two categories: Apriori (association analysis) and FFSM (Fast Frequent Subgraph Mining), represented by AGM (Apriori-based Graph Mining) and gSpan (Graph-Based Substructure Pattern Mining) algorithms. FFSM-based algorithms are often better than Apriori-based algorithms, but at the same time, FFSM-based algorithms take up more memory space.
[0005] In recent years, frequent subgraph mining algorithms represented by MapReduce and BSP (Bulk Synchronous Parallel) have emerged in the field of massive graph data mining. These technologies are based on general big data storage and computing such as Hadoop, Spark and Flink, and have achieved the ability to mine frequent subgraphs with a scale of more than one billion edges on commercial clusters.
[0006] However, the existing massive data frequent subgraph mining algorithm engines are not dedicated engines optimized for graph computing, which greatly affects the mining efficiency of the frequent subgraph algorithm. Summary of the invention
[0007] In view of this, the present invention provides a method and device for mining frequent subgraphs of a single graph to improve the efficiency of mining frequent subgraphs.
[0008] In order to achieve the above object, the present invention adopts the following scheme:
[0009] According to one aspect of an embodiment of the present invention, a frequent subgraph mining method for a single graph is provided, comprising:
[0010] Generate a canonical adjacency matrix of a single graph according to the dictionary sorting result of the node labels of the single graph, and number each graph node in the canonical adjacency matrix of the single graph in the order of rows or columns;
[0011] An initial suboptimal canonical adjacency matrix tree is generated by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes, wherein each leaf node of the initial suboptimal canonical adjacency matrix tree includes a first number of edges; the first number is an integer not less than one; the root node of the initial suboptimal canonical adjacency matrix tree does not include the graph nodes and edges of the single graph, the child nodes of the root node are frequent nodes, and the child nodes of the frequent nodes are frequent edges; the CSP search space of the leaf nodes is a combination of the lexicographic sort order of the numbers of the graph nodes corresponding to the node labels contained therein;
[0012] In the case where the first node of the leaf containing the first number of edges is a canonical adjacency matrix and there are other second nodes with leaves containing the first number of edges that share a parent node with the first node, the first node and the second node are subjected to FFSM-Join operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges; in the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and is an external matrix, the third node is subjected to FFSM-Extension operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as parent node and containing the second number of edges; wherein the second number minus the first number is equal to one; the third node is the same as or different from the first node or the second node; the child node containing the second number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree;
[0013] Taking the leaf nodes containing the second number of edges as candidate subgraphs, constructing a CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node;
[0014] When the number of valid combinations of the lexicographic order of the graph nodes in the CSP search space of the current candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph;
[0015] In the case that it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, subgraph growth is performed according to the canonical adjacency matrix of the single graph and according to nodes containing a second number of edges that are not marked as invalid subgraphs, so as to update leaf nodes of a suboptimal canonical adjacency matrix tree, and frequent subgraphs of the single graph are output according to the leaf nodes that have completed subgraph growth.
[0016] In some embodiments, generating an initial suboptimal canonical adjacency matrix tree by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes comprises:
[0017] The suboptimal canonical adjacency matrix tree is initialized by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes to obtain an initial suboptimal canonical adjacency matrix tree; wherein the root node of the initial suboptimal canonical adjacency matrix tree is a null value; the first number is equal to one; and the CSP search space of the frequent nodes is a combination of the lexicographically sorted order of the node label numbers of the starting graph nodes of the corresponding edges and the node label numbers of the end graph nodes.
[0018] In some embodiments, the frequent subgraph mining method of a single graph further includes:
[0019] In the case where the numbers of the graph nodes in the suboptimal adjacency matrix corresponding to the nodes of the leaves including the first number of edges do not conform to the lexicographic sort order, marking the corresponding nodes of the leaves including the first number of edges as invalid subgraphs;
[0020] In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges, including:
[0021] When the third node of the leaf containing the first number of edges is a canonical adjacency matrix, an external matrix and is not marked as an invalid subgraph, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges.
[0022] In some embodiments, when a first node containing leaves of a first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the first node and the second node as parent nodes and containing a second number of edges, including:
[0023] In the case where a first node containing leaves of the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node,
[0024] If the first node and the second node are both inner matrices, if and only if f and k are different, the subgraph is grown in the first way to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented by C m×m , where the adjacency matrix C m×m The elements in are represented as:
[0025]
[0026] Among them, c i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, b i,j represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the second node. The last edge in the canonical adjacency matrix corresponding to the first node is represented by a m,f , m and f represent the number of rows and columns and the total number of edges in the canonical adjacency matrix corresponding to the first node, respectively. The last edge in the adjacency matrix corresponding to the second node is represented by b n,k , n and k represent the number of rows and columns and the total number of edges of the adjacency matrix corresponding to the second node respectively;
[0027] If the first node is an inner matrix and the second node is an outer matrix, the subgraph is grown in the second manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented as C n×n , where the adjacency matrix C n×n The elements in are represented as:
[0028]
[0029] If the first node and the second node are both external matrices, then f≠k∧a m,m =b m,m , the subgraph is grown in the third way, and the adjacency matrix corresponding to the child nodes having the first node and the second node as parent nodes and containing the second number of edges is obtained, which is represented as C m×m , where the adjacency matrix C m×m The elements in are represented as:
[0030]
[0031] If both the first node and the second node are external matrices, the subgraph is grown in the fourth manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented as D (m+1)×(m+1) , where the adjacency matrix D (m+1)×(m+1) The elements in are represented as:
[0032]
[0033] Among them, d i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, b m,j represents the element in the mth row and jth column of the adjacency matrix corresponding to the second node, b m,m Represents the element in the mth row and mth column of the adjacency matrix corresponding to the second node, where m represents the number of rows and columns of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node.
[0034] In some embodiments, taking a leaf node containing a second number of edges as a candidate subgraph, constructing a CSP search space of a corresponding candidate subgraph according to a subgraph growth mode and according to a parent node of the candidate subgraph and a CSP search space of the parent node, including:
[0035] When the subgraph is grown in the first manner or the third manner to obtain a leaf node containing the second number of edges as a candidate subgraph, deduplication of the subgraph corresponding to the combination of the lexicographic sorting order of the numbers of the graph nodes in the CSP search space of the first node and the CSP search space of the second node is obtained to obtain the CSP search space of the candidate subgraph;
[0036] When the subgraph is grown according to the second method or the fourth method to obtain a node with leaves containing the second number of edges as a candidate subgraph, the subgraph corresponding to the lexicographically sorted order combination of the numbers of the graph nodes in the two CSP search spaces corresponding to the common part of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node is deduplicated, and spliced to the CSP search space corresponding to the remaining nodes in the adjacency matrix corresponding to the second node except the common part of the canonical adjacency matrix corresponding to the first node, to obtain the CSP search space of the candidate subgraph.
[0037] In some embodiments, taking a leaf node containing a second number of edges as a candidate subgraph, constructing a CSP search space of a corresponding candidate subgraph according to a subgraph growth mode and according to a parent node of the candidate subgraph and a CSP search space of the parent node, including:
[0038] When a node containing a leaf of the second number of edges obtained by performing a FFSM-Extension operation on the subgraph is used as a candidate subgraph, the CSP search space of the third node is obtained, and the number of the end point graph node added by the candidate subgraph relative to the third node is added to the end of the lexicographically sorted combination of the numbers of each graph node in the CSP search space of the third node to obtain the CSP search space of the candidate subgraph.
[0039] In some embodiments, taking a leaf node containing a second number of edges as a candidate subgraph, constructing a CSP search space of a corresponding candidate subgraph according to a subgraph growth mode and according to a parent node of the candidate subgraph and a CSP search space of the parent node, including:
[0040] In the case where the fourth node containing the second number of edges is a non-canonical adjacency matrix, if there are other nodes that share a parent node with the fourth node, a fifth node that has the same graph node set and edge set as the fourth node and contains the second number of edges and is a canonical adjacency matrix is found, and a new numbering sequence combination is generated by adjusting the order of the numbers in the order combination of the numbers of the graph nodes in the CSP search space of the fourth node, the generated new numbering sequence combination is added to the CSP search space of the fifth node, and the fourth node is marked as an invalid subgraph.
[0041] In some embodiments, the frequent subgraph mining method of a single graph further includes:
[0042] All frequent nodes and all frequent edges and their child nodes in the initial suboptimal canonical adjacency matrix tree are distributed to each computing node of the distributed system according to the frequent nodes, so that each computing node performs subgraph growth under load balancing to obtain nodes containing the second number of edges.
[0043] In some embodiments, the frequent subgraph mining method of a single graph further includes:
[0044] In the case where it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, according to the CSP search space of the candidate subgraphs of the single graph, the parent node of the node containing the first number of edges in the suboptimal canonical adjacency matrix tree, the corresponding node containing the first number of edges and its child nodes are distributed to each computing node in the distributed system, so that each computing node grows the subgraph according to the canonical adjacency matrix of the single graph and according to the nodes containing the second number of edges that are not marked as invalid subgraphs under load balancing.
[0045] In some embodiments, according to the CSP search space of the candidate subgraph of the single graph, allocating the parent node and the child nodes of the node containing the first number of edges in the suboptimal canonical adjacency matrix tree to each computing node in the distributed system includes:
[0046] Determine a pre-search space for constructing the CSP corresponding to the candidate subgraph according to the number of node numbers between the number of the last graph node in the CSP search space of the node containing the first number of edges as the candidate subgraph and the number of the last graph node in the canonical adjacency matrix of the single graph;
[0047] The pre-search spaces for constructing the CSP of each node containing the first number of edges are grouped and summed according to the parent nodes of the parent nodes of the nodes containing the first number of edges, and the nodes containing the first number of edges in the suboptimal canonical adjacency matrix tree, their parent nodes and their child nodes are distributed to each computing node in the distributed system according to the grouped summation results, so that the sums of the pre-search spaces executed on different computing nodes are similar.
[0048] In some embodiments, when the valid number of dictionary-sorted order combinations of the numbers of the graph nodes in the CSP search space of the current candidate subgraph is less than a set support threshold, marking the corresponding candidate subgraph as an invalid subgraph includes:
[0049] The product of the number of numbering order combinations in the CSP search space of the candidate subgraph and the number of corresponding search methods when the latest node added in the candidate subgraph is searched according to the numbering order of the graph nodes in the canonical adjacency matrix of the single graph is calculated, and the valid number of lexicographical order combinations of the numbers of the graph nodes in the CSP search space of the candidate subgraph is obtained. If the corresponding valid number is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph.
[0050] In some embodiments, when it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, subgraph growth is performed according to the canonical adjacency matrix of the single graph and according to nodes containing a second number of edges that are not marked as invalid subgraphs, so as to update leaf nodes of a suboptimal canonical adjacency matrix tree, and output a frequent subgraph of the single graph according to the leaf nodes that have completed subgraph growth, including:
[0051] In the case where it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, in the case where the sixth node containing the second number of edges as the candidate subgraph is a canonical adjacency matrix and there is a seventh node that is a leaf containing the second number of edges and has a common parent node with the sixth node and the seventh node, a FFSM-Join operation is performed on the sixth node and the seventh node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the sixth node and the seventh node as parent nodes and containing the third number of edges; in the case where the eighth node containing the second number of edges as the candidate subgraph is not marked as an invalid subgraph and is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the eighth node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the eighth node as parent node and containing the third number of edges; wherein the third number minus the second number is equal to one; the eighth node is the same as or different from the sixth node or the seventh node; the child node containing the third number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree;
[0052] Taking the leaf nodes containing the third number of edges as new candidate subgraphs, and constructing the CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node;
[0053] When the number of valid combinations of the lexicographic order of the graph node numbers in the CSP search space of the current new candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph;
[0054] In the case where it is determined according to the canonical adjacency matrix of the single graph that the current new candidate subgraph is a subgraph that has completed growth, a frequent subgraph of the single graph is output according to the current new candidate subgraph.
[0055] In some embodiments, when a first node containing leaves of a first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the first node and the second node as parent nodes and containing a second number of edges, including:
[0056] In the case where a first node of leaves containing a first number of edges is a canonical adjacency matrix and there are other second nodes of leaves containing the first number of edges that share a parent node with the first node, a push-pull dual-mode engine is used to traverse the canonical adjacency matrix of the single graph using a distributed system, and a FFSM-Join operation is performed on the first node and the second node, and a subgraph is grown to obtain child nodes having the first node and the second node as parent nodes and containing a second number of edges;
[0057] In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges, including:
[0058] In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a push-pull dual-mode engine is used in a distributed system to traverse the canonical adjacency matrix of the single graph, and a FFSM-Extension operation is performed on the third node, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges;
[0059] The distributed communication scheduling of the distributed system is implemented by non-blocking communication and dynamic thread resource release.
[0060] According to another aspect of an embodiment of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any of the above embodiments when executing the program.
[0061] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0062] The frequent subgraph mining method, computer device and computer-readable storage medium of a single graph in the embodiment of the present invention can facilitate sequential search of graph nodes and edges in a single graph by generating a canonical adjacency matrix of a single graph and numbering the graph nodes, thereby avoiding repeated searches, which is equivalent to pruning. By constructing a suboptimal canonical adjacency matrix tree and using the nodes therein that meet the matrix requirements to grow the subgraph, it is equivalent to further pruning. Moreover, by marking invalid subgraphs, it is equivalent to pre-pruning, thereby avoiding subsequent invalid subgraph growth. Therefore, the embodiment of the present invention can greatly reduce the search space and improve the mining efficiency of frequent subgraphs through multi-faceted pruning. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0064] Figure 1 It is a schematic diagram of the process of a frequent subgraph mining method of a single graph according to an embodiment of the present invention;
[0065] Figure 2 It is a schematic diagram of the process of a frequent subgraph mining method of a single graph according to a specific embodiment of the present invention;
[0066] Figure 3 is a schematic diagram of a push-pull dual-engine mode in one embodiment of the present invention;
[0067] Figure 4 It is an example of a graph structure of a single graph of 6 nodes in a specific embodiment of the present invention;
[0068] Figure 5 In a specific embodiment of the present invention, Figure 4 The schematic diagram of a single graph showing the growth of subgraphs from stage S(0) to S(3);
[0069] Figure 6 In a specific embodiment of the present invention, Figure 4 The schematic diagram of a single graph undergoing subgraph growth in stage S(4) is shown;
[0070] Figure 7 In a specific embodiment of the present invention, Figure 4 The schematic diagram of a single graph undergoing subgraph growth in stage S(5) is shown;
[0071] Figure 8 In a specific embodiment of the present invention, Figure 4 The schematic diagram of a single graph showing the growth of subgraphs from stage S(6) to S(8);
[0072] Fig. 9 In a specific embodiment of the present invention, Figure 7 Schematic diagram of constructing the search space of the subgraph shown;
[0073] Fig.10 In another specific embodiment of the present invention, Figure 7 Schematic diagram of the subgraph construction search space shown. DETAILED DESCRIPTION
[0074] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0075] First, the terms that may be involved in this description are explained as follows:
[0076] Canonical Adjacency Matrix (CAM): Given the adjacency matrix M of a single graph G, the string generated by concatenating the lower triangular elements and diagonal elements of the adjacency matrix M in order from top to bottom and from left to right is called the encoding sequence of the matrix M, denoted as Code(M). Due to the different ordering of the nodes (graph nodes) of the diagonal elements, the same single graph G will produce multiple encoding sequences. All encoding sequences are further sorted in alphabetical order, and the adjacency matrix M with the largest encoding sequence is called the canonical adjacency matrix of the single graph G.
[0077] Maximal Proper Submatrix: Given an m×m adjacency matrix A, if another n×n adjacency matrix B is obtained by removing the last non-zero item in the lower triangular area (excluding the diagonal) of the adjacency matrix A, then the adjacency matrix B is called the maximal proper submatrix of the adjacency matrix A.
[0078] Suboptimal Canonical Adjacency Matrix (SCAM): If the maximal submatrix N of an adjacency matrix M is a canonical adjacency matrix, then the adjacency matrix M is called a suboptimal canonical adjacency matrix. In particular, if the adjacency matrix M is not a canonical adjacency matrix CAM but N is a canonical adjacency matrix CAM, then the adjacency matrix M is called a Proper Suboptimal CAM, or the canonical adjacency matrix can be considered a special case of the suboptimal canonical adjacency matrix.
[0079] Suboptimal Canonical Adjacency Matrix Tree (SCAM Tree): A subgraph that meets the following conditions and is organized in a tree structure: 1) The root node of the tree is an empty matrix NULL; 2) Each node in the tree represents a different subgraph, represented by its suboptimal canonical adjacency matrix (ie, CAM or SCAM); 3) For any given matrix M on a non-root node, its parent node is the maximal characteristic submatrix of M.
[0080] Inner matrix and outer matrix: Given an adjacency matrix A of a single graph G, if the last row of the adjacency matrix A contains at least two non-zero elements (except the diagonal, that is, there are at least two edges), it is called the inner matrix, otherwise it is the outer matrix.
[0081] Figure 1 is a flow chart of a frequent subgraph mining method for a single graph according to an embodiment of the present invention, see Figure 1 The frequent subgraph mining method of a single graph according to an embodiment of the present invention may include the following steps S110 to S160.
[0082] The specific implementation of steps S110 to S160 will be described in detail below.
[0083] Step S110: Generate a canonical adjacency matrix of a single graph according to the dictionary sorting result of the node labels of the single graph, and number each graph node in the canonical adjacency matrix of the single graph in order of rows or columns.
[0084] In the above step S110, the single graph may refer to a single large graph. A node label may indicate that a graph node has a certain characteristic or belongs to a certain type, and different graph nodes may have the same node label. Node labels may be represented by identifiers that can be sorted, such as numbers or letters, so all node labels may follow a certain dictionary order, such as numerical order or alphabetical order. Each diagonal element in the canonical adjacency matrix of a single graph corresponds to a node in a single graph, and these diagonal elements may be node labels arranged in dictionary order, and the same node labels may be adjacent on the diagonal. The graph nodes in the canonical adjacency matrix of a single graph may be numbered, and an identifier (ID) may be set for each diagonal element (graph node) in the matrix, and the identifiers (numbering) of the graph nodes may have a certain order, for example, when numbering by column, the label may be inserted into a column on the left side of the canonical adjacency matrix, and the column elements may be numbers that increase from top to bottom. The obtained canonical adjacency matrix of a single graph may be used as a data index matrix for subsequent processes such as subgraph growth and support calculation.
[0085] Step S120: Generate an initial suboptimal canonical adjacency matrix tree by searching the canonical adjacency matrix of the single graph in the order of the numbering of the graph nodes, wherein each leaf node of the initial suboptimal canonical adjacency matrix tree includes a first number of edges; the first number is an integer not less than one; the root node of the initial suboptimal canonical adjacency matrix tree does not include the graph nodes and edges of the single graph, the child nodes of the root node are frequent nodes, and the child nodes of the frequent nodes are frequent edges; the CSP search space of the leaf nodes is a lexicographically sorted combination of the numbers of the graph nodes corresponding to the node labels contained therein.
[0086] In the above step S120, each node in the suboptimal canonical adjacency matrix tree represents a subgraph of a single graph (the subgraph essentially corresponds to a subgraph pattern (corresponding to a matrix containing node labels and edge labels), the subgraph or the node corresponds to a CSP search space, the CSP search space contains various possible sequential combinations of the numbers of all nodes in the subgraph pattern, each combination can be called a numbering sequence, and can constitute a row in the matrix corresponding to the CSP search space, at this time, the number of rows is equal to the number of combinations), and the parent node can obtain a child node by expanding an edge. The nodes in the suboptimal canonical adjacency matrix tree can be represented as adjacency matrices, all of which belong to suboptimal canonical adjacency matrices, but may be canonical adjacency matrices or may not be canonical adjacency matrices. The root node of the suboptimal canonical adjacency matrix tree, the frequent nodes containing only one graph node, and the frequent edges containing one edge can be obtained by initialization, so the leaf nodes described in step S120 can refer to frequent edges. All frequent nodes can constitute a frequent point set of a single graph, and all frequent edges can constitute a frequent edge set of a single graph. Among them, the root node can be a null value, the frequent node adds a graph node relative to the root node, and the frequent edge adds an edge and a terminal graph node relative to the frequent node. It should be noted that in this article, the points in a single graph are called "graph nodes", and the nodes in the suboptimal canonical adjacency matrix tree are called "nodes" for the sake of distinction. The CSP search space of frequent nodes is the set of node numbers corresponding to the node labels of the frequent nodes. The CSP search space of frequent edges is the set of combinations of the starting graph node and the ending graph node of the frequent edge. For a node (subgraph or subgraph pattern), one of the numbering order combinations is actually a numbering sequence.
[0087] In specific implementation, the frequent nodes and frequent edges in the suboptimal canonical adjacency matrix tree can be obtained by initialization. Exemplarily, in the above step S120, the initial suboptimal canonical adjacency matrix tree is generated by searching the canonical adjacency matrix of the single graph in the order of the numbering of the graph nodes, which can specifically include the steps of: S121, initializing the suboptimal canonical adjacency matrix tree by searching the canonical adjacency matrix of the single graph in the order of the numbering of the graph nodes, and obtaining the initial suboptimal canonical adjacency matrix tree; wherein the root node of the initial suboptimal canonical adjacency matrix tree is a null value; the first number is equal to one; the CSP search space of the frequent nodes is a combination of the number of the node label of the starting graph node of the corresponding edge and the number of the end graph node label in the lexicographic sorting order.
[0088] In step S121, for example, in the canonical adjacency matrix of a single graph, each graph node is numbered from top to bottom. When it is necessary to generate frequent nodes of a suboptimal canonical adjacency matrix tree, the numbers of the graph nodes in the canonical adjacency matrix of the single graph can be searched from top to bottom in sequence, and the frequent nodes corresponding to each graph node of the single graph (a subgraph containing only one graph node) can be obtained in sequence. When it is necessary to generate frequent edges of a suboptimal canonical adjacency matrix tree, the adjacent edges and adjacent graph nodes below the graph node in the canonical adjacency matrix of the single graph can be searched from top to bottom starting from a frequent node (a graph node, which is the starting graph node of the frequent edge), that is, an edge is expanded and the end graph node of the edge is obtained. The CSP search space of the initialized frequent nodes can be the number of the corresponding graph node, and the CSP search space of the initialized frequent edges can be a lexicographic order combination of the number of the starting graph node and the number of the end graph node. Since the canonical adjacency matrix of the single graph is searched in the order of the graph node numbers, the searched graph node number combinations can be directly arranged in order.
[0089] In other embodiments, more nodes of the suboptimal canonical adjacency matrix tree may be obtained by initialization, for example, nodes including at most two edges may be obtained, or nodes including at most three edges may be obtained, etc.
[0090] Step S130: When the first node of the leaf containing the first number of edges is a canonical adjacency matrix and there is a second node that has other leaves containing the first number of edges and has a common parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges; when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and is an external matrix, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as parent node and containing the second number of edges; wherein the second number minus the first number is equal to one; the third node is the same as or different from the first node or the second node; and the child node containing the second number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree.
[0091] In step S130, the nodes in the suboptimal canonical adjacency matrix tree can be represented by a canonical adjacency matrix (belonging to the suboptimal canonical adjacency matrix) or a non-canonical adjacency matrix (also referred to as the suboptimal canonical adjacency matrix). In addition, frequent nodes and frequent edges can be used as special cases of the external matrix. Before the subgraph is grown, if the suboptimal canonical adjacency matrix tree contains three layers of root nodes, frequent nodes and frequent edges, the frequent edges are leaf nodes. If the bottom node in the suboptimal canonical adjacency matrix tree is a node containing a first number of edges, the node containing the first number of edges is a leaf node. The leaf node containing the first number of edges may be a canonical adjacency matrix (CAM) or a non-canonical adjacency matrix (SCAM). Only in the case of a canonical adjacency matrix, FFSM-Join operation (Fast Frequent Subgraph Mining, FFSM, fast frequent subgraph mining algorithm) is performed with other nodes that may have a common parent node. If it is a non-canonical adjacency matrix, it can participate in the FFSM-Join operation as other nodes that share a parent node with the canonical adjacency matrix. When the leaf node containing the first number of edges is a canonical adjacency matrix, it may also be an inner matrix or an outer matrix. The FFSM-Extension operation can be performed only when the leaf node containing the first number of edges is a canonical adjacency matrix.
[0092] In specific implementation, the specific method of FFSM-Join operation is different depending on whether the two leaf nodes containing the first number of edges having a common parent node are external matrices or internal matrices.
[0093] Exemplarily, in the above step S130, when the first node of the leaves containing the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with it, the first node and the second node are subjected to FFSM-Join operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges. When the first node of the leaves containing the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with it, the following situations S131 to S134 may be specifically included:
[0094] S131, if the first node and the second node are both inner matrices, if and only if f and k are different, grow the subgraph in a first manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing a second number of edges, represented as C m×m , where the adjacency matrix C m×m The elements in are represented as:
[0095]
[0096] Among them, c i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, b i,j represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the second node. The last edge in the canonical adjacency matrix corresponding to the first node is represented by a m,f , m and f represent the number of rows and columns and the total number of edges in the canonical adjacency matrix corresponding to the first node, respectively. The last edge in the adjacency matrix corresponding to the second node is represented by b n,k , n and k represent the number of rows and columns and the total number of edges of the adjacency matrix corresponding to the second node respectively;
[0097] S132: If the first node is an inner matrix and the second node is an outer matrix, the subgraph is grown in a second manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing a second number of edges, represented as C n×n , where the adjacency matrix C n×n The elements in are represented as:
[0098]
[0099] S133: If both the first node and the second node are external matrices, then f≠k∧a m,m =b m,m , the subgraph is grown in the third way, and the adjacency matrix corresponding to the child nodes having the first node and the second node as parent nodes and containing the second number of edges is obtained, which is represented as C m×m , where the adjacency matrix C m×m The elements in are represented as:
[0100]
[0101] S134: If both the first node and the second node are external matrices, the subgraph is grown in the fourth manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing a second number of edges, represented as D (m+1)×(m+1) , where the adjacency matrix D (m+1)×(m+1) The elements in are represented as:
[0102]
[0103] Among them, d i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, bm,j represents the element in the mth row and jth column of the adjacency matrix corresponding to the second node, b m,m Represents the element in the mth row and mth column of the adjacency matrix corresponding to the second node, where m represents the number of rows and columns of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node.
[0104] In the above embodiment, through the FFSM-Join operation, two matrices with a common parent matrix can be connected by adding an edge to generate a new matrix. Given the SCAM of matrices A and B, let a m,f represents the last edge of SCAM(A) (suboptimal canonical adjacency matrix A), b n,k Represents the last edge of SCAM(B) (suboptimal canonical adjacency matrix B), and the FFSM-Join operation can be defined as follows:
[0105] 1) If both matrix A and matrix B are inner matrices, the FFSM-Join operation is represented by Join(A,B)=C if and only if f and k are different, and the element c of matrix C is i,j Satisfy the above formula (1);
[0106] 2) If matrix A is the inner matrix and matrix B is the outer matrix, then the FFSM-Join operation is represented by Join(A,B)=C, and the element c of matrix C is i,j Satisfy the above formula (2);
[0107] 3) If both matrix A and matrix B are external matrices, there are two further cases:
[0108] Case 1: If and only if f≠k∧a m,m =b m,m When FFSM-Join operation is expressed as C m×m , matrix C m×m The element c i,j Satisfy the above formula (3);
[0109] Case 2: FFSM-Join operation represented by D (m+1)×(m+1) , then the matrix D (m+1)×(m+1) There must exist, and the matrix D (m+1)×(m+1) The element d i,j It can be expressed as the above formula (4).
[0110] In addition, in the above step S130, when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, the FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges. Specifically, the steps may include: when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, if the third node is an external matrix, an edge is expanded and the end point graph node of the edge is obtained, and the child node with the third node as the parent node and containing the second number of edges is expressed as B (n+1)×(n+1) , where the matrix B of the child node (n+1)×(n+1) The elements in are represented as:
[0111]
[0112] Among them, a i,j represents the element in the i-th row and j-th column of the matrix corresponding to the third node, b i,j Represents the element in the i-th row and j-th column of the matrix corresponding to the child node containing the second number of edges, e represents the expanded edge, and n represents the destination graph node of the expanded edge (the introduced graph node).
[0113] In the above embodiment, during the FFSM-Extension operation, if the suboptimal canonical adjacency matrix SCAM is an external matrix, a new edge e is added between its last node and a newly introduced node n, and the current subgraph with k edges is expanded into a new subgraph B with k+1 edges. (n+1)x(n+1) , whose elements satisfy the above formula (5).
[0114] Step S140: Taking leaf nodes containing the second number of edges as candidate subgraphs, constructing a CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node.
[0115] Among them, let C k-1 and C k are the SCAM sets of subgraphs with k-1 edges and k edges of a single graph G (k ≥ 2), then the set C k All SCAMs in C can be connected two by two (Join) k-1 Elements or pairs in C k-1 It is obtained by expanding the elements in (Extension).
[0116] The CSP (Constraint Satisfaction Problem) model is: A single large picture A subgraph of a single large graph G and a candidate subgraph g that is isomorphic can be expressed as a constrained CSP (X, D, C), where V represents a node set (frequent node set), E represents an edge set (frequent edge set), V1 represents a node, E1 represents an edge, and L V Represents the node label set of the node set V, L E represents the edge label set of edge set E, Represents the node set V and node label set L V The mapping relationship and edge set E and edge label set L E The set of mapping relationships, A set of node labels representing the subgraph, represents the set of edge labels of the subgraph, A set representing the mapping between nodes and node labels and between edges and edge labels in a subgraph, satisfying the following conditions:
[0117] 1. X is a set of ordered variables (in this embodiment, it can be the sequence number / number of the node), and each node in the subgraph g corresponds to a variable in X;
[0118] 2. By x v ∈X forms a domain space (CSP search space) called D, where all set elements of D are subsets of V;
[0119] 3. The constraint set C satisfies the following three constraints:
[0120] a) The nodes in X are unique;
[0121] b) The nodes in X have the same labels as the nodes in the corresponding subgraph;
[0122] c) The edges formed by the nodes in X have the same labels as the edges in the corresponding subgraph.
[0123] In specific implementation, for the candidate subgraphs (nodes containing the second number of edges) obtained by different methods, CSP (constraint satisfaction problem) search spaces can be constructed by different methods. Exemplarily, the above step S140 may specifically include the following steps: S1411, when the node containing the leaf of the second number of edges is obtained by the subgraph growth according to the first method or the third method as the candidate subgraph, the subgraph corresponding to the dictionary sorting order combination of the number of the graph nodes in the CSP search space of the first node and the CSP search space of the second node is deduplicated to obtain the CSP search space of the candidate subgraph; S1412, when the node containing the leaf of the second number of edges is obtained by the subgraph growth according to the second method or the fourth method as the candidate subgraph, the subgraph corresponding to the dictionary sorting order combination of the number of the graph nodes in the two CSP search spaces corresponding to the common part of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node is deduplicated, and spliced to the CSP search space corresponding to the remaining nodes in the adjacency matrix corresponding to the second node except the common part of the canonical adjacency matrix corresponding to the first node, to obtain the CSP search space of the candidate subgraph.
[0124] In the above step S1411, under this growth mode, if the node set and edge set of the first node and the second node are the same, then after the two nodes perform FFSM-Extension operation to expand one edge, the specific subgraphs corresponding to the two search spaces corresponding to the obtained subgraph patterns may be the same, so deduplication is required. In other words, it can be said that the greatest common subset of the CSP search space of the first node and the CSP search space of the second node is taken.
[0125] In another example, the above step S140 may specifically include the following step: S1421, when the node containing the leaf of the second number of edges obtained by performing FFSM-Extension operation subgraph growth is used as the candidate subgraph, the CSP search space of the third node is obtained, and the number of the terminal graph node added by the candidate subgraph relative to the third node is added to the end of the dictionary sorting order combination of the numbers of each graph node in the CSP search space of the third node to obtain the CSP search space of the candidate subgraph. In this step S1421, general subgraph growth is performed, and the number of the terminal graph node of the newly expanded edge is added to the end of the number combination (number sequence) in the previous search space.
[0126] In a further embodiment, more accurate pruning can be performed for nodes that do not conform to the dictionary sorting. Exemplarily, the above step S140 may specifically include the following step: S1431, in the case where the fourth node containing the second number of edges is a non-standard adjacency matrix, if there are other nodes that share a parent node with the fourth node, then find a fifth node that has the same graph node set and edge set as the fourth node and contains the second number of edges and is a standard adjacency matrix, and generate a new numbering sequence combination by adjusting the order of the numbers in the order combination of the numbers of the graph nodes in the CSP search space of the fourth node, add the generated new numbering sequence combination to the CSP search space of the fifth node, and mark the fourth node as an invalid subgraph.
[0127] In step S1431, the CSP search space of the node of the non-standard adjacency matrix is transferred to the CSP search space of the node of the standard adjacency matrix corresponding to the node.
[0128] Step S150: When the valid number of lexicographically sorted order combinations of the numbers of the graph nodes in the CSP search space of the current candidate subgraph is less than a set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph.
[0129] Among them, one node corresponds to one candidate subgraph, that is, one subgraph pattern. The support calculation of the candidate subgraph g is equivalent to finding the valid number (valid allocation number) of each variable (the number of number combinations in the CSP search space) in the CSP model, that is, for each variable in X, at least τ (support) nodes can be included in the corresponding CSP search space D. For the CSP search space of the candidate subgraph that is not marked as an invalid subgraph, unless otherwise specified (the number combination removed due to deduplication is an invalid number combination), it can be considered that the number combination in its CSP search space is valid.
[0130] In step S150, for a candidate subgraph, it may contain some graph nodes and some edges, and the combination order in the CSP search space is different. Different combinations correspond to different specific subgraphs (a subgraph pattern can correspond to one or more specific subgraphs, depending on the number combination method in the CSP search space). Each combination can correspond to a row of the matrix of the CSP search space, so the number of rows can be equal to the number of combinations, which can be the number of valid allocations for the candidate subgraph. The valid number can also be called support. If the support threshold requirement is met, it can be retained. If not, subsequent subgraph growth can be stopped, and it will not be selected as a frequent subgraph, thereby playing a role of pre-pruning.
[0131] In specific implementation, step S150 may specifically include the steps of: calculating the product of the number of numbering order combinations in the CSP search space of the candidate subgraph and the number of corresponding search methods when the latest node added to the candidate subgraph is searched according to the numbering order of the graph nodes in the canonical adjacency matrix of the single graph, obtaining the valid number of lexicographical sorting order combinations of the numbers of the graph nodes in the CSP search space of the candidate subgraph, and when the corresponding valid number is less than the set support threshold, marking the corresponding candidate subgraph as an invalid subgraph.
[0132] The newly added node may be the last node added in the candidate subgraph. The number of corresponding search methods when searching for the newly added node in the order of the number of the graph nodes in the canonical adjacency matrix of the single graph may refer to the number of possible methods for searching the adjacent nodes of a node backward according to the canonical adjacency matrix of the single graph.
[0133] Step S160: When it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, subgraph growth is performed according to the canonical adjacency matrix of the single graph and according to the nodes containing a second number of edges that are not marked as invalid subgraphs, so as to update the leaf nodes of the suboptimal canonical adjacency matrix tree, and output the frequent subgraphs of the single graph according to the leaf nodes that have completed subgraph growth.
[0134] In the above step S160 , when the sub-graph growth is not completed, the sub-graph growth may continue to be performed using the method in the above steps S130 to S150 .
[0135] Exemplarily, during specific implementation, when it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, the above-mentioned step S160 may specifically include the following steps: S161, when it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, when the sixth node of the candidate subgraph containing the second number of edges is a canonical adjacency matrix and there is a seventh node that is a leaf containing the second number of edges and has a common parent node with the sixth node and the seventh node, a FFSM-Join operation is performed on the sixth node and the seventh node according to the canonical adjacency matrix of the single graph, and the subgraph is grown to obtain a child node with the sixth node and the seventh node as parent nodes and containing the third number of edges; when the eighth node of the candidate subgraph containing the second number of edges is not marked as an invalid subgraph, is a canonical adjacency matrix and is an external matrix, a FFSM-Extension operation is performed on the eighth node according to the canonical adjacency matrix of the single graph. on operation, the subgraph grows to obtain a child node with the eighth node as the parent node and containing the third number of edges; wherein the third number minus the second number is equal to one; the eighth node is the same as or different from the sixth node or the seventh node; the child node containing the third number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree; S162, taking the leaf node containing the third number of edges as a new candidate subgraph, according to the subgraph growth method and according to the parent node of the candidate subgraph and the CSP search space of the parent node, the CSP search space of the corresponding candidate subgraph is constructed; S163, when the valid number of the dictionary sorting order combination of the number of the graph nodes in the CSP search space of the current new candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph; S164, when it is judged that the current new candidate subgraph is a subgraph that has completed the growth according to the canonical adjacency matrix of the single graph, the frequent subgraphs of the single graph are output according to the current new candidate subgraph.
[0136] In the above step S161, only the subgraphs that are not marked as invalid subgraphs can be grown, which is equivalent to pruning.
[0137] In the frequent subgraph mining methods of a single graph in the above-mentioned embodiments, by generating a canonical adjacency matrix of a single graph and numbering the graph nodes, it is convenient to sequentially search the graph nodes and edges in a single graph, avoiding repeated searches, which is equivalent to pruning. By constructing a suboptimal canonical adjacency matrix tree and using the nodes that meet the matrix requirements to grow the subgraph, it is equivalent to further pruning. Moreover, by marking invalid subgraphs, it is equivalent to pre-pruning, avoiding subsequent invalid subgraph growth. Therefore, the embodiments of the present invention can greatly reduce the search space through multi-faceted pruning, lack of directional optimization in data structure optimization, space occupancy, etc., and improve the mining efficiency of frequent subgraphs.
[0138] In order to further reduce the search space, the nodes in the suboptimal canonical adjacency matrix tree whose order of graph nodes does not conform to the dictionary order can be pruned. For example, Figure 1 The method may further include step: S170, when the numbering of the graph nodes in the suboptimal adjacency matrix corresponding to the nodes of the leaves including the first number of edges does not conform to the lexicographic sorting order, marking the corresponding nodes of the leaves including the first number of edges as invalid subgraphs.
[0139] In this case, in the above step S130, when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, the third node is subjected to FFSM-Extension operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges. Specifically, the steps may include: when the third node of the leaf containing the first number of edges is a canonical adjacency matrix, an external matrix and is not marked as an invalid subgraph, the third node is subjected to FFSM-Extension operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges. In this way, the nodes marked as invalid subgraphs are no longer subjected to Extension growth, which is equivalent to pruning.
[0140] The frequent subgraph mining method of a single graph described in the above embodiments can be executed on a single machine or a distributed system. Running on a distributed system can improve the execution speed.
[0141] In some embodiments, a distributed system may be used to perform calculations such as subgraph growth and search space construction. Prior to this, load balancing may be performed on the computing nodes of the distributed system.
[0142] For example, Figure 1 The frequent subgraph mining method of a single graph shown may further include the step of: S180, allocating all frequent nodes and all frequent edges and their child nodes in the initial suboptimal canonical adjacency matrix tree to each computing node of the distributed system according to the frequent nodes, so that each computing node performs subgraph growth under load balancing to obtain nodes containing the second number of edges. In step S180, the graph nodes and edges of the single graph may be relatively evenly allocated to the computing nodes of the distributed system to balance their load.
[0143] In other embodiments, a distributed system may be used to perform calculations such as search space construction. After the subgraph grows, the computing nodes of the distributed system may be load balanced according to the search space conditions of the nodes.
[0144] For example, Figure 1The frequent subgraph mining method of a single graph shown may further include the step: S190, when it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, according to the CSP search space of the candidate subgraphs of the single graph, the parent node of the node containing the first number of edges in the suboptimal canonical adjacency matrix tree, the corresponding node containing the first number of edges and its child nodes are distributed to each computing node in the distributed system, so that each computing node grows the subgraph according to the canonical adjacency matrix of the single graph and according to the nodes containing the second number of edges that are not marked as invalid subgraphs under load balancing.
[0145] In this step S190, it is possible to check whether the current candidate subgraph can also expand new edges by searching the canonical adjacency matrix of a single graph. If it can, it means that the growth has not been completed. If it cannot, it means that the subgraph growth has been completed. If the first number is k, the nodes containing k edges and k+1 edges on the suboptimal canonical adjacency matrix tree can be divided into different branches according to the nodes containing k-1 edges. The child nodes of each node containing k-1 edges and the child nodes of its child nodes can correspond to a branch. Such branches can be used as units to distribute these units to multiple computing nodes. A computing node can contain one or more such units, with the purpose of balancing the amount of calculation on each computing node. In addition, if the candidate subgraph is an invalid subgraph, the subgraph growth can be omitted, and it is not necessary to allocate it to the computing node. In fact, pruning is performed. In the case of incomplete subgraph growth, subgraph growth similar to step S130 can be continued, and steps such as search space construction and pruning can also be performed similar to steps S140 and S150 to improve search efficiency.
[0146] In specific implementation, in the above step S190, according to the CSP search space of the candidate subgraph of the single graph, the parent nodes and their child nodes of the nodes containing the first number of edges in the suboptimal canonical adjacency matrix tree are allocated to each computing node in the distributed system, which may specifically include the steps of: S191, determining the pre-search space for constructing the CSP corresponding to the candidate subgraph according to the number of node numbers between the last graph node number in the CSP search space of the node containing the first number of edges as the candidate subgraph and the last graph node number in the canonical adjacency matrix of the single graph; S192, grouping and summing the pre-search spaces for constructing the CSP of each node containing the first number of edges according to the parent node of the parent node of the node containing the first number of edges, and allocating the nodes containing the first number of edges in the suboptimal canonical adjacency matrix tree, their parent nodes and their child nodes to each computing node in the distributed system according to the grouping and summing results, so that the totals of the pre-search spaces executed on different computing nodes are similar.
[0147] In step S191, for example, the CSP search space of a node containing two edges is composed of the numbering sequence of the graph nodes it contains (1, 2, 3), and the last graph node in the canonical adjacency matrix of a single graph is numbered 10 (a total of 10 graph nodes may be included), then 7 obtained by subtracting 3 from 10 can be used as the pre-search space of the node containing two edges. The larger the pre-search space, the greater the amount of calculation required for subsequent subgraph growth, construction of search space, etc. In step S192, for example, the parent node of the parent node of the node containing two edges is a frequent node, and for each frequent node, the sum of the search spaces of all the child nodes of all the child nodes of the frequent node (i.e., the nodes containing two edges) can be calculated. According to the sum of the search spaces corresponding to each frequent node, the frequent nodes and the child nodes and the child nodes of the child nodes can be allocated to balance the sum of the search spaces corresponding to each calculation node.
[0148] When the solution is implemented using a distributed system, the traversal method can be optimized.
[0149] Exemplarily, in the above step S130, when the first node of the leaves containing the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges. Specifically, the steps may include: when the first node of the leaves containing the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node, a distributed system is used to traverse the canonical adjacency matrix of the single graph using a push-pull dual-mode engine, and a FFSM-Join operation is performed on the first node and the second node, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges.
[0150] In addition, in the above step S130, when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, the FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges. Specifically, the steps may include: when the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, using a distributed system to adopt a push-pull dual-mode engine to traverse the canonical adjacency matrix of the single graph, performing the FFSM-Extension operation on the third node, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges.
[0151] The distributed communication scheduling of the distributed system can be realized by non-blocking communication and dynamic thread resource release, thereby optimizing distributed message communication and other aspects, overcoming the problem of lack of directional optimization in distributed message communication and other aspects in the prior art.
[0152] In one embodiment, a frequent subgraph mining method for a single graph includes: finding all frequent subgraphs of the single graph through a distributed subgraph growth algorithm; improving the computing efficiency of the distributed engine using a load balancing algorithm; quickly finding a set of frequent subgraphs that meet conditions through a distributed support algorithm, and reducing the search space of the algorithm using pre-search pruning and self-downward pruning algorithms.
[0153] The input of the distributed subgraph growth algorithm is: the adjacency matrix M of a single large graph G. The nodes and edges of the single large graph are traversed to obtain the edges whose appearance frequency is greater than a certain value to form the frequent node set S(0) in the single large graph, and the edges whose appearance frequency is greater than a certain value to form the frequent edge set S(1).
[0154] The process of subgraph growth and support calculation includes: inputting a frequent subgraph set with k-1 edges, for example, inputting a frequent subgraph set with 2 edges; the frequent subgraph set with 0 edges and the frequent subgraph set with 1 edge are obtained by initialization; the purpose of the distributed subgraph growth algorithm is to output: the newly generated frequent subgraph set Sk.
[0155] The process of subgraph growth using the distributed subgraph growth algorithm is as follows: the frequent subgraphs (suboptimal canonical adjacency matrix SCAM) in the frequent subgraph set S(k-1) are divided into a group if they have a common parent CAM (canonical adjacency matrix); the following operations are performed on each group of frequent subgraphs divided by the common parent CAM: FFSM-Join operations are performed on the pairwise matrices (SCAM) of the frequent subgraphs in a group to obtain a new k-edge frequent subgraph, which is added to the frequent subgraph set S(k); if the CAM of the frequent subgraph in a group (the first time it is SCAM) is an external matrix, FFSM-Extension operations are performed on the frequent subgraph to generate the corresponding new k-edge frequent subgraph, which is added to the frequent subgraph set S(k); the frequent subgraphs in the k-edge frequent subgraph set S(k) are renumbered, and then S(k) is output.
[0156] The input of the distributed support algorithm: the subgraph G (a set of subgraphs containing all g), the support threshold τ (set); constructing the CSP (constraint satisfaction problem) search space Dg through the subgraph set G; the candidate subgraph g (obtained by the CSP method); each candidate subgraph g corresponds to a search space Dg.
[0157] The input of the load balancing algorithm: the candidate subgraph set S on the Partition (distributed server nodes); sort the candidate subgraph set according to the CSP search space; redistribute the frequent subgraph set in each Partition (server node) so that the size of the CSP search space (the sum of all Dg corresponding to all g in S) in each Partition is roughly equal; the output of the load balancing algorithm: the adjusted Partition candidate subgraph set Sbalance; using the distributed server nodes, the process of finding a frequent subgraph that meets the conditions using the distributed support algorithm is as follows: if the number of adjacent nodes of the variable v in the search space Dg is greater than one, according to the node uniqueness constraint, the redundant adjacent nodes are removed; if the number of valid assignments of the variable v in the search space Dg (the number of nodes in the search space) is less than the support threshold τ, the support requirement is not met and false is returned (true will be returned for the remaining nodes); invalid assignment schemes in the search space Dg are marked (marked nodes are not searched), and the search space of its sub-SCAM can then not search the marked nodes.
[0158] In addition, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any of the above embodiments when executing the program.
[0159] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0160] The following is an explanation of the embodiments of the present invention with reference to specific examples, so that those skilled in the art can better understand the present invention.
[0161] In a specific embodiment, a distributed computing engine is used to implement large-scale single-graph frequent subgraph mining. The method implements frequent subgraph enumeration by constructing a SCAM tree (suboptimal canonical adjacency matrix), and implements frequent subgraph screening by incrementally calculating support during the growth of the subgraph, supporting rapid search for frequent subgraphs of a single large graph in a distributed environment. The main process includes the generation of a CAM (canonical adjacency matrix) for a single large graph, initialization of the SCAM tree, subgraph growth (supports both stand-alone and distributed environments), incremental support calculation, SCAM tree pre-pruning, and dynamic load balancing. Specifically, see Figure 2 The method of this embodiment includes the following steps (hereinafter, "node" refers to a node of a SCAM tree or a node of a single graph (graph node), and the specific meaning is determined according to the specific description):
[0162] S1. First, initialize the adjacency matrix of a single graph, that is, use the matrix dictionary sorting algorithm to generate a unique CAM matrix for the large graph, and use it as the data index matrix for the subgraph growth and incremental support calculation process; and renumber the nodes of the graph in the initialized CAM matrix so that the nodes of the CAM matrix increase in order from small to large in rows or columns;
[0163] S2. The CAM matrix will be traversed in sequence during the growth of the SCAM tree. In a distributed environment, the CAM matrix can be load balanced to distribute the nodes and edge data in the CAM to different computing nodes.
[0164] S3. The CSP model is used to calculate the subgraph support, that is, the set of frequent subgraphs containing τ (support) in the definition space D in the CSP model; wherein the space D is incrementally constructed and pre-pruned to reduce the search space of the algorithm;
[0165] S4. After the incremental support calculation, if the subgraph growth is not completed, the distributed computing engine performs dynamic load balancing according to the size of the definition space D on the distributed nodes to optimize the computing resources of the distributed cluster and improve the efficiency of the algorithm.
[0166] Among them, the distributed graph computing engine adopts a push-pull dual-mode engine and CAM index, such as Figure 3 As shown in the figure, in the two processes of subgraph growth and support calculation, the adjacency list of the nodes needs to be traversed. According to the number of active nodes, the push mode is adopted when the active points are in a sparse state, and the pull mode is adopted when the active nodes are in a dense state to improve the efficiency of graph traversal. In addition, in a distributed computing environment, the distributed communication scheduling adopts non-blocking communication and dynamic thread resource release to achieve effective overlap of computing and communication, so as to improve the overall efficiency of the distributed engine.
[0167] In the above step S1, the SCAM tree construction may specifically include the following steps:
[0168] S11. The input of SCAM tree construction is the adjacency matrix M of a single large graph G, which is generated into a CAM matrix after dictionary sorting. The CAM matrix can uniquely represent the large graph. The node numbers of the graph on the CAM matrix are arranged in order from small to large.
[0169] For example, Figure 4 As shown, a single large graph G contains 6 nodes, namely, A, B, B, C, D, A, of which there are four node labels A, B, C, D. The 6 nodes are sorted in the lexicographic order of the node labels to generate the adjacency matrix M, as shown in Figure 5The "standard adjacency matrix" in , where x, x, y, z, y, y, z, x are all the edges in a single graph G, and edges with the same label have the same attributes. Number the six nodes in sequence by column to get the sequence (number) of the graph nodes, i.e., 1, 2, 3, 4, 5, 6;
[0170] S12. After the CAM is generated, the initial load balancing needs to be performed. The initial load balancing distributes the CAM to different nodes of the computing cluster according to the principle of even distribution;
[0171] S13. Traverse the rows or columns of the CAM matrix, extract nodes with the same label to generate the frequent node set S(0) of the large graph G, the definition domain space (CSP search space) of the frequent node set S(0) in CSP is its node number; the parent node of the frequent node set S(0) in the SCAM tree is the NULL node;
[0172] For example, Figure 5 As shown, the root node in the SCAM tree is node NULL, and the frequent node set S(0) is the child node of node NULL, including nodes A, B, C, and D (node labels). Each tree node (graph node label) corresponds to a domain space (matrix) (CSP search space) represented by a sequence number, such as A corresponds to 1 and 6, B corresponds to 2 and 3, C corresponds to 4, and D corresponds to 5.
[0173] S14. Traverse the frequent node adjacency list in S(0), and generate the frequent edge set S(1) of the SCAM tree with the corresponding frequent node label as the parent node; the domain space of S(1) in CSP is the end point sequence number (the number of the end point graph node) of the edge in the corresponding vertex adjacency list (only select the edge with the end point sequence number greater than the starting point, that is, intercept the adjacency list from the bottom or right of the diagonal element in the CAM matrix of a single graph G); for example, Figure 5 As shown, the child nodes of the frequent node set S(0) are the frequent edge set S(1), and the frequent edge set S(1) includes nodes AB (corresponding to the domain spaces (numbering sequence combination) 1, 2 and 2, 3), AC (corresponding to the domain spaces 1, 4), BB (corresponding to the domain spaces 2, 3), BD (corresponding to the domain spaces 2, 5 and 3, 5), CA (corresponding to the domain spaces 4, 6), and DA (corresponding to the domain spaces 5, 6). Among them, the node labels in nodes CA and DA do not conform to the dictionary order, so they are marked as invalid subgraphs (dashed boxes), and no Extension operation is performed, but they can participate in Join operations;
[0174] S15. After generating the frequent node set S(0) and the frequent edge set S(1), the initialization process of the SCAM tree is completed; Figure 5 As shown, after initialization, the root node of the SCAM tree, the frequent point set S(0) and the frequent edge set S(1) are obtained.
[0175] The subgraph growth algorithm is to generate a subgraph set S(K) child node containing K edges based on the elements in the subgraph set (node set) S(K-1) containing K-1 edges in SCAM as the parent node. After SCAM is initialized, the frequent node set S(0) and the frequent edge set S(1) are known, among which the subgraph set S(K) containing K edges is the subgraph set with K edges (the node set of the SCAM tree); the node matrices generated in the SCAM tree are all CAM or SCAM, among which the elements in the frequent node set S(0) and the frequent edge set S(1) can be regarded as special cases of the CAM external matrix.
[0176] In the above step S2, the SCAM tree growth (subgraph growth) process may specifically include the following steps:
[0177] S21. This process will realize the SCAM tree growth process when K>=2. The node matrices in S(K) all take the node matrices in S(K-1) as parent matrices, where only CAM nodes can be used as parent matrices, and SCAM nodes only participate in the subgraph growth operation; Figures 5 to 8 As shown, the subgraph matrices and CSP search space matrices of the subgraph set S(2) containing 2 edges, the subgraph set S(3) containing 3 edges, the subgraph set S(4) containing 4 edges, the subgraph set S(5) containing 5 edges, the subgraph set S(6) containing 6 edges, the subgraph set S(7) containing 7 edges, and the subgraph set S(8) containing 8 edges are shown. Among them, the label j3.1 indicates that the FFSM-Join operation is performed according to the first method or the third method to grow the subgraph, the label e indicates that the FFSM-Extension operation is performed to grow the subgraph, the label j2 indicates that the FFSM-Join operation is performed according to the second method or the fourth method to grow the subgraph, the nodes marked with dotted boxes indicate that the Extension operation is no longer performed but can participate in the Join operation, and the label "prune" indicates an invalid subgraph that needs to be pruned. In addition, the subgraphs marked with dashed boxes are represented by solid box matrices with arrows pointing to the common parent nodes, and the search space of the dashed box subgraphs is increased to the matrix pointed to by the arrows.
[0178] S22. In step S21, a CAM matrix in S(K-1) is selected as the parent node, and FFSM-Join and FFSM-Extension operations can be performed to achieve subgraph growth. The specific growth operation can be divided into the following cases:
[0179] 1. If the selected parent node has a common parent node with other SCAMs in S(K-1) (i.e., a node in S(K-2)), the two matrices will be FFSM-Joined, and the subgraph selected as the parent matrix will expand one edge from the other matrices to form a node in S(K);
[0180] 2. When the selected parent node is an external matrix, the FFSM-Extension operation can be performed on the matrix. The parent node will expand one edge from the adjacency list of the node ranked last in the parent node matrix to form a node in S(K). This process will continue to cycle as the subgraph grows, and all appropriate edges in the adjacency list will be added (indicated by the fact that the sequence number of the end point of the newly added edge in the domain space D of the CSP must be greater than the sequence number of the starting point);
[0181] 3. In the above two operations 1 and 2, the order of formula (1), formula (2), formula (3) (case 1), formula (4) (case 2), and formula (5) can be followed. The generated subgraphs will be arranged in the order of the dictionary sequence in CAM from small to large, which will ensure that the newly generated subgraphs are comprehensive and non-redundant.
[0182] S23. When the operation of step S22 stops, the growth process of S(K) ends, and the next round of subgraph growth can be entered after step S4.
[0183] In the above step S3, the specific process of calculating the incremental support is as follows:
[0184] S31. The input for calculating the subgraph support is the candidate subgraph g and the parent node g of the candidate subgraph g. k-1 (The number is 1 to 2, because if the FFSM-Join operation is performed, there will be two parent nodes) and g k-1 The CSP search space D(g k-1 ), and support threshold τ;
[0185] S32. The incremental construction process of the domain space D in the CSP model is carried out simultaneously in the SCAM initialization phase (step S1) and the subgraph growth phase (step S2); it can be obtained by D(g k-1 ) and a single graph G to construct a CSP search space D(g k ), mainly in the following situations:
[0186] 1. If the candidate subgraph g consists of two parent nodes g k-1 By calculating and generating through formula (1) and formula (3) (case 1) in FFSM-Join, we can directly take two D(g k-1 ) space (the case where different node number combinations in the same subgraph pattern correspond to the same specific subgraph is removed) as D(g k );like Figure 7 and Fig. 9As shown, the graph nodes A, B, B, C, D and the two nodes (subgraphs) containing 5 edges correspond to the CSP search spaces ((1,2,3,4,5), (1,3,2,4,5)) and (1,2,3,4,5), respectively. The numbering combination (1,3,2,4,5) in the CSP search space ((1,2,3,4,5), (1,3,2,4,5)) is converted from the CSP search space (1,2,3,4,5). When a node containing graph nodes A, B, B, C, D and 6 edges is obtained by performing FFSM-Join with two nodes containing graph nodes A, B, B, C, D and 5 edges as parent nodes, the search space of the node is obtained by removing duplicates or taking the greatest common subset of the CSP space containing graph nodes A, B, B, C, D and 5 edges. That is, by removing duplicates from the CSP search spaces ((1,2,3,4,5), (1,3,2,4,5)) (where the numbering combination (1,3,2,4,5) is converted from the CSP search space (1,2,3,4,5) and is not considered) and (1,2,3,4,5), the CSP search space (1,2,3,4,5) is obtained as the generated CSP search space containing graph nodes A, B, B, C, D and 6 edges.
[0187] 2. If the candidate subgraph g consists of two parent nodes g k-1 Generate through the calculation of formula (2) and formula (4) (case 2) in FFSM-Join, for the parent node g k-1 The common part of the A matrix corresponding to one of the parent nodes and the B matrix corresponding to the other parent node is taken as the greatest common subset, and the search space of the remaining elements of the B matrix is combined as D(g k );like Figure 7 and Fig.10 As shown, the common part of the matrices corresponding to the two nodes (i.e., the part containing graph nodes A, B, B, C, D and 5 edges) obtained by FFSM-Join operation (j3.1) and the node containing graph nodes A, B, B, C, D, A and 5 edges, is the common part of the search spaces (1,2,3,4,5) and (1,2,3,4,5,6), i.e., (1,2,3,4,5), and then merged into the search space 6 of the remaining element A of the latter node, and the CSP search space containing graph nodes A, B, B, C, D, A and 6 edges generated by FFSM-Join operation with these two nodes as parent nodes is obtained, i.e., (1,2,3,4,5,6).
[0188] 3. If the candidate subgraph g is generated by FFSM-Extension operation, the parent node g is retainedk-1 The search space D(g k-1 ), and fill the newly added edge endpoint number into D(g k-1 ) to generate the last column of D(g k );
[0189] 4. When the adjacency matrix of the candidate subgraph g is a non-CAM matrix, if there is still a subgraph with the same parent node before the candidate subgraph g, then the CAM matrix subgraph g' corresponding to the candidate subgraph g can be found. The search space D(g k ) is added to the search space D(g') of the CAM matrix subgraph g' k )middle.
[0190] In the above two cases 1 and 2, by taking the greatest common subset, the newly generated search space can be reduced, which can be regarded as a pruning process. In the above two cases 3 and 4, the newly generated search space can be increased and the number of subgraphs can be increased.
[0191] S33. If the support threshold condition is not met, the incremental support calculation outputs false; specifically, if D(g k ) is less than the threshold τ, false is returned; k ) is equal to D(g k ) is the product of the number of rows in the matrix or the number of search spaces and the number of elements in the domain of the last newly added node label. Fig. 9 As shown, a node's D(g k ) matrix includes two rows (1,2,3,4,5) and (1,3,2,4,5), then the number of rows or search spaces is 2, and the backward search method of the last newly added node label D has only one edge x (the end point graph node is A), that is, the domain of the graph node is 1, then D(g k ) is 2 times 1, which is 2.
[0192] S34. After completing the support calculation of this round, mark the invalid assignment schemes in the search space (i.e., the SCAM nodes that return false), and no subgraph growth will be performed for this node (including this node); this process is the pre-pruning process;
[0193] S35. If the support threshold condition is met, the incremental support calculation output is true; specifically, if D(g k ) is greater than or equal to the threshold τ, and the result is true.
[0194] In the above step S4, the method for load balancing in the second stage can perform load balancing once after each increase, or perform load balancing once when the load reaches a certain level. The specific steps can be as follows:
[0195] S41. The input for load balancing is the candidate subgraph set S(K) on the Partition (computing node); wherein a candidate subgraph refers to a subgraph pattern (corresponding to a subgraph matrix);
[0196] S42. The factor that affects the load balancing of the candidate subgraph set S(K) is that the FFSM-Extension process of subgraph growth needs to traverse the edges whose end number in the adjacency list of the last node in D(g) is greater than the current maximum number assigned. This search space becomes the pre-search space for CSP construction;
[0197] S43. The output goal during load balancing is to adjust each Partition candidate subgraph set S'(K) so that the CSP pre-search space size of all nodes in S'(K) is roughly the same;
[0198] S44. The CSP pre-search space of each element in the candidate subgraph set S(K) is roughly equal to N-Vmax, where N is the total number of nodes in the graph G, and Vmax is equal to the minimum value of the node sequence number in the maximum value set of all allocations in D(g).
[0199] S45. group and sum the CSP pre-search space in the candidate subgraph set S(K) according to S(K-2), and repartition it so that the sum of the CSP pre-search space of each partition is approximately equal;
[0200] S46. Redistribute the frequent subgraph sets in each Partition according to the repartitioning result.
[0201] The frequent subgraph mining method of this embodiment realizes SCAM tree growth through an ordered CAM matrix, and can easily promote the traditional FFSM algorithm to a distributed computing environment through node sorting; in the implementation process of the FFSM algorithm, the search space of subgraph growth is effectively reduced by orderly traversing the CAM matrix and adopting the method of backward search of the end node, and the joint calculation of subgraph growth and support calculation is realized through incremental support calculation; while the traditional FFSM algorithm has a large search space and high complexity in the process of support calculation. In a distributed environment, through two-stage load balancing (the first stage realizes the load balancing of the CAM matrix, and the second stage dynamically adjusts the load balancing of the CSP search space), push-pull dual-mode computing mode (realizing distributed adjacency list access), non-blocking messages, and dynamic thread resource management, the overlap of computing and communication is realized, and the implementation efficiency of the algorithm is improved.
[0202] In summary, the frequent subgraph mining method, computer device and computer-readable storage medium of a single graph in the embodiment of the present invention can facilitate sequential search of graph nodes and edges in a single graph by generating a canonical adjacency matrix of a single graph and numbering the graph nodes, thereby avoiding repeated searches, which is equivalent to pruning. By constructing a suboptimal canonical adjacency matrix tree and using the nodes therein that meet the matrix requirements to grow the subgraph, it is equivalent to further pruning. Moreover, by marking invalid subgraphs, it is equivalent to pre-pruning, thereby avoiding subsequent invalid subgraph growth. Therefore, the embodiment of the present invention can greatly reduce the search space and improve the mining efficiency of frequent subgraphs through multi-faceted pruning.
[0203] In the description of this specification, the description with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. The order of steps involved in each embodiment is used to schematically illustrate the implementation of the present invention, and the order of steps is not limited and can be appropriately adjusted as needed.
[0204] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0205] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0206] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0207] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0208] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A frequent subgraph mining method for a single graph, characterized in that: include: Generate a canonical adjacency matrix of a single graph according to the dictionary sorting result of the node labels of the single graph, and number each graph node in the canonical adjacency matrix of the single graph in the order of rows or columns; An initial suboptimal canonical adjacency matrix tree is generated by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes, wherein each leaf node of the initial suboptimal canonical adjacency matrix tree includes a first number of edges; the first number is an integer not less than one; the root node of the initial suboptimal canonical adjacency matrix tree does not include the graph nodes and edges of the single graph, the child nodes of the root node are frequent nodes, and the child nodes of the frequent nodes are frequent edges; the CSP search space of the leaf nodes is a combination of the lexicographic sort order of the numbers of the graph nodes corresponding to the node labels contained therein; In the case where the first node of the leaf containing the first number of edges is a canonical adjacency matrix and there are other second nodes with leaves containing the first number of edges that share a parent node with the first node, the first node and the second node are subjected to FFSM-Join operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the first node and the second node as parent nodes and containing the second number of edges; in the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and is an external matrix, the third node is subjected to FFSM-Extension operation according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as parent node and containing the second number of edges; wherein the second number minus the first number is equal to one; the third node is the same as or different from the first node or the second node; the child node containing the second number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree; Taking the leaf nodes containing the second number of edges as candidate subgraphs, constructing a CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node; When the number of valid combinations of the lexicographic order of the graph nodes in the CSP search space of the current candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph; In the case that it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, subgraph growth is performed according to the canonical adjacency matrix of the single graph and according to nodes containing a second number of edges that are not marked as invalid subgraphs, so as to update leaf nodes of a suboptimal canonical adjacency matrix tree, and frequent subgraphs of the single graph are output according to the leaf nodes that have completed subgraph growth.
2. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: An initial suboptimal canonical adjacency matrix tree is generated by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes, including: The suboptimal canonical adjacency matrix tree is initialized by searching the canonical adjacency matrix of the single graph in the order of the numbers of the graph nodes to obtain an initial suboptimal canonical adjacency matrix tree; wherein the root node of the initial suboptimal canonical adjacency matrix tree is a null value; the first number is equal to one; and the CSP search space of the frequent nodes is a combination of the lexicographically sorted order of the node label numbers of the starting graph nodes of the corresponding edges and the node label numbers of the end graph nodes.
3. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: The method further comprises: In the case where the numbers of the graph nodes in the suboptimal adjacency matrix corresponding to the nodes of the leaves including the first number of edges do not conform to the lexicographic sort order, marking the corresponding nodes of the leaves including the first number of edges as invalid subgraphs; In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges, including: When the third node of the leaf containing the first number of edges is a canonical adjacency matrix, an external matrix and is not marked as an invalid subgraph, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the third node as the parent node and containing the second number of edges.
4. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: In the case where a first node of a leaf including a first number of edges is a canonical adjacency matrix and there are other second nodes of a leaf including the first number of edges that share a parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the first node and the second node as parent nodes and including a second number of edges, including: In the case where a first node containing leaves of the first number of edges is a canonical adjacency matrix and there are other second nodes containing leaves of the first number of edges that share a parent node with the first node, If the first node and the second node are both inner matrices, if and only if f and k are different, the subgraph is grown in the first way to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented by C m×m , where the adjacency matrix C m×m The elements in are represented as: Among them, c i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, b i,j represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the second node. The last edge in the canonical adjacency matrix corresponding to the first node is represented by a m,f , m and f represent the number of rows and columns and the total number of edges in the canonical adjacency matrix corresponding to the first node, respectively. The last edge in the adjacency matrix corresponding to the second node is represented by b n,k , n and k represent the number of rows and columns and the total number of edges of the adjacency matrix corresponding to the second node respectively; If the first node is an inner matrix and the second node is an outer matrix, the subgraph is grown in the second manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented as C n×n , where the adjacency matrix C n×n The elements in are represented as: If the first node and the second node are both external matrices, then f≠k∧a m,m =b m,m , the subgraph is grown in the third way, and the adjacency matrix corresponding to the child nodes having the first node and the second node as parent nodes and containing the second number of edges is obtained, which is represented as C m×m , where the adjacency matrix C m×m The elements in are represented as: If both the first node and the second node are external matrices, the subgraph is grown in the fourth manner to obtain an adjacency matrix corresponding to a child node having the first node and the second node as parent nodes and containing the second number of edges, represented as D (m+1)×(m+1) , where the adjacency matrix D (m+1)×(m+1) The elements in are represented as: Among them, d i,j Represents the element in the i-th row and j-th column of the adjacency matrix corresponding to the child node, a i,j represents the element in the i-th row and j-th column of the canonical adjacency matrix corresponding to the first node, b m,j represents the element in the mth row and jth column of the adjacency matrix corresponding to the second node, b m,m Represents the element in the mth row and mth column of the adjacency matrix corresponding to the second node, where m represents the number of rows and columns of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node.
5. The frequent subgraph mining method of a single graph as claimed in claim 4, characterized in that: Taking the leaf nodes containing the second number of edges as candidate subgraphs, constructing the CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node, including: When the subgraph is grown in the first manner or the third manner to obtain a leaf node containing the second number of edges as a candidate subgraph, deduplication of the subgraph corresponding to the combination of the lexicographic sorting order of the numbers of the graph nodes in the CSP search space of the first node and the CSP search space of the second node is obtained to obtain the CSP search space of the candidate subgraph; When the subgraph is grown according to the second method or the fourth method to obtain a node with leaves containing the second number of edges as a candidate subgraph, the subgraph corresponding to the lexicographically sorted order combination of the numbers of the graph nodes in the two CSP search spaces corresponding to the common part of the canonical adjacency matrix corresponding to the first node and the adjacency matrix corresponding to the second node is deduplicated, and spliced to the CSP search space corresponding to the remaining nodes in the adjacency matrix corresponding to the second node except the common part of the canonical adjacency matrix corresponding to the first node, to obtain the CSP search space of the candidate subgraph.
6. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: Taking the leaf nodes containing the second number of edges as candidate subgraphs, constructing the CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node, including: When a node containing a leaf of the second number of edges obtained by performing a FFSM-Extension operation on the subgraph is used as a candidate subgraph, the CSP search space of the third node is obtained, and the number of the end point graph node added by the candidate subgraph relative to the third node is added to the end of the lexicographically sorted combination of the numbers of each graph node in the CSP search space of the third node to obtain the CSP search space of the candidate subgraph.
7. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: Taking the leaf nodes containing the second number of edges as candidate subgraphs, constructing the CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node, including: In the case where the fourth node containing the second number of edges is a non-canonical adjacency matrix, if there are other nodes that share a parent node with the fourth node, a fifth node that has the same graph node set and edge set as the fourth node and contains the second number of edges and is a canonical adjacency matrix is found, and a new numbering sequence combination is generated by adjusting the order of the numbers in the order combination of the numbers of the graph nodes in the CSP search space of the fourth node, the generated new numbering sequence combination is added to the CSP search space of the fifth node, and the fourth node is marked as an invalid subgraph.
8. The frequent subgraph mining method of a single graph according to any one of claims 1 to 7, characterized in that: Also includes: All frequent nodes and all frequent edges and their child nodes in the initial suboptimal canonical adjacency matrix tree are distributed to each computing node of the distributed system according to the frequent nodes, so that each computing node performs subgraph growth under load balancing to obtain nodes containing the second number of edges.
9. The frequent subgraph mining method of a single graph according to any one of claims 1 to 7, characterized in that: Also includes: In the case where it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, according to the CSP search space of the candidate subgraphs of the single graph, the parent node of the node containing the first number of edges in the suboptimal canonical adjacency matrix tree, the corresponding node containing the first number of edges and its child nodes are distributed to each computing node in the distributed system, so that each computing node grows the subgraph according to the canonical adjacency matrix of the single graph and according to the nodes containing the second number of edges that are not marked as invalid subgraphs under load balancing.
10. The frequent subgraph mining method of a single graph as claimed in claim 9, characterized in that: According to the CSP search space of the candidate subgraph of the single graph, the parent nodes and the child nodes of the nodes containing the first number of edges in the suboptimal canonical adjacency matrix tree are allocated to the computing nodes in the distributed system, including: Determine a pre-search space for constructing the CSP corresponding to the candidate subgraph according to the number of node numbers between the number of the last graph node in the CSP search space of the node containing the first number of edges as the candidate subgraph and the number of the last graph node in the canonical adjacency matrix of the single graph; The pre-search spaces for constructing the CSP of each node containing the first number of edges are grouped and summed according to the parent nodes of the parent nodes of the nodes containing the first number of edges, and the nodes containing the first number of edges in the suboptimal canonical adjacency matrix tree, their parent nodes and their child nodes are distributed to each computing node in the distributed system according to the grouped summation results, so that the sums of the pre-search spaces executed on different computing nodes are similar.
11. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: When the number of valid combinations of the lexicographic order of the graph nodes in the CSP search space of the current candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph, including: The product of the number of numbering order combinations in the CSP search space of the candidate subgraph and the number of corresponding search methods when the latest node added in the candidate subgraph is searched according to the numbering order of the graph nodes in the canonical adjacency matrix of the single graph is calculated, and the valid number of lexicographical order combinations of the numbers of the graph nodes in the CSP search space of the candidate subgraph is obtained. If the corresponding valid number is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph.
12. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: In the case that it is determined according to the canonical adjacency matrix of the single graph that the current candidate subgraph is not a subgraph that has been grown, the subgraph is grown according to the canonical adjacency matrix of the single graph and according to the nodes containing the second number of edges that are not marked as invalid subgraphs, so as to update the leaf nodes of the suboptimal canonical adjacency matrix tree, and the frequent subgraphs of the single graph are output according to the leaf nodes that have completed the subgraph growth, including: In the case where it is determined that the current candidate subgraph is not a subgraph that has completed growth according to the canonical adjacency matrix of the single graph, in the case where the sixth node containing the second number of edges as the candidate subgraph is a canonical adjacency matrix and there is a seventh node that is a leaf containing the second number of edges and has a common parent node with the sixth node and the seventh node, a FFSM-Join operation is performed on the sixth node and the seventh node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the sixth node and the seventh node as parent nodes and containing the third number of edges; in the case where the eighth node containing the second number of edges as the candidate subgraph is not marked as an invalid subgraph and is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the eighth node according to the canonical adjacency matrix of the single graph, and the subgraph grows to obtain a child node with the eighth node as parent node and containing the third number of edges; wherein the third number minus the second number is equal to one; the eighth node is the same as or different from the sixth node or the seventh node; the child node containing the third number of edges becomes a leaf node of the suboptimal canonical adjacency matrix tree; Taking the leaf nodes containing the third number of edges as new candidate subgraphs, and constructing the CSP search space of the corresponding candidate subgraph according to the subgraph growth mode and according to the parent node of the candidate subgraph and the CSP search space of the parent node; When the number of valid combinations of the lexicographic order of the graph node numbers in the CSP search space of the current new candidate subgraph is less than the set support threshold, the corresponding candidate subgraph is marked as an invalid subgraph; In the case where it is determined according to the canonical adjacency matrix of the single graph that the current new candidate subgraph is a subgraph that has completed growth, a frequent subgraph of the single graph is output according to the current new candidate subgraph.
13. The frequent subgraph mining method of a single graph as claimed in claim 1, characterized in that: In the case where a first node of a leaf including a first number of edges is a canonical adjacency matrix and there are other second nodes of a leaf including the first number of edges that share a parent node with the first node, a FFSM-Join operation is performed on the first node and the second node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the first node and the second node as parent nodes and including a second number of edges, including: In the case where a first node of leaves containing a first number of edges is a canonical adjacency matrix and there are other second nodes of leaves containing the first number of edges that share a parent node with the first node, a push-pull dual-mode engine is used to traverse the canonical adjacency matrix of the single graph using a distributed system, and a FFSM-Join operation is performed on the first node and the second node, and a subgraph is grown to obtain child nodes having the first node and the second node as parent nodes and containing a second number of edges; In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a FFSM-Extension operation is performed on the third node according to the canonical adjacency matrix of the single graph, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges, including: In the case where the third node of the leaf containing the first number of edges is a canonical adjacency matrix and an external matrix, a push-pull dual-mode engine is used in a distributed system to traverse the canonical adjacency matrix of the single graph, and a FFSM-Extension operation is performed on the third node, and a subgraph is grown to obtain a child node having the third node as a parent node and containing the second number of edges; The distributed communication scheduling of the distributed system is implemented by non-blocking communication and dynamic thread resource release.
14. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 13 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
Citation Information
Patent Citations
Maximal frequent subgraph mining-based dynamic taint analysis method
CN106384050A
Frequent sub-graph mining method and system
CN106777065A