Directed graph ring detection method and device, computer device and readable storage medium
By performing data preprocessing and initialization on the directed graph, and using a multi-party key sharing algorithm and preset rules to handle public and private nodes respectively, the problem of data leakage in traditional ring detection algorithms under multiple data holders is solved, and highly secure ring detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2026-03-31
AI Technical Summary
Traditional ring detection algorithms are prone to leaking data information in graph databases when the directed graph structure is distributed among multiple data holders, resulting in low data security in the financial industry.
By acquiring the directed graph to be detected, data preprocessing is performed and node identifiers are obtained. The graph nodes are initialized using a multi-party key sharing algorithm and preset rules, generating public and local initial values for public and private nodes respectively. Ring detection is then performed to ensure data security.
In scenarios with multiple data holders, loop detection was implemented without leaking private data in the financial industry, thus improving data security.
Smart Images

Figure CN116701715B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial technology, and in particular to a method, apparatus, computer device, and readable storage medium for detecting directed graph loops. Background Technology
[0002] In recent years, with the rapid development of e-commerce, finance, and the Internet of Things, a vast and complex network of relationships has emerged in society. Relational databases cannot effectively represent the connections between samples within this network, while some non-relational databases fail to represent the relationships between features. Graph databases, however, are well-suited for the aforementioned financial industry scenarios. Graph databases store data in a graph structure, enabling the storage of interconnected data. In directed graph structures, loops reflect a unique data flow of physical entities in the real world, making loop detection a crucial function in graph databases. However, traditional loop detection algorithms rely on full graph information. When the graph structure is distributed across multiple data holders, traditional loop detection algorithms are prone to data leakage during loop detection, leading to low data security in the financial industry. Summary of the Invention
[0003] The purpose of this application is to at least partially solve the problems of the prior art and provide a method, apparatus, computer device and readable storage medium for detecting directed graph loops, which can detect directed graphs in the financial industry without leaking private data and has a high level of data security.
[0004] The technical solution of this application embodiment is as follows:
[0005] Firstly, this application provides a method for detecting loops in a directed graph, the method comprising:
[0006] Obtain the directed graph to be detected, wherein the directed graph to be detected includes multiple graph nodes;
[0007] Perform data preprocessing on each graph node to obtain the node identifier corresponding to each graph node;
[0008] Send the node identifier corresponding to each of the graph nodes to a preset server, and receive the category corresponding to each of the graph nodes returned by the server;
[0009] For the graph nodes classified as public nodes, a multi-party key sharing algorithm is used to initialize the graph nodes and obtain common initial values.
[0010] For the graph node of the category of private node, the graph node is initialized using preset rules to obtain local initial values;
[0011] Based on the graph nodes, the common initial values, and the local initial values, ring detection processing is performed to obtain the detection results.
[0012] According to some embodiments of this application, each graph node is provided with a detection label and a stack label, wherein the detection label indicates whether the graph node is detected and the stack label indicates whether the graph node is in the stack;
[0013] For the graph nodes classified as public nodes, a multi-party key sharing algorithm is used to initialize the graph nodes and obtain common initial values, including:
[0014] The multi-party key sharing algorithm is used to assign values to the detection tag and the stack tag respectively, so as to obtain the first detection value corresponding to the detection tag and the first stack value corresponding to the stack tag;
[0015] The first detection value and the first stack value constitute the common initial value.
[0016] According to some embodiments of this application, the ring detection processing based on the graph nodes, the common initial value, and the local initial value to obtain the detection result includes:
[0017] For the graph node of the category of public node, the first detection value and the first stack value are processed by the multi-party key sharing algorithm to obtain the second detection value corresponding to the detection label and the second stack value corresponding to the stack label.
[0018] When the second detection value is the first preset value and the second stack value is the first preset value, both the second detection value and the second stack value are set to the second preset value, and loop detection is performed on the neighboring nodes of the graph node.
[0019] If the neighbor node returns the second preset value, the graph node is determined to be on the ring.
[0020] According to some embodiments of this application, the initialization process for graph nodes of the category of private nodes, using preset rules to obtain local initial values, includes:
[0021] The detection label and the stack label are assigned values according to the preset rules to obtain the third detection value corresponding to the detection label and the third stack value corresponding to the stack label.
[0022] The third detection value and the third stack value constitute the local initial value.
[0023] According to some embodiments of this application, the ring detection processing based on the graph nodes, the common initial value, and the local initial value to obtain the detection result includes:
[0024] For the graph node of the category of private node, if the third detection value is the first preset value and the third stack value is the first preset value, both the third detection value and the third stack value are set to the second preset value, and ring detection is performed on the neighboring nodes of the graph node.
[0025] If the neighbor node returns the second preset value, the graph node is determined to be on the ring.
[0026] According to some embodiments of this application, the step of performing data preprocessing on each graph node to obtain the node identifier corresponding to each graph node includes:
[0027] Each graph node is initialized to obtain the initial identifier corresponding to each graph node;
[0028] Each of the initial identifiers is de-identified to obtain the node identifier.
[0029] According to some embodiments of this application, after performing ring detection on the neighbor nodes of the graph node, the method further includes:
[0030] If the neighbor node returns a third preset value, it is determined that the graph node is not on the ring.
[0031] Secondly, this application provides a directed graph loop detection device, comprising:
[0032] The graph acquisition module is used to acquire a directed graph to be detected, wherein the directed graph to be detected includes multiple graph nodes;
[0033] The preprocessing module is used to preprocess the data of each graph node to obtain the node identifier corresponding to each graph node;
[0034] The interaction module is used to send the node identifiers corresponding to each of the graph nodes to a preset server and receive the categories corresponding to each of the graph nodes returned by the server.
[0035] The first processing module is used to initialize the graph nodes of the category of public nodes using a multi-party key sharing algorithm to obtain common initial values.
[0036] The second processing module is used to initialize the graph nodes of the category of private nodes using preset rules to obtain local initial values.
[0037] The detection module is used to perform ring detection processing based on the graph nodes, the common initial values, and the local initial values to obtain the detection results.
[0038] Thirdly, this application provides a computer device including a memory and a processor, wherein the memory stores computer-readable instructions that, when executed by one or more of the processors, cause the one or more processors to perform the steps of any of the methods described in the first aspect above.
[0039] Fourthly, this application also provides a computer-readable storage medium that can be read and written by a processor, the storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of any of the methods described in the first aspect above.
[0040] The technical solution provided in this application has the following beneficial effects:
[0041] This application proposes a directed graph ring detection method, apparatus, computer device, and readable storage medium. The method acquires a directed graph to be detected, which includes multiple graph nodes. For each graph node, data preprocessing is performed to obtain a node identifier. The node identifiers are sent to a preset server, and the server returns the category of each graph node, facilitating subsequent processing based on the category. For graph nodes classified as public, a multi-party key sharing algorithm is used to initialize the nodes, obtaining a public initial value to ensure the privacy of public nodes is not leaked. For graph nodes classified as private, preset rules are used to initialize the nodes, obtaining a local initial value to ensure the privacy of private nodes is not leaked. Ring detection is performed based on the graph nodes, the public initial value, and the local initial value to obtain the detection result. Compared to existing financial industry technologies where data is distributed among multiple holders, leading to information leakage, the embodiments of this application obtain the categories of graph nodes and process the corresponding graph nodes for different categories using multi-party key sharing algorithms and preset rules. This enables loop detection in the case of multiple data holders without leaking private financial industry data, thereby improving data security. Attached Figure Description
[0042] Figure 1 This is a schematic flowchart of a directed graph loop detection method provided in one embodiment of this application;
[0043] Figure 2 yes Figure 1A flowchart illustrating a sub-step of step S140;
[0044] Figure 3 yes Figure 1 A flowchart illustrating a sub-step of step S160;
[0045] Figure 4 yes Figure 1 A flowchart illustrating a sub-step of step S150;
[0046] Figure 5 yes Figure 1 A flowchart illustrating another sub-step of step S160;
[0047] Figure 6 yes Figure 1 A flowchart illustrating a sub-step of step S120;
[0048] Figure 7 This is a schematic diagram of the overall process of a directed graph loop detection method provided in one embodiment of this application;
[0049] Figure 8 This is a schematic diagram of the structure of a directed graph loop detection device provided in one embodiment of this application;
[0050] Figure 9 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0053] This application proposes a directed graph ring detection method, apparatus, computer device, and readable storage medium. The method acquires a directed graph to be detected, which includes multiple graph nodes. For each graph node, data preprocessing is performed to obtain a node identifier. The node identifiers are sent to a preset server, and the server returns the category of each graph node, facilitating subsequent processing based on the category. For graph nodes classified as public, a multi-party key sharing algorithm is used to initialize the nodes, obtaining a public initial value to ensure the privacy of public nodes is not leaked. For graph nodes classified as private, preset rules are used to initialize the nodes, obtaining a local initial value to ensure the privacy of private nodes is not leaked. Ring detection is performed based on the graph nodes, the public initial value, and the local initial value to obtain the detection result. Compared with existing technologies where data is distributed among multiple holders, leading to information leakage, the embodiments of this application obtain the category of graph nodes and process the corresponding graph nodes for different categories using multi-party key sharing algorithms and preset rules. This enables loop detection in the case of multiple data holders without leaking private data in the financial industry, resulting in higher data security.
[0054] It should be noted that the directed graph cycle detection method can be applied to joint cycle detection in multi-graph databases as well as single-graph databases. The business data stored in the graph databases can be complex networks of relationships, such as those related to financial, medical, and life insurance businesses. This directed graph detection method is suitable for federated directed graph cycle detection, ensuring data privacy and high data security even with multiple data holders.
[0055] In one embodiment, the directed graph cycle detection method can run on a terminal or a server. The terminal can be a tablet computer, laptop computer, desktop computer, etc., but is not limited to these. The server can be a desktop computer, laptop computer, etc. In addition, the server can also be a server cluster composed of multiple physical servers, and can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0056] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.
[0057] The embodiments of this application can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. This application can 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. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can reside in local and remote computer storage media, including storage devices.
[0058] The directed graph loop detection method, apparatus, computer equipment, and readable storage medium provided in the embodiments of this application will now be described with reference to the accompanying drawings.
[0059] See Figure 1 , Figure 1 The diagram illustrates a flow chart of a directed graph loop detection method provided in an embodiment of this application. This directed graph loop detection method includes, but is not limited to, steps S110, S120, S130, S140, S150, and S160.
[0060] Step S110: Obtain the directed graph to be detected, which includes multiple graph nodes.
[0061] In one embodiment, the directed graph to be detected is obtained through a preset reading interface. This interface can either read the directed graph from the database into memory all at once, disconnect from the database, and then read the graph from memory again, or establish a fixed connection with the database so that the connection remains open during each data read. The directed graph to be detected includes multiple graph nodes. In the graph, the edges connecting one graph node to another are directed, indicating the direction of information transmission. Obtaining this directed graph facilitates subsequent graph detection processing. The directed graph to be detected can be a directed graph from the financial industry, such as a directed graph for banking operations, insurance operations, order systems, or payment systems.
[0062] Step S120: Perform data preprocessing on each graph node to obtain the node identifier corresponding to each graph node.
[0063] like Figure 6 As shown, data preprocessing is performed on each graph node to obtain the node identifier corresponding to each graph node, including but not limited to the following steps:
[0064] Step S121: Initialize each graph node to obtain the initial identifier corresponding to each graph node.
[0065] In one embodiment, each graph node undergoes initialization processing. Specifically, information extraction is performed on each graph node, and the extracted information is marked as a graph node ID. That is, the graph node ID includes the extracted information, resulting in an initial identifier for each graph node. This initial identifier is the information transmitted to the server for processing. The graph node can be a node in a directed graph within the financial industry. By initializing each graph node, the corresponding node identifier can be obtained.
[0066] Step S122: Desensitize each initial identifier to obtain the node identifier.
[0067] In one embodiment, the initial identifier obtained in step S121 may include some sensitive privacy information. To prevent privacy leakage due to improper use of sensitive information, each initial identifier is de-identified to obtain a node identifier, thereby ensuring that privacy data is not leaked. The node identifier can be obtained by de-identifying the initial identifier using a hash algorithm, numerical substitution, or other de-identification algorithms, as long as privacy information leakage is avoided. Details are omitted here. The privacy data can be sensitive privacy data in banking operations or privacy data related to buyers and sellers in insurance operations.
[0068] Step S130: Send the node identifiers corresponding to each graph node to the preset server, and receive the categories corresponding to each graph node returned by the server.
[0069] In one embodiment, the anonymized node identifiers corresponding to each graph node are sent to a preset server. The preset server performs a merge calculation on the node identifier information. By merging the node identifiers corresponding to multiple participating graph nodes, the category corresponding to the graph node is obtained, and the category corresponding to the graph node is returned. Receiving the categories corresponding to each graph node returned by the server is beneficial for subsequent initialization processing of the graph nodes according to different categories. The preset server is a recognized and trusted third-party server. The merge calculation can be used to obtain interaction information between multiple data holders, designating nodes containing interaction information as public nodes and nodes that do not interact as private nodes. The node identifiers corresponding to each graph node are sent to the preset server. For example, for a directed graph of banking business, the node identifiers corresponding to each graph node of the directed graph of banking business can be sent to the preset server. The directed graph of banking business can include directed graphs of customer information, loan information, and deposit information, etc.
[0070] Step S140: For graph nodes of the category of public nodes, the graph node is initialized using a multi-party key sharing algorithm to obtain a common initial value.
[0071] In one embodiment, for graph nodes classified as public nodes, public nodes mean that the information of the graph node can be shared with other data holders. By using a multi-party key sharing algorithm to initialize the graph nodes, and combining directed graph detection processing with the multi-party key sharing algorithm, the information of the graph node can be prevented from being leaked during transmission, ensuring data security. For example, in banking operations, the directed graphs for customer information and loan information have graph nodes classified as public nodes. Therefore, a multi-party private key sharing algorithm can be used to initialize the graph nodes, thereby obtaining the corresponding public initial values.
[0072] In another embodiment, each graph node is provided with a detection label and a stack label. The detection label indicates whether the graph node has been detected, and the stack label indicates whether the graph node is in the stack. Figure 2 As shown, for graph nodes of the category of public nodes, a multi-party key sharing algorithm is used to initialize the graph nodes and obtain common initial values, including but not limited to the following steps:
[0073] Step S141: Use a multi-party key sharing algorithm to assign values to the detection tag and the stack tag respectively, to obtain the first detection value corresponding to the detection tag and the first stack value corresponding to the stack tag.
[0074] For example, the detection tag is assigned a value using a multi-party key sharing algorithm to obtain the first detection value corresponding to the detection tag. Specifically, the detection tag is a Boolean type, and the value of the detection tag is represented by 0 and 1 in the computer, where 0 represents no and 1 represents yes. There are n data holders participating in the n-party key sharing. The detection tag x is split into n parts x1, x2, ..., xn, satisfying x1 + x2 + ... + xn = x, where 1 + floor(n / 2) parts are sent to each participant (floor means rounding down, floor(1) = 1, floor(2.5) = 2, and when n = 5, 1 + floor(n / 2) = 3). The i-th participant sends x 1, x2, x3 are sent to the (i+1)%n side, x2, x3, x4 are sent to the (i+2)%n side, x3, x4, x5 are sent to the (i+3)%n side, x4, x5, x1 are sent to the (i+4)%n side, x5, x1, x2 are sent to the (i+5)%n side. Here, since i will exceed n when it increases to a certain extent, % represents the remainder when divided by integers. For example, (3+4)%5 is the remainder 2 when 7 is divided by 5. Once a tag is shared, assigning it the value 0 is equivalent to multiplying it by 0. Sharing 0 with all parties in this way is denoted as y. The calculation method for the i-th participant is x multiplied by y, which equals z. The formula is: zi=xi*sumi(y)+xk*sumi(y[:k-1]), where k=n-floor(n / 2), sumi(y) represents summing all y values for the i-th participant, and sumi(y[:k-1]) represents summing the first k-1 y values for the i-th participant. The calculation methods for each participant are as follows:
[0075] The calculation for the first side is: z1 = x1*(y1+y2+y3) + x3*(y1+y2);
[0076] The second side is calculated as: z2 = x2*(y2+y3+y4) + x4*(y2+y3);
[0077] The third party's calculation is: z3=x3*(y3+y4+y5)+x5*(y3+y4);
[0078] The fourth side is calculated as: z4 = x4*(y4+y5+y1) + x1*(y4+y5);
[0079] The fifth party is calculated as follows: z5 = x5*(y5+y1+y2)+x2*(y5+y1);
[0080] Where z = z1 + z2 + z3 + z4 + z5 = (x1 + x2 + x3 + x4 + x5) * (y1 + y2 + y3 + y4 + y5) = x * y. When a tag is shared, assigning the tag a value of 1 is equivalent to multiplying by 0 and adding 1. Calculating z = x + y only requires the i-th participant to calculate zi = xi + yi.
[0081] In one embodiment, a multi-party key sharing algorithm is used to assign values to the detection tag and the stack tag respectively, and the values are shared and stored among multiple parties. During application, the shared values are retrieved from these parties, and the first detection value corresponding to the detection tag and the first stack value corresponding to the stack tag are obtained by solving n+1 equations. In multi-graph data joint loop detection, the privacy information transmitted is guaranteed not to be leaked. Specifically, the first detection value is the value assigned to the detection tag using the multi-party key sharing algorithm, and the first stack value is the value assigned to the stack tag using the same algorithm.
[0082] Step S142: The first detection value and the first stack value constitute a common initial value.
[0083] In one embodiment, the first detection value and the first stack value obtained in step S141 are shared with other participants. This shared initial value not only enables information sharing but also ensures that information privacy is not compromised. For example, in banking operations, the first detection value and the first stack value of the directed graph of loan information can constitute the corresponding shared initial value.
[0084] Step S150: For graph nodes of the category of private nodes, initialize the graph nodes using preset rules to obtain local initial values.
[0085] In one embodiment, for graph nodes classified as private nodes, a private node means that its information is not shared with other participants. Private nodes are stored locally, and the graph nodes are initialized using preset rules. By initializing private nodes locally and avoiding information sharing, privacy information is prevented from being leaked, thus ensuring data security. For example, in insurance business, the directed graph for claims processing has private graph nodes. These nodes need to be initialized using preset rules to obtain their corresponding local initial values.
[0086] In another embodiment, each graph node is provided with a detection label and a stack label. The detection label indicates whether the graph node has been detected, and the stack label indicates whether the graph node is in the stack. Figure 4 As shown, for graph nodes of the category of private nodes, the graph nodes are initialized using preset rules to obtain local initial values, including but not limited to the following steps:
[0087] Step S151: Using preset rules, assign values to the detection label and the stack label respectively to obtain the third detection value corresponding to the detection label and the third stack value corresponding to the stack label.
[0088] In one embodiment, the preset rule can be to directly set the value of the label, or to first initialize the label and then convert the initial value. When the graph node is a private node, the preset rule is used to assign values to the detection label and the stack label respectively, obtaining the third detection value corresponding to the detection label and the third stack value corresponding to the stack label. By initializing the private node locally without information sharing, privacy information is avoided, ensuring data security. Specifically, the third detection value is the value assigned to the detection label using the preset rule, and the third stack value is the value assigned to the stack label using the preset rule.
[0089] In step S152, the third detection value and the third stack value constitute the local initial value.
[0090] In one embodiment, the third detection value and the third stack value obtained in step S151 are stored locally to form local initial values. These local initial values are not shared to ensure that information privacy is not leaked. For banking operations, preset rules are used to assign values to the detection tags and stack tags respectively to obtain the third detection value corresponding to the detection tag and the third stack value corresponding to the stack tag; the obtained third detection value and third stack value constitute the corresponding local initial values.
[0091] Step S160: Perform ring detection processing based on graph nodes, common initial values, and local initial values to obtain the detection results.
[0092] like Figure 3 As shown, ring detection is performed based on graph nodes, common initial values, and local initial values to obtain the detection results, including but not limited to the following steps:
[0093] Step S161: For graph nodes of the category of public nodes, use a multi-party key sharing algorithm to perform label evaluation on the first detection value and the first stack value to obtain the second detection value corresponding to the detection label and the second stack value corresponding to the stack label.
[0094] In one embodiment, for directed graph detection, a starting graph node is selected. This can be done randomly, by selecting the node with the fewest connected edges, or by selecting the node with the most connected edges; details are omitted here. Cycle detection begins from the starting node. For graph nodes classified as public nodes, the label value is shared with other participants during label initialization using a multi-party key sharing algorithm to ensure the privacy of the graph node is not leaked. When performing cycle detection on this node, the first detection value and the first stack value are processed using the multi-party key sharing algorithm to obtain the second detection value corresponding to the detection label and the second stack value corresponding to the stack label. This facilitates subsequent determination of whether the graph node is on a cycle based on the second detection value and the second stack value. For example, when party i initiates ring detection, and the graph node type of party i is a public node, the first detection value is processed by label evaluation using multi-party key sharing. Specifically, party i+floor(n / 2) sends its shared x to party i. Since each participant has 1+floor(n / 2) copies, if n is odd, (1+floor(n / 2))*2 = n+1; if n is even, (1+floor(n / 2))*2 = n+2. The number of copies for both parties must be greater than n, including each of the n copies, thus the original value x = x1+x2+…+xn can be restored. This not only enables ring detection processing based on the second detection value and the second stack value, but also ensures that privacy is not leaked. The second detection value obtained through the above method is the real value corresponding to the detection label of the initiating party, and the second stack value is the real value corresponding to the stack label of the initiating party.
[0095] Step S162: If the second detection value is the first preset value and the second stack value is the first preset value, set both the second detection value and the second stack value to the second preset value, and perform ring detection on the neighboring nodes of the graph node.
[0096] In one embodiment, when both the second detection value and the second stack value are set to the first preset value, cycle detection is performed on the neighboring nodes of the graph node. The cycle detection on neighboring nodes is similar to the initial detection of the graph node; the values corresponding to the detection labels and stack labels are obtained according to the category of the neighboring node. The neighboring nodes return corresponding detection results after the detection is performed. The first preset value is "no," and the second preset value is "yes." Alternatively, the first preset value can be "not detected" or "not present," represented as 0, and the second preset value can be "detected" or "existing," represented as 1. Specifically, for a directed graph in the banking industry, when both the second detection value and the second stack value are set to the first preset value, cycle detection is performed on the neighboring nodes of the graph node.
[0097] Step S163: If the return result of the neighbor node is the second preset value, determine that the graph node is on the ring.
[0098] In one embodiment, if a neighboring node has no other neighbors besides the starting graph node (i.e., the directed graph consists of two graph nodes forming a directed cycle), and the neighboring node returns a second preset value, it indicates that the starting graph node has been detected and is in the stack, and the neighboring nodes of the starting graph node have been detected and are in the stack. Therefore, it is determined that the starting graph node and the graph nodes are on the cycle. Cycle detection effectively avoids the waste of resources caused by unlimited information transmission.
[0099] like Figure 5 As shown, ring detection is performed based on graph nodes, common initial values, and local initial values to obtain the detection results, including but not limited to the following steps:
[0100] Step S164: For a graph node of type private node, if the third detection value is the first preset value and the third stack value is the first preset value, both the third detection value and the third stack value are set to the second preset value, and ring detection is performed on the neighboring nodes of the graph node.
[0101] In one embodiment, for the directed graph to be detected, a starting graph node is selected, and cycle detection is performed starting from the starting graph node. For graph nodes whose category is private nodes, if the third detection value and the third stack value are both set to the first preset value, then both the third detection value and the third stack value are set to the second preset value. Cycle detection is then performed on the neighboring nodes of the graph node. The cycle detection on neighboring nodes is similar to that on the starting graph node. The values corresponding to the detection labels and stack labels are obtained according to the categories of the neighboring nodes. By detecting the neighboring nodes, the neighboring nodes can return the corresponding detection results. Here, the first preset value is no, and the second preset value is yes; alternatively, the first preset value can be 0 (not detected or not existing) and the second preset value can be 1 (detected or existing).
[0102] Step S165: If the return result of the neighbor node is the second preset value, determine that the graph node is on the ring.
[0103] In one embodiment, if a neighboring node has no other neighbors besides the starting node (i.e., the directed graph consists of two nodes forming a directed cycle), and the neighboring node returns a second preset value, it indicates that the starting node has been detected and is in the stack, and the initial node's neighboring nodes have been detected and are in the stack. Therefore, it is determined that the starting node and the other nodes are on the cycle. Cycle detection effectively avoids wasted resources caused by infinite information transmission.
[0104] In one embodiment, the directed graph cycle detection method is also used for cycle detection in a directed graph with two or more graph nodes, where the graph nodes in the directed graph include both public and private nodes. For example, a graph node is first selected as the first node to be detected. If the label value of this graph node is detected as a second preset value, then this graph node is skipped, and a graph node connected to this node is randomly selected as the starting graph node. Alternatively, other methods can be used to select a graph node to begin detection. If the label values of all graph nodes are the second preset value, it indicates that all graph nodes have been detected, the directed graph has been detected, and the recorded detection result is returned.
[0105] In another embodiment, the directed graph cycle detection method is also used for cycle detection in a directed graph with two or more graph nodes, where the graph nodes in the directed graph include both public and private nodes. For example, firstly, a graph node is selected as the first node to be detected. The type of the graph node is determined, and its label value and stack value are obtained based on the node type. If the label value and stack value of the graph node are both a first preset value, both the label value and stack value are set to a second preset value, and cycle detection is performed on the neighboring nodes of the graph node. Then, the type of the neighboring nodes is determined, and their label values and stack values are obtained based on the neighboring node type. If the label value and stack value of the neighboring node are both a first preset value, both the label value and stack value are set to a second preset value, and cycle detection is performed on the neighboring nodes of the neighboring nodes. Cycle detection is performed sequentially according to the above detection method. If the return result of a neighboring node is a third preset value, it indicates that there is no cycle on that path, and the graph node is determined not to be on a cycle. The third preset value can be empty, indicating that the neighboring node did not return a detection result, thus confirming that the graph node is not on the ring.
[0106] For example, a graph node is randomly selected as the first node to be detected. This graph node is a public node. A second detection value and a second stack value are obtained using a multi-party key sharing algorithm. If the label value and stack value of this graph node are both detected as a first preset value, both the label value and stack value are set to the second preset value. Graph cycle detection is then performed on the neighboring nodes of this graph node. If the neighboring nodes are private nodes, a third detection value and a third stack value are directly detected. If the label value and stack value of this neighboring node are both detected as a first preset value, both the label value and stack value are set to the second preset value. Graph cycle detection is then performed on the neighboring nodes of these neighboring nodes. If all neighboring nodes return the third preset value, it indicates that there is no cycle on this path, and the graph node is determined not to be on a cycle. Alternatively, if the neighboring nodes are public nodes, the detection is performed in the same way as the first graph node. Finally, based on the return results of the neighboring nodes, it is determined whether the graph node is on a cycle.
[0107] See Figure 7 , Figure 7This diagram illustrates the overall flow of the directed graph cycle detection method provided in this application embodiment. First, step S201 is executed to obtain the directed graph to be detected, which includes multiple graph nodes. Then, step S202 is executed to initialize each graph node, obtaining an initial node. Next, step S203 is executed to de-identify the initial nodes, obtaining node identifiers. The node identifiers corresponding to each graph node are sent to a preset server, and the category corresponding to each graph node is received from the server, which facilitates subsequent processing operations based on the category of the graph node. Step S204 is executed, for graph nodes of the category of public nodes, a multi-party key sharing algorithm is used to assign labels to the graph nodes, obtaining common initial values. For public nodes in the interaction, encryption is performed using a multi-party key sharing algorithm to ensure that the privacy data of graph nodes classified as public nodes is not leaked. Step S206 is executed, where graph nodes classified as private nodes are tagged using preset rules to obtain local initial values. Private nodes are set locally without interaction, ensuring that the privacy data of graph nodes classified as private nodes is not leaked. Then, step S205 is executed to obtain the tag values using multi-party key sharing, and step S207 is executed to obtain the local node tag values. Step S208 is executed, where the tag values are used to detect the directed graph to be detected. Finally, step S209 is executed, where the detection results are obtained based on the detected graph nodes and the tag markings. This embodiment of the application, by obtaining the category of graph nodes and processing the corresponding graph nodes for different categories using a multi-party key sharing algorithm and preset rules, can perform ring detection without leaking the privacy data of the financial industry, thus improving data security.
[0108] See Figure 8This application provides a directed graph loop detection device 100. The device 100 acquires a directed graph to be detected via a graph acquisition module 110, which includes multiple graph nodes. A preprocessing module 120 preprocesses each graph node to obtain its corresponding node identifier. An interaction module 130 sends the node identifiers to a preset server and receives the category of each graph node returned by the server, facilitating subsequent processing based on the node's category. For graph nodes classified as public nodes, a first processing module 140 initializes them using a multi-party key sharing algorithm. For public nodes interacting with each other, encryption is performed using a multi-party key sharing algorithm to ensure that the privacy data of graph nodes classified as public nodes is not leaked. For graph nodes classified as private nodes, the second processing module 150 initializes them using preset rules to obtain local initial values. Private nodes are then set locally without interaction, ensuring that the privacy data of graph nodes classified as private nodes is not leaked. Finally, the detection module 160 performs ring detection based on the graph nodes, public initial values, and local initial values to obtain the detection results. With the participation of multiple parties, ring detection can be performed without leaking private data in the financial industry, improving data security.
[0109] It should be noted that the graph acquisition module 110 is connected to the preprocessing module 120, the preprocessing module 120 is connected to the interaction module 130, the interaction module 130 is connected to the first processing module 140, the first processing module 140 is connected to the second processing module 150, and the second processing module 150 is connected to the detection module 160. Both the first processing module 140 and the second processing module 150 are central processing units (CPUs). A CPU typically consists of a logic unit, a control unit, and a storage unit. Utilizing a CPU for computation saves significant human resources. The aforementioned directed graph cycle detection method is applied to the directed graph cycle detection device 100. This device, by obtaining the category of the graph nodes, processes the corresponding graph nodes for different categories using a multi-party key sharing algorithm and preset rules. This allows for cycle detection without leaking private data, resulting in high data security.
[0110] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0111] Figure 9This application illustrates a computer device 500 provided in an embodiment of the present application. The computer device 500 may be a server or a terminal, and its internal structure includes, but is not limited to:
[0112] Memory 510 is used to store programs;
[0113] The processor 520 is used to execute the program stored in the memory 510. When the processor 520 executes the program stored in the memory 510, the processor 520 is used to execute the directed graph loop detection method described above.
[0114] The processor 520 and memory 510 can be connected via a bus or other means.
[0115] The memory 510, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs, such as the directed graph cycle detection method described in any embodiment of this application. The processor 520 implements the above-described directed graph cycle detection method by running the non-transitory software program and instructions stored in the memory 510.
[0116] The memory 510 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function. The data storage area may store the directed graph cycle detection method described above. Furthermore, the memory 510 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 510 may optionally include memory remotely located relative to the processor 520, and these remote memories may be connected to the processor 520 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0117] The non-transient software program and instructions required to implement the above-described directed graph loop detection method are stored in the memory 510. When executed by one or more processors 520, the directed graph loop detection method provided in any embodiment of this application is executed.
[0118] This application also provides a computer-readable storage medium storing computer-executable instructions for performing the above-described directed graph loop detection method.
[0119] In one embodiment, the storage medium stores computer-executable instructions that are executed by one or more control processors 520, such as one processor 520 in the computer device 500, to enable the one or more processors 520 to perform the directed graph loop detection method provided in any embodiment of this application.
[0120] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0121] The terms “first,” “second,” “third,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0122] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0123] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0124] The foregoing has provided a detailed description of the preferred embodiments of this application. However, this application is not limited to the above-described embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.
Claims
1. A directed graph loop detection method, characterized by, The method comprises: acquiring a to-be-detected directed graph, the to-be-detected directed graph comprising a plurality of graph nodes; performing data preprocessing on each of the graph nodes to obtain a node identifier corresponding to each of the graph nodes; sending the node identifier corresponding to each of the graph nodes to a preset server and receiving a category corresponding to each of the graph nodes returned by the server; for the graph node of the public node category, performing initialization processing on the graph node by using a multi-party key sharing algorithm to obtain a public initial value; for the graph node of the private node category, performing initialization processing on the graph node by using a preset rule to obtain a local initial value; performing ring detection processing based on the graph node, the public initial value, and the local initial value to obtain a detection result; each of the graph nodes is provided with a detection label and a stack label, the detection label indicating whether the graph node is detected, and the stack label indicating whether the graph node is in a stack; for the graph node of the public node category, the initialization processing on the graph node by using the multi-party key sharing algorithm to obtain the public initial value comprises: label assignment is performed on the detection label and the stack label respectively by using the multi-party key sharing algorithm to obtain a first detection value corresponding to the detection label and a first stack value corresponding to the stack label; the first detection value and the first stack value constitute the public initial value; for the graph node of the private node category, the initialization processing on the graph node by using the preset rule to obtain the local initial value comprises: label assignment is performed on the detection label and the stack label respectively by using the preset rule to obtain a third detection value corresponding to the detection label and a third stack value corresponding to the stack label; the third detection value and the third stack value constitute the local initial value; the ring detection processing based on the graph node, the public initial value, and the local initial value to obtain the detection result comprises: for the graph node of the public node category, label evaluation processing is performed on the first detection value and the first stack value by using the multi-party key sharing algorithm to obtain a second detection value corresponding to the detection label and a second stack value corresponding to the stack label; in a case where the second detection value is a first preset value and the second stack value is the first preset value, the second detection value and the second stack value are both set to a second preset value, and ring detection is performed on a neighbor node of the graph node; in a case where a return result of the neighbor node is the second preset value, it is determined that the graph node is on a ring; the ring detection processing based on the graph node, the public initial value, and the local initial value to obtain the detection result comprises: for the graph node of the private node category, in a case where the third detection value is the first preset value and the third stack value is the first preset value, the third detection value and the third stack value are both set to the second preset value, and ring detection is performed on a neighbor node of the graph node; in a case where a return result of the neighbor node is the second preset value, it is determined that the graph node is on a ring; Wherein, the first preset value is no, and the second preset value is yes.
2. The method of claim 1, wherein, The step of preprocessing data for each graph node to obtain the node identifier corresponding to each graph node includes: Each graph node is initialized to obtain the initial identifier corresponding to each graph node; Each of the initial identifiers is de-identified to obtain the node identifier.
3. The method of claim 1, wherein, After performing ring detection on the neighbor nodes of the graph node, the method further includes: If the neighbor node returns a third preset value, it is determined that the graph node is not on the ring.
4. A directed graph loop detection apparatus, characterized by, include: The graph acquisition module is used to acquire a directed graph to be detected, wherein the directed graph to be detected includes multiple graph nodes; The preprocessing module is used to preprocess the data of each graph node to obtain the node identifier corresponding to each graph node; An interaction module is used to send the node identifiers corresponding to each of the graph nodes to a preset server and receive the categories corresponding to each of the graph nodes returned by the server. The first processing module is used to initialize the graph nodes of the category of public nodes using a multi-party key sharing algorithm to obtain common initial values. The second processing module is used to initialize the graph nodes of the category of private nodes using preset rules to obtain local initial values. The detection module is used to perform ring detection processing based on the graph nodes, the common initial values, and the local initial values to obtain the detection results; Each of the graph nodes is provided with a detection label and a stack label. The detection label indicates whether the graph node has been detected, and the stack label indicates whether the graph node is in the stack. For the graph nodes classified as public nodes, a multi-party key sharing algorithm is used to initialize the graph nodes and obtain common initial values, including: The multi-party key sharing algorithm is used to assign values to the detection tag and the stack tag respectively, so as to obtain the first detection value corresponding to the detection tag and the first stack value corresponding to the stack tag; The first detection value and the first stack value constitute the common initial value; For the graph nodes of the category of private nodes, the graph nodes are initialized using preset rules to obtain local initial values, including: The detection label and the stack label are assigned values according to the preset rules to obtain the third detection value corresponding to the detection label and the third stack value corresponding to the stack label. The third detection value and the third stack value constitute the local initial value; The ring detection process based on the graph nodes, the common initial value, and the local initial value yields the detection result, including: For the graph node of the category of public node, the first detection value and the first stack value are processed by the multi-party key sharing algorithm to obtain the second detection value corresponding to the detection label and the second stack value corresponding to the stack label. In a case where the second detection value is a first preset value and the second stack value is the first preset value, the second detection value and the second stack value are both set as a second preset value, and a neighbor node of the graph node is subjected to loop detection; In a case where a return result of the neighbor node is the second preset value, it is determined that the graph node is on a loop; The loop detection processing based on the graph node, the common initial value and the local initial value obtains a detection result, including: In a case where the third detection value is a first preset value and the third stack value is the first preset value, the third detection value and the third stack value are both set as a second preset value, and a neighbor node of the graph node is subjected to loop detection; In a case where a return result of the neighbor node is the second preset value, it is determined that the graph node is on a loop; The first preset value is no, and the second preset value is yes.
5. A computer device, comprising: The computer device includes a memory and a processor, the memory stores computer readable instructions, and the computer readable instructions are executed by one or more processors to make one or more processors execute the steps of the method in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The storage medium can be read and written by the processor, and the storage medium stores computer readable instructions, and the computer readable instructions are executed by one or more processors to make one or more processors execute the steps of the method in any one of claims 1 to 3.
Citation Information
Patent Citations
Multi-party loop detection method and device based on knowledge federation and related equipment
CN113468382A
Power grid real-time graph parallel computing method
CN113672775A