A graph search method, device and equipment
By decomposing the graph data and generating word sets, the graph search function of the graph database is realized, which solves the problem that cannot support graph search in the existing technology, supports similar graph and subgraph search, saving computing resources and time costs.
Patent Information
- Application Number
- CN202111317516.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-09
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-11-09
AI Technical Summary
The prior art cannot support the graph search function, especially when processing massive complex data relationship operations, it cannot meet the user's graph search needs, and lacks the functions of similar graph and sub-graph search.
By obtaining the graph data input by the user, performing decomposition operations to obtain the graph data unit, generating a word set based on the unit's attribute information, and searching the graph data based on the set, supporting similar graph and sub-graph searches.
Implement the graph search function of graph database, saves server computing resources and time costs, fills the gap in the existing technology that graph database cannot support graph search, supports similar graph and subgraph search, and does not require additional training costs and model storage. cost.
Smart Images

Figure CN114090834B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a graph search method, device and equipment. Background Art
[0002] With the rapid development of various industries in society, the real world has woven a huge and complex network of relationships, and traditional databases are difficult to handle relational operations. The relationship between the data that the big data industry needs to process is growing exponentially with the amount of data, and there is an urgent need for a database that supports massive and complex data relational operations. Among them, a graph consists of two elements: nodes and relationships. Each node represents an entity (a person, a place, a thing, a category, or other data), and each relationship represents the way two nodes are related. A graph database does not refer to a database that stores images, but rather stores and queries data in a graph data structure. A graph database is an online database management system that has the ability to handle the creation, reading, updating, and deletion (CRUD) operations of a graph data model.
[0003] Graph databases can be used in social, retail, financial, and IoT fields, etc., and are widely used. Therefore, there is an urgent need to provide a more reliable graph search solution. Summary of the invention
[0004] The embodiments of this specification provide a graph search method, device and equipment to solve the problem that graph search cannot be performed based on a graph in the prior art.
[0005] To solve the above technical problems, the embodiments of this specification are implemented as follows:
[0006] An embodiment of this specification provides a graph search method, including:
[0007] Acquire first graph data input by a user; the first graph data includes point data and edge data;
[0008] Performing a decomposition operation on the first graph data to obtain corresponding graph data units;
[0009] Generating a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0010] Based on the word set, graph data related to the first graph data is searched.
[0011] An embodiment of the present specification provides a graph search device, including:
[0012] A first graph data acquisition module, used to acquire first graph data input by a user; the first graph data includes point data and edge data;
[0013] A decomposition module, used to perform a decomposition operation on the first graph data to obtain corresponding graph data units;
[0014] A word set generation module, used to generate a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0015] The graph data search module is used to search for graph data related to the first graph data based on the word set.
[0016] An embodiment of the present specification provides a graph search device, including:
[0017] at least one processor; and,
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0020] Acquire first graph data input by a user; the first graph data includes point data and edge data;
[0021] Performing a decomposition operation on the first graph data to obtain corresponding graph data units;
[0022] Generating a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0023] Based on the word set, graph data related to the first graph data is searched.
[0024] An embodiment of the present specification provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement a graph search method.
[0025] At least one embodiment of the present specification can achieve the following beneficial effects: by obtaining the first graph data input by the user; the first graph data includes point data and edge data; performing a decomposition operation on the first graph data to obtain corresponding units; generating a word set corresponding to the first graph data according to the attribute information of the unit; and performing a search operation related to the first graph data based on the word set. Through this method, the gap that the existing graph database cannot support graph search can be solved, and the functions of similar graph search and subgraph search can be supported, without the need for additional training costs and model storage costs, saving a lot of server computing resources and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0027] Figure 1 An overall system block diagram of a graph search method provided in an embodiment of this specification;
[0028] Figure 2 A flowchart of a graph search method provided in an embodiment of this specification;
[0029] Figure 3 An example diagram of graph decomposition in a graph search method provided in an embodiment of this specification;
[0030] Figure 4 A schematic diagram of the structure of a graph search device provided in an embodiment of this specification;
[0031] Figure 5 A schematic diagram of the structure of a graph search device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.
[0033] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0034] As the number of scenarios for graph-based intelligent analysis increases, using graphs to solve algorithmic and engineering problems is becoming more and more popular. In one application scenario, in pharmaceutical analysis, drugs with the same or similar functional groups may have similar effects. If drugs with known effects are decomposed into functional group relationship diagrams in advance and stored in a graph database, and the graph search function is used to input the functional group relationship diagram of the new drug, the output is the drugs with known similar structures in the database, as well as the corresponding drug information, which can help pharmaceutical developers determine the possible effects of new drugs.
[0035] Another application scenario is in the field of program analysis. The call graph of the program when it is running can be saved in the graph database. Before the program is launched or released, it is necessary to use program use cases to test the program to be launched. Only after the test is successful can it be launched. Because there will be different inputs when the program is running, many call graphs will be generated after the service of the same version of the program is launched. Different call graphs represent the differences in the execution logic inside the program, that is, they carry the business attributes of the program. When the program code is changed, the impact use cases of the change can be obtained through analysis, so as to accurately test the change and save time.
[0036] In the prior art, the main functions provided by current graph databases are graph storage and graph query. The query here refers to describing the conditions for searching a graph through a dedicated language, and the graph database engine helps users find the corresponding graph or subgraph. For example, in the enterprise relationship search, if you need to find the relationship network between the personnel of Company A and Company B, you can use the existing graph database to complete it. However, the current graph database cannot solve the problem of using a given graph to search for related graphs.
[0037] In order to solve the defects in the prior art, this solution provides the following embodiments:
[0038] Next, the embodiments of the specification will be described in detail with reference to the accompanying drawings:
[0039] Figure 1 The overall system block diagram of a graph search method provided in the embodiment of this specification. Figure 1 As shown, the system includes a graph database interface 101, a graph query module 103, a graph data addition, deletion and modification module 105, a graph search module 107, a graph node and edge data storage module 109, and a graph vector and word data storage module 111. The system can not only provide users with ordinary graph query functions, but also provide users with graph search functions, wherein the graph query is mainly based on the conditional data of nodes and edges, querying the data of the graph or subgraph; the graph search is mainly based on the graph search, that is, based on the graph search to obtain similar graphs or subgraphs.
[0040] The system can receive requests sent by users through the graph database interface 101, such as graph query requests, data addition, deletion and modification requests, or graph search requests. If a graph query request is received, the graph query module 103 can interact with the graph node and edge data storage module 109. Specifically, the graph query module 103 is mainly responsible for undertaking graph query services, and can interact with the graph node and edge data storage module 109 based on the node and / or edge data input by the user, or a graph that matches the node and / or edge data input by the user. If the system receives a data addition, deletion and modification request, the graph data addition, deletion and modification module 105 can interact with the graph node and edge data storage module 109 or the graph vector and word data storage module 111. The graph data addition, deletion and modification module 105 is mainly responsible for adding, deleting and modifying the original data. If the system receives a graph search request, the graph search module 107 can interact with the graph vector and word data storage module 111, wherein the graph search module 107 integrates functions such as similar graph search and subgraph search, and the graph vector and word data storage module 111 can mainly store the pre-processed information of the graph, including the encoding vector of the graph and the pre-processed word information. At the same time, it can also provide vector retrieval function and word inverted index function.
[0041] Next, the solution provided by the embodiments of this specification can be described in combination with the embodiments:
[0042] Figure 2 A flowchart of a graph search method provided in an embodiment of this specification. From a program perspective, the execution subject of the process can be a program or application client installed on an application server. In this embodiment, the execution subject of the process can be a server that provides a graph search function. The server can also provide a graph query function and a graph storage function at the same time. According to the graph input by the user, the result graph corresponding to the input graph can be found from the graph database.
[0043] like Figure 2 As shown, the process may include the following steps:
[0044] Step 210: Acquire first graph data input by a user; the first graph data includes point data and edge data.
[0045] The first graph data may represent the data corresponding to the graph input by the user. The graph may be composed of a finite non-empty set of vertices and a set of edges between vertices. In existing graph query solutions, when users need to find corresponding graph data, they generally enter the attribute information of a certain point and / or edge for query. For example, in corporate relationship search, if you need to find the relationship network between the personnel of Company A and Company B, you can use the existing graph database to complete it. However, the current graph database cannot meet the demand of searching for related graphs with a given graph. In this step, when performing a graph search, the data entered by the user is the graph data corresponding to the graph.
[0046] Step 220: Perform a decomposition operation on the first graph data to obtain corresponding units.
[0047] The performing a decomposition operation on the first graph data to obtain corresponding units may specifically include:
[0048] The first graph data is decomposed according to preset rules to obtain corresponding units; one unit includes a node data in the first graph data, or one unit includes edge data in the first graph data and node data connected by the edge.
[0049] The decomposition operation can be understood as the operation of disassembling the points and edges in the graph according to preset rules. For example, a node itself can become a unit, the connection relationship between nodes can become a unit, and the edges between more than one node and nodes can become a unit.
[0050] Step 230: Generate a word set corresponding to the first graph data according to the attribute information of the unit.
[0051] In step 220, after the first graph data is decomposed to obtain units, all decomposed units in the graph can be traversed, and the attribute information of the unit can be used to perform HASH encoding to become a word. There can be a one-to-one correspondence between the unit and the word (HASH value). That is, a unit can include one or more points and can also include edges. According to the attribute information of the unit, a word corresponding to the unit can be generated.
[0052] The attribute information of a unit may include the attribute information of the node itself and the attribute information of the edge itself in the unit, and may also include the attribute information of the node or edge in the graph, for example, the relationship information between two or several points in a unit.
[0053] Step 240: Based on the word set, search for graph data related to the first graph data.
[0054] Optionally, searching for graph data related to the first graph data based on the word set may specifically include:
[0055] Based on the word set, target graph data matching the first graph data in the graph database is determined; the association relationship between the target graph data and the first graph data satisfies a preset condition; the association relationship satisfies the preset condition including: the similarity between the target graph data and the first graph data satisfies the first preset condition or the inclusion degree between the target graph data and the first graph data satisfies the second preset condition.
[0056] The word set may represent the set of words corresponding to each unit after decomposition in the input graph. The search operation may represent the operation of determining the target graph data in the graph database that matches the first graph data. Specifically, it may include the operation of determining the target graph data similar to the first graph data, and it may also include the operation of determining the target graph data containing the first graph data. Furthermore, when determining the target graph data similar to the first graph data, the graph data whose similarity is greater than the first preset condition may be determined as the target graph data of the first graph data; when determining the target graph data containing the first graph data, the graph data whose inclusion degree satisfies the second preset condition may be determined as the target graph data. The first preset condition and the second preset condition may be set according to the actual application requirements, and this specification does not specifically limit the embodiments of this specification.
[0057] It should be understood that the order of some steps in the methods described in one or more embodiments of this specification can be interchanged according to actual needs, or some steps can be omitted or deleted.
[0058] Figure 2 The method in the embodiment of the present invention obtains the first graph data input by the user; the first graph data includes point data and edge data; performs a decomposition operation on the first graph data to obtain corresponding units; generates a word set corresponding to the first graph data according to the attribute information of the units; and performs a search operation related to the first graph data based on the word set. This method can solve the problem that the existing graph database cannot support graph search, and can support the functions of similar graph search and subgraph search without requiring additional training costs and model storage costs, thus saving a large amount of server computing resources and time costs.
[0059] based on Figure 2 The method, the examples of this specification also provide some specific implementation plans of the method, which are described below.
[0060] Generating a word set corresponding to the first graph data according to the attribute information of the unit may specifically include:
[0061] For any of the units, determine the node data and edge data in the unit;
[0062] Determine attribute information of the node data and the edge data;
[0063] Perform hash calculation on the attribute information to obtain the word corresponding to the unit,
[0064] The word is determined as an element in the word set.
[0065] A unit may include one node or multiple nodes, one edge or an edge and the nodes connected by the corresponding edge; each node has its own attribute information. For example, when a node represents a user, the attribute information of the node may be the attribute information of the user, such as the user's asset information, identity information, etc. Each edge also has its own attribute information. For example, in a company relationship network diagram, an edge may represent a position affiliation or a department relationship. Of course, attribute information may also include information about a node or edge in the diagram, for example, a node in the diagram is an intermediate node connecting other nodes. Node A is connected to node B, node B is connected to node C, node D is connected to node B, and node B is connected to node E. If there are multiple nodes connected to node B, then the number of nodes connected to node B or the type of nodes may also be used as attribute information of node B.
[0066] The attribute information of each unit is hash-coded into a word, and multiple words corresponding to multiple units obtained by graph decomposition input by the user are obtained to form a word set.
[0067] Since the graph database in the embodiment of the present specification stores both graph nodes and edges for graph query and graph vectors and words for graph search, when performing graph search, the graph can be decomposed into the form of words and vectors to facilitate graph search.
[0068] The graph search function can include similar graph search function and subgraph search function, which can be discussed separately below:
[0069] Function 1: Similar image search function
[0070] If the association relationship satisfies the preset condition that the similarity between the target graph data and the first graph data satisfies the first preset condition; determining the target graph data matching the first graph data in the graph database based on the word set may specifically include:
[0071] Normalizing the vectors corresponding to the words in the word set to obtain a first graph vector corresponding to the first graph data;
[0072] Based on the first graph vector, determining a set of candidate graph data corresponding to the first graph data from the graph database;
[0073] Based on the word set, the target graph data whose similarity with the first graph data satisfies a first preset condition is determined from the candidate graph database set.
[0074] Among them, standardizing the vectors corresponding to the words in the word set may include: adding the vectors corresponding to the words in the word set and performing normalization processing to obtain a first graph vector corresponding to the first graph data.
[0075] After decomposing the graph into a set of words, each word is encoded into a vector according to its HASH value as a seed. Specifically, the encoding method can be to add the vectors of each word, and the addition method can be to add each dimension bit by bit. Normalization is to make the modulus of the vector 1.
[0076] When searching for similar graphs, first, based on the graph vector of the first graph data, filter out the top M candidate graph data sets whose vector distances meet the distance threshold from the graph database, then calculate the similarity based on the word list, and determine the target graph data from the candidate graph data set based on the similarity.
[0077] The determining, based on the word set, from the candidate graph database set, the target graph data whose similarity with the first graph data satisfies a first preset condition may specifically include:
[0078] Calculating the similarity between the words in the word set and the words in the candidate graph database;
[0079] Determine target graph data in the candidate graph database whose similarity is greater than or equal to a preset similarity threshold.
[0080] If there are multiple target graph data in the candidate graph database whose similarity is greater than or equal to a preset similarity threshold, the graph data with the greatest similarity among the candidate graph data is determined as the target graph data.
[0081] In a graph database, a word set can be stored in the form of a word list.
[0082] When performing a graph search, firstly, a graph A and other search conditions are given. Graph A is decomposed according to the preset rules, and N graphs that meet other search conditions and whose vector distances meet the preset distances are determined from the graph database through calculation according to the graph vector corresponding to graph A. At the same time, the word lists of these N graphs are taken out, and the word similarity between these N graphs and graph A is calculated using word similarity. According to the similarity value, the graph whose similarity value meets the preset conditions is used as the target graph.
[0083] In addition, the similarity results can be reordered in descending order according to the word similarity values, and then the graph with the greatest similarity is input according to the preset conditions or sorted by similarity, and the first M graphs are output, M≤N. Then the search results are output.
[0084] When calculating the similarity, the following formula can be used:
[0085]
[0086] There are two word lists, wordsA and wordsB, and the word list with the two words repeated is wordsAB. Define the function len to find the number of words in the list, and max to find the maximum value. The numerator represents the repeated word lists in the two graphs A and B, and the denominator represents the maximum number of words in the two lists.
[0087] After determining the target graph data matching the first graph data in the graph database based on the word set, the method may further include: sending the ID of the target graph data and the similarity value to the user's terminal.
[0088] After the corresponding target graph is found based on the graph input by the user, the ID and similarity value of the target graph may be sent to the user so that the user can view the searched target graph and the degree of similarity.
[0089] Function 2: Subgraph Search
[0090] If the association relationship satisfies the preset condition that the similarity between the target graph data and the first graph data satisfies the first preset condition; determining the target graph data matching the first graph data in the graph database based on the word set may specifically include:
[0091] Based on the word set, determining a candidate graph data set including the word set according to an inverted index method;
[0092] Calculate the inclusion degree of the word set and each graph data in the candidate graph data set;
[0093] The graph data in the candidate graph data set whose inclusion degree is greater than or equal to a preset inclusion degree threshold is determined as the target graph data.
[0094] If there are multiple graph data with a degree of inclusion greater than or equal to a preset degree of inclusion threshold in the candidate graph data set, the graph data with the largest degree of inclusion in the candidate graph data set is determined as the target graph data.
[0095] When calculating the subgraph inclusion degree, the following formula can be used:
[0096]
[0097] Among them, the subgraph word list subwordsA, the word list corresponding to the graph in the graph database subwordsB, and subwordsAB are the word lists of the two words that are repeated. Define the function len to find the number of words in the list. The numerator can represent the number of overlapping words, and the denominator can represent the number of words in the subgraph.
[0098] Subgraph search can be understood as searching for graphs with a high probability of containing subgraphs. Specifically, first, a subgraph a and other search conditions are given. Subgraph a is decomposed according to preset rules. After the units of subgraph a are decomposed, the word list corresponding to graph a is obtained based on hash coding. A module with an inverted index function is used to search the database for the M graphs that meet other search conditions and contain the most word lists corresponding to word list graph a. The subgraph inclusion of these M graphs and subgraph a is further calculated, and the results are reordered in order from large to small in terms of subgraph inclusion, and then the search results are output. The input search results can include the graph ID, as well as information such as the subgraph inclusion, and the ID of the target graph data and the inclusion value are sent to the user's terminal.
[0099] In one implementation, the user can modify the data stored in the graph database. Like the common graph database operation process, the user can provide the ID of the graph to be inserted, deleted or modified, the nodes, edges, and other attribute information of the graph through the interface. If it is a storage or modification command, the information in the graph can be modified according to the user's instructions, and the modified graph can be taken out. If it is a deletion command, the data corresponding to the original graph in the graph database is directly deleted. The graph is decomposed according to the modified graph. The node itself can become a unit, and the connection relationship between nodes can also become a unit. Traverse all the decomposed units in the graph, and use the attribute information of the unit to perform HASH encoding into a word. The probability of one-to-many occurrence of units and words (HASH values) is very small, and it can be determined that there is a one-to-one correspondence between units and words. For each word, its HASH value can be used as a seed to encode it into a vector, such as a 64-bit vector or a 128-bit vector, etc. The sum of all word vectors of a graph is then normalized as the graph vector of the entire graph. If the original command is to store or modify, the graph vector and all word HASH values are stored or the corresponding data of the original graph in the graph database is modified. If the original command is to delete the graph, the data of the original graph in the graph database is deleted. Specifically, the following steps can be used to implement:
[0100] Based on the modification instruction, the corresponding original graph data in the graph database is modified to obtain second graph data; the second graph data includes the ID of the original graph data, the ID of the second graph data, the attribute information of the node data in the second graph data, and the attribute information of the edge data in the second graph data; the second graph data includes the ID of the original graph data, the ID of the second graph data, the attribute information of the node data in the second graph data, and the attribute information of the edge data in the second graph data;
[0101] The second graph data is processed according to the preset rules and then stored in the graph database.
[0102] The implementation steps may also include:
[0103] The original graph data in the graph database is deleted.
[0104] When a graph is decomposed into units, it can be decomposed according to preset rules or based on the attribute information of the nodes or edges in the graph. For example, when a graph is decomposed into units, if the node itself is set to 0-order decomposition, and the nodes and edges contained in the K-step path are set to K-order decomposition, then the above unit decomposition is to use the unit encoding of 0-order + 1-order decomposition to become words. In actual application, according to the storage and scale of the graph itself, a single 1-order decomposition, or 0-order decomposition + 1-order decomposition + 2-order decomposition, or a combination of other decomposition modes can be used. When adding the attributes of nodes or edges to decompose the graph into units, you can combine Figure 3 To explain: Figure 3 This is an example diagram of graph decomposition in the graph search method provided in the embodiment of this specification. Figure 3 The following are the structural diagrams of two acetaldehydes, which are decomposed as graph data:
[0105] Among them, each atom can be regarded as a node and the chemical bond as an edge.
[0106] There is no special indication of carbon in the node. , hydrogen is , oxygen element is Chemical bonds are divided into single bonds, double bonds, and triple bonds according to the number of shared electron pairs. The decomposition method can ignore the node attributes, that is, the influence of isotopes, or consider the influence of isotopes.
[0107] The following example considers the influence of isotopes and chemical bond properties. Assuming that the way to decompose words is the node itself (0th order) and the relationship between nodes directly connected (1st order), graph a can be decomposed into C, H, H, H, C, O, H, CH, CH, CH, C=O, CH, CC. Graph b can be decomposed into H,H,H,C,O,H, C=O,CH,
[0108] If we ignore the influence of isotopes and only consider the influence of chemical bond properties, Figure a can be decomposed into C, H, H, H, C, O, H, CH, CH, CH, C=O, CH, CC. Figure b can be decomposed into C, H, H, H, C, O, H, CH, CH, CH, C=O, CH, CC.
[0109] It should be noted that when decomposing a graph into units, the specific decomposition method can be set according to the actual application scenario, or it can be decomposed based on the attribute information of points or edges. This specification does not make any specific limitation on this.
[0110] Of course, the solution in the embodiments of this specification, in addition to being able to perform graph search, also retains the functions of the graph database for storage and graph query. That is, the solution in the embodiments of this specification can enable the graph database to have the same storage function, graph query function and graph search function.
[0111] The solutions in the embodiments of this specification can at least achieve the following technical effects:
[0112] 1) When encoding words by vectors, random encoding is adopted. Hash theory can encode infinite vectors one by one, which achieves better results and solves the problem that the skip-gram model requires a limited number of words to be encoded in this way and that the skip-gram model needs to obtain data in advance for training before it can be used. The method used in the embodiments of this specification can improve the accuracy without requiring additional training costs and model storage costs, saving a lot of server computing resources and time costs.
[0113] 2) Existing graph databases are unable to perform graph search. The method in the embodiments of this specification can provide graph search services while storing the graph, which can be convenient for R&D personnel to use in many application scenarios. The graph database fills the gap that existing graph databases cannot support graph search, and can support similar graph search and sub-graph search functions.
[0114] 3) By searching the call subgraphs of the changed parts, the call graphs containing these subgraphs can be obtained. When the program changes, the program analysis can analyze the static graphs before and after the change points. The use cases affected by the change can be analyzed through the static graphs of the change points before and after the change, so that the impact of each change can be obtained, and test cases can be further constructed for the affected parts, which saves a lot of testing time compared to the full use case test. For example: assuming that the user has 10,000 test cases, once the program is changed, 10,000 use cases need to be tested one by one, and 10,000 tests are required. The method of the embodiment of this specification can be used to find similar cases in advance, remove duplication, and reduce test cases. In addition, after the program is changed, it can be determined which use cases are affected by the program change based on the relationship contained in the subgraphs, for example: the change only affects the test cases of scene A. Then you only need to use the test cases in scene A for testing.
[0115] In the scheme in the above embodiment, the interaction subjects may include a server and a graph database. It should be noted that the server may be a server independent of the graph database, and data can be exchanged between the server and the graph database. Of course, the server may also be a server in the graph database, serving as a functional interface or data processing module in the graph database. In the following steps, the server and the graph database are regarded as two subjects only to facilitate the explanation of the interaction of the scheme, and it does not limit the server and the graph database to be independent of each other. The scheme can be divided into a graph storage phase, a graph query phase, and a graph search phase.
[0116] Graph storage stage: In this stage, the server can be a functional interface of the graph database, responsible for receiving the graph input by the user, decomposing the graph input by the user according to preset rules, decomposing it into units, performing hash calculations on the attributes of the units, obtaining the words corresponding to the units, and finally determining the word list and graph vector corresponding to the graph, and storing them in the graph database. When modification is required, the user can enter the ID, node information or edge information of the graph to be modified. After modification, the modified graph is saved in the graph database, and the graph before modification in the graph database is deleted.
[0117] Graph query stage: The server can receive the user's graph query request, which may include attribute information of nodes and / or edges, and search for the corresponding target graph from the graph database based on the information input by the user.
[0118] Graph search phase: If it is a similar graph search, the server receives the graph input by the user, decomposes the graph according to the decomposition rules of the storage phase, and obtains the word list and graph vector corresponding to the input graph. Based on the graph vector, the first M candidate graph data sets whose vector distance meets the distance threshold are pre-screened from the graph database, and then the similarity is calculated based on the word list. The target graph data is determined from the candidate graph data set based on the similarity. If it is a subgraph search, the inclusion degree between the word list corresponding to the input graph and the word list corresponding to the graph in the graph database is directly solved, and the target graph is determined based on the inclusion degree.
[0119] Based on the same idea, the embodiments of this specification also provide devices corresponding to the methods in the above embodiments. Figure 4 This is a schematic diagram of the structure of a graph search device provided in an embodiment of this specification. Figure 4 As shown, the device may include:
[0120] A first graph data acquisition module 410 is used to acquire first graph data input by a user; the first graph data includes point data and edge data;
[0121] A decomposition module 420, configured to perform a decomposition operation on the first graph data to obtain corresponding graph data units;
[0122] A word set generating module 430, configured to generate a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0123] Graph data search module 440, for searching graph data related to the first graph data based on the word set.
[0124] based on Figure 4 The present specification also provides some specific implementation schemes of the device, which are described below.
[0125] Optionally, the device may further include:
[0126] Optionally, the graph data search module 440 may specifically include:
[0127] A similar graph data search unit is used to determine, based on the word set, target graph data in a graph database whose similarity with the first graph data satisfies a first preset condition.
[0128] Optionally, the graph data search module 440 may specifically include:
[0129] The subgraph data search unit is used to determine, based on the word set, target graph data in the graph database whose degree of inclusion with the first graph data satisfies a second preset condition.
[0130] Optionally, the decomposition module 420 may specifically include:
[0131] Decomposing the first graph data according to a preset rule to obtain corresponding units; one of the units includes one node data in the first graph data, or one of the units includes edge data in the first graph data and node data connected by the edge;
[0132] Optionally, the word set generation module 430 may be specifically used for:
[0133] For any of the units, determine the node data and edge data in the unit;
[0134] Determine attribute information of the node data and the edge data;
[0135] Perform hash calculation on the attribute information to obtain the word corresponding to the unit,
[0136] The word is determined as an element in the word set.
[0137] Optionally, the similar graph data searching unit may specifically include:
[0138] A first graph vector calculation subunit, configured to perform normalization processing on vectors corresponding to words in the word set to obtain a first graph vector corresponding to the first graph data;
[0139] a candidate graph data set subunit, configured to determine, from the graph database, a candidate graph data set corresponding to the first graph data based on the first graph vector;
[0140] The similar graph data determination subunit is used to determine, based on the word set, from the candidate graph database set the target graph data whose similarity with the first graph data satisfies a first preset condition.
[0141] Optionally, the similar graph data determination subunit may be specifically used for:
[0142] Calculating the similarity between the words in the word set and the words in the candidate graph database;
[0143] Determine target graph data in the candidate graph database whose similarity is greater than or equal to a preset similarity threshold.
[0144] Optionally, if there are multiple target graph data in the candidate graph database whose similarity is greater than or equal to a preset similarity threshold, the graph data with the greatest similarity among the candidate graph data is determined as the target graph data.
[0145] Optionally, the device may further include:
[0146] The first result sending module is used to send the ID of the target graph data and the similarity value to the user's terminal.
[0147] Optionally, the sub-graph data searching unit may specifically include:
[0148] A candidate graph data set determination subunit, configured to determine a candidate graph data set including the word set based on the word set and according to an inverted index method;
[0149] An inclusion degree calculation subunit, used to calculate the inclusion degree of the word set and each graph data in the candidate graph data set;
[0150] The sub-graph data determination sub-unit is used to determine the graph data in the candidate graph data set whose inclusion degree is greater than or equal to a preset inclusion degree threshold as the target graph data.
[0151] Optionally, if there are multiple graph data with a degree of inclusion greater than or equal to a preset degree of inclusion threshold in the candidate graph data set, the graph data with the largest degree of inclusion in the candidate graph data set is determined as the target graph data.
[0152] Optionally, the device may further include:
[0153] The second result sending module is used to send the ID of the target graph data and the inclusion value to the user's terminal.
[0154] Optionally, the device may further include:
[0155] A second graph data acquisition module, used to acquire the second graph data input by the user; the second graph data is obtained by modifying the original graph data contained in the graph database; the second graph data includes the ID of the original graph data, the ID of the second graph data, the attribute information of the node data in the second graph data, and the attribute information of the edge data in the second graph data;
[0156] The second graph data storage module is used to process the second graph data according to the preset rules and store them in the graph database.
[0157] Optionally, the device may further include:
[0158] The graph data deletion module is used to delete the original graph data in the graph database.
[0159] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0160] Figure 5 This is a schematic diagram of the structure of a graph search device provided in an embodiment of this specification. Figure 5 As shown, the device 500 may include:
[0161] at least one processor 510; and,
[0162] A memory 530 in communication with the at least one processor; wherein,
[0163] The memory 530 stores instructions 520 that can be executed by the at least one processor 510. The instructions are executed by the at least one processor 510 to enable the at least one processor 510 to:
[0164] Acquire first graph data input by a user; the first graph data includes point data and edge data;
[0165] Performing a decomposition operation on the first graph data to obtain corresponding graph data units;
[0166] Generating a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0167] Based on the word set, graph data related to the first graph data is searched.
[0168] Based on the same idea, the embodiment of this specification also provides a computer-readable medium corresponding to the above method. The computer-readable medium stores computer-readable instructions. The computer-readable instructions can be executed by a processor to implement the following method:
[0169] Acquire first graph data input by a user; the first graph data includes point data and edge data;
[0170] Performing a decomposition operation on the first graph data to obtain corresponding graph data units;
[0171] Generating a word set corresponding to the first graph data according to the attribute information of each of the graph data units;
[0172] Based on the word set, graph data related to the first graph data is searched.
[0173] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0174] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0175] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, AtmelAT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0176] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices. For the convenience of description, the above devices are described separately by function into various units. Of course, when implementing this application, the functions of each unit may be implemented in the same or more software and / or hardware.
[0177] 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.
[0178] 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.
[0179] 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.
[0180] 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 In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0181] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0182] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0183] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0184] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt 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.) that contain computer-usable program code.
[0185] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0186] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A graph search method, comprising: Acquire first graph data input by a user; the first graph data includes point data and edge data; Performing a decomposition operation on the first graph data to obtain corresponding graph data units; Generate a word set corresponding to the first graph data according to the attribute information of each of the graph data units; each word in the word set is generated based on encoding the attribute information of each of the graph data units; Based on the word set, searching for graph data related to the first graph data; The searching for graph data related to the first graph data based on the word set specifically includes: Based on the word set, target graph data whose degree of inclusion between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, or target graph data whose degree of similarity between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, is determined as graph data related to the first graph data; the degree of inclusion is used to represent the quotient of a first number of repeated words between a word list corresponding to the first graph data and a word list corresponding to the target graph data and a second number of words corresponding to the first graph data.
2. According to the method of claim 1, performing a decomposition operation on the first graph data to obtain corresponding units specifically comprises: Decomposing the first graph data according to a preset rule to obtain corresponding units; One of the units includes one node data in the first graph data, or one of the units includes edge data in the first graph data and node data connected by the edge.
3. According to the method of claim 1, generating a word set corresponding to the first graph data according to the attribute information of the unit specifically comprises: For any of the units, determine the node data and edge data in the unit; Determine attribute information of the node data and the edge data; Perform hash calculation on the attribute information to obtain the word corresponding to the unit, The word is determined as an element in the word set.
4. The method according to claim 1, wherein based on the word set, determining the target graph data whose similarity between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold as graph data related to the first graph data, specifically comprises: Normalizing the vectors corresponding to the words in the word set to obtain a first graph vector corresponding to the first graph data; Based on the first graph vector, determining a set of candidate graph data corresponding to the first graph data from the graph database; Based on the word set, the target graph data whose similarity with the first graph data satisfies a first preset condition is determined from the candidate graph data set.
5. The method according to claim 4, wherein based on the word set, determining the target graph data from the candidate graph data set whose similarity with the first graph data satisfies a first preset condition, specifically comprises: Calculate the similarity between the words in the word set and the words in each graph data in the candidate graph data set; Determine target graph data in the candidate graph data set whose similarity is greater than or equal to a preset similarity threshold.
6. According to the method of claim 5, if there are multiple target graph data in the candidate graph data set whose similarity is greater than or equal to the preset similarity threshold, the graph data with the greatest similarity in the candidate graph data set is determined as the target graph data.
7. The method according to claim 1, after determining, based on the word set, the target graph data whose similarity between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold as graph data related to the first graph data, further comprising: The ID of the target graph data and the similarity value are sent to the user's terminal.
8. The method according to claim 1, wherein based on the word set, determining the target graph data whose inclusion degree between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold as graph data related to the first graph data, specifically comprises: Based on the word set, determining a candidate graph data set including the word set according to an inverted index method; Calculate the inclusion degree of the word set and each graph data in the candidate graph data set; The graph data in the candidate graph data set whose inclusion degree is greater than or equal to a preset inclusion degree threshold is determined as the target graph data.
9. According to the method of claim 8, if there are multiple graph data in the candidate graph data set whose inclusion degree is greater than or equal to a preset inclusion degree threshold, the graph data with the largest inclusion degree in the candidate graph data set is determined as the target graph data.
10. The method according to claim 1, after determining, based on the word set, the target graph data in the graph database whose inclusion degree with the first graph data is greater than or equal to a preset threshold as graph data related to the first graph data, further comprises: The ID of the target graph data and the inclusion value are sent to the user's terminal.
11. The method according to claim 1, further comprising: Obtaining a modification instruction input by the user; Based on the modification instruction, modify the corresponding original graph data in the graph database to obtain second graph data; The second graph data includes the ID of the original graph data, the ID of the second graph data, the attribute information of the node data in the second graph data, and the attribute information of the edge data in the second graph data; The second graph data is processed according to preset rules and then stored in the graph database.
12. The method according to claim 11, further comprising: The original graph data in the graph database is deleted.
13. A graph search device, comprising: A first image data acquisition module, used to acquire first image data input by a user; The first graph data includes point data and edge data; A decomposition module, used to perform a decomposition operation on the first graph data to obtain corresponding graph data units; A word set generation module, used to generate a word set corresponding to the first graph data according to the attribute information of each of the graph data units; each word in the word set is generated based on encoding the attribute information of each of the graph data units; A graph data search module, configured to search for graph data related to the first graph data based on the word set; The graph data search module is specifically used for: Based on the word set, target graph data whose degree of inclusion between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, or target graph data whose degree of similarity between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, is determined as graph data related to the first graph data; the degree of inclusion is used to represent the quotient of a first number of repeated words between a word list corresponding to the first graph data and a word list corresponding to the target graph data and a second number of words corresponding to the first graph data.
14. A graph search device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire first graph data input by a user; the first graph data includes point data and edge data; Performing a decomposition operation on the first graph data to obtain corresponding graph data units; Generate a word set corresponding to the first graph data according to the attribute information of each of the graph data units; each word in the word set is generated based on encoding the attribute information of each of the graph data units; Based on the word set, searching for graph data related to the first graph data; The searching for graph data related to the first graph data based on the word set specifically includes: Based on the word set, target graph data whose degree of inclusion between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, or target graph data whose degree of similarity between the graph data in the graph database and the first graph data is greater than or equal to a preset threshold, is determined as graph data related to the first graph data; the degree of inclusion is used to represent the quotient of a first number of repeated words between a word list corresponding to the first graph data and a word list corresponding to the target graph data and a second number of words corresponding to the first graph data.
15. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method of any one of claims 1 to 12.
