Directed graph loop detection method, device, system, equipment and medium

Through the stack structure and linked list structure, the node pointing relationship of the directed graph is traversed, and the linked list data is stored to detect loops, which solves the problem of narrow applicability and complexity of loop detection in directed graphs in the existing technology, and realizes the design stage Loop detection and infinite loop avoidance.

CN113204678BActive Publication Date: 2024-10-29INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110587862.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-27
Publication Date
2024-10-29
Estimated Expiration
2041-05-27

AI Technical Summary

Technical Problem

The existing directed graph loop detection technology has a narrow scope of application and cannot detect loops in advance during the network design stage. Moreover, it is difficult to determine the existence of loops under complex graph structures, causing the execution process to fall into an infinite loop.

Method used

Using the method of combining the stack structure and the linked list structure, by traversing the node pointing relationship of the directed graph, storing the linked list data to the loop storage set, determining the loop data, and realizing the detection of all loops in the directed graph.

Benefits of technology

It realizes the detection of all loops in the directed graph design stage. It is applicable to a wide range of scenarios and does not rely on specific equipment and scenarios. It can accurately detect loops within a limited time and avoid infinite loops.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113204678B_ABST
    Figure CN113204678B_ABST
Patent Text Reader

Abstract

The present disclosure provides a loop detection method for a directed graph, which can be applied to the fields of information security and big data technology, including: traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure; storing the linked list data in the linked list structure obtained during the traversal process in a loop storage set; and determining that the linked list data in the loop storage set is loop data. Therefore, compared with the existing loop detection technology, it does not rely on actual scenarios and deployment equipment, has a wider range of applicable scenarios, and can directly detect all loops existing in the directed graph within a limited time. In addition, the present disclosure also provides a loop detection device for a directed graph, a loop detection system for a directed graph, an electronic device, and a computer-readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a directed graph loop detection method, device, system, equipment and medium. Background Art

[0002] Graphs are widely used in many fields, such as the decision flow in the field of financial risk control. By customizing a series of decision nodes and organizing them together using directed graphs, an effective decision link is finally formed. Another example is that in some complex task scenarios, complex tasks can be decomposed into simple tasks with smaller granularity, and these simple tasks are constructed into a directed graph, making the original complex task execution process more specific and clear. In short, directed graphs can be used to describe almost all application scenarios with process characteristics, and are a very good solution for expressing process scenarios.

[0003] Among them, the biggest feature of the process is that it has a beginning and an end, that is, no matter what the next step is, it will eventually reach the end node. In many application scenarios, loops are not allowed to exist in the graph, because a directed graph with loops may fall into an infinite loop during the actual execution process, and will never reach the end node. Therefore, loop detection technology has become an important topic in the field of directed graph research. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In order to solve at least one of the technical problems existing in the loop detection technology in the prior art, the present disclosure provides a loop detection method, apparatus, system, device and medium for a directed graph.

[0006] (II) Technical solution

[0007] One aspect of the present disclosure provides a method for loop detection in a directed graph, which includes: traversing the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure; storing the linked list data in the linked list structure obtained during the traversal process into a loop storage set; and determining that the linked list data in the loop storage set is loop data.

[0008] According to an embodiment of the present disclosure, before traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method also includes: defining the storage structure of the directed graph based on the key-value data structure rule, and realizing the storage of the directed graph in the data form of key-value pairs.

[0009] According to an embodiment of the present disclosure, before traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method also includes: initializing the stack structure, the linked list structure and the loop storage set so that the data in the stack structure, the linked list structure and the loop storage set are all empty; and in response to the end of the initialization process, inserting the starting binary data corresponding to the starting node in the directed graph into the stack structure.

[0010] According to an embodiment of the present disclosure, traversing the pointed-to nodes of the current node in a directed graph according to the data relationship in the stack structure and the linked list structure includes: when the data in the stack structure is not empty, performing a pop operation on the stack structure to obtain the top data corresponding to the current node; deleting all linked list data in the linked list structure whose index position is greater than or equal to the traversal level depth in the top data; and inserting the current node into the end of the linked list structure after performing the delete operation.

[0011] According to an embodiment of the present disclosure, in traversing the pointing nodes of the current node in a directed graph according to the data relationship in the stack structure and the linked list structure, it also includes: when there is no duplicate node data in the linked list structure at the end of which the current node is inserted, removing the top data in the stack structure; querying the pointing node corresponding to the current node according to the node pointing rule of the directed graph; and when the pointing node corresponding to the current node is not empty, inserting the pointing binary data corresponding to the pointing node into the stack structure with the top data removed.

[0012] According to an embodiment of the present disclosure, the linked list data in the linked list structure obtained during the traversal process is stored in a loop storage collection, including: when there is duplicate node data in the linked list structure at the end of which the current node is inserted, the linked list data in the linked list structure obtained during the traversal process is stored in the loop storage collection.

[0013] According to an embodiment of the present disclosure, storing the linked list data in the linked list structure obtained during the traversal process in the loop storage set also includes: deleting the last inserted node in the linked list structure; and removing the top data in the stack structure to further determine whether the data in the stack structure is empty.

[0014] According to an embodiment of the present disclosure, determining that the linked list data in the loop storage set is loop data includes: when the data in the stack structure is empty, determining the loop data in the loop storage set.

[0015] Another aspect of the present disclosure provides a loop detection device for a directed graph, which includes a node traversal module, a data storage module and a loop data determination module. The node traversal module is used to traverse the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure; the data storage module is used to store the linked list data in the linked list structure obtained during the traversal process into the loop storage set; and the loop data determination module is used to determine that the linked list data in the loop storage set is loop data.

[0016] Another aspect of the present disclosure provides a directed graph loop detection system, which includes: a database and the above-mentioned device. The database is used to store and update the structure data of the directed graph; the above-mentioned device is used to read the structure data in the database to implement the above-mentioned method.

[0017] Another aspect of the present disclosure provides an electronic device, including one or more processors and a memory; the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method of the embodiment of the present disclosure.

[0018] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method of the embodiment of the present disclosure when executed.

[0019] Another aspect of the present disclosure provides a computer program, wherein the computer program includes computer executable instructions, and the instructions are used to implement the method of the embodiment of the present disclosure when executed.

[0020] (III) Beneficial effects

[0021] The present disclosure provides a loop detection method for a directed graph, which includes: traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure; storing the linked list data in the linked list structure obtained during the traversal process into a loop storage set; and determining that the linked list data in the loop storage set is loop data. Therefore, compared with the existing loop detection technology, it does not rely on actual scenarios and deployment equipment, has a wider range of applicable scenarios, and can directly detect all loops existing in the directed graph within a limited time. In addition, the present disclosure also provides a loop detection device for a directed graph, a loop detection system for a directed graph, an electronic device, and a computer-readable storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] For a more complete understanding of the present disclosure and its advantages, reference will now be made to the following description taken in conjunction with the accompanying drawings, in which:

[0023] Figure 1An exemplary system architecture to which a loop detection method of a directed graph can be applied according to an embodiment of the present disclosure is schematically shown;

[0024] Figure 2 A flow chart of a directed graph loop detection method according to an embodiment of the present disclosure is schematically shown;

[0025] Figure 3 Another flow chart of a directed graph loop detection method according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 4 A flowchart schematically shows an application example of the method for detecting a loop in a directed graph according to an embodiment of the present disclosure;

[0027] Figure 5 A composition diagram of a directed graph according to a directed graph loop detection method of an embodiment of the present disclosure is schematically shown;

[0028] Figure 6 Another flow chart of a directed graph loop detection method according to an embodiment of the present disclosure is schematically shown;

[0029] Figure 7 Another flow chart of a directed graph loop detection method according to an embodiment of the present disclosure is schematically shown;

[0030] Figure 8 Another flow chart of a directed graph loop detection method according to an embodiment of the present disclosure is schematically shown;

[0031] Fig. 9 A diagram schematically showing another directed graph composition of a directed graph loop detection method according to an embodiment of the present disclosure;

[0032] Fig.10 The exemplary architecture of a loop detection device for a directed graph according to an embodiment of the present disclosure is schematically shown;

[0033] Fig.11 An exemplary architecture of a directed graph loop detection system according to an embodiment of the present disclosure is schematically shown;

[0034] Fig.12 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0035] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0036] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "include", "comprising", etc. used herein indicate the existence of the above-mentioned features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0037] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0038] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0039] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some boxes or combinations thereof in the block diagrams and / or flow charts 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, or other programmable data processing device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable storage medium storing instructions, which can be used by an instruction execution system or used in conjunction with an instruction execution system.

[0040] Existing loop detection technologies are mostly used in the field of computer networks. Each node in the diagram corresponds to a device in the network. Communication between devices and transmission of loop detection messages are used to identify whether there is a loop in the computer network. This loop detection technology has a narrow application range and can only be applied in the field of network communications. During measurement, all networks must be unobstructed and fault-free. The biggest problem is that this detection method cannot detect whether there is a loop in the network in advance during the network design stage. It must wait until the device is deployed in the actual network to detect it.

[0041] As mentioned above, directed graph loop detection technology has a wide range of applications. However, in many practical application scenarios, loops are not allowed in directed graphs. The presence of loops will cause the execution process to fall into an infinite loop. Simple directed graphs can be observed to detect the presence of loops, but when the number of nodes in a directed graph increases and the structure becomes more complex, it is impossible to judge by observation.

[0042] In order to solve at least one of the technical problems existing in the directed graph loop detection technology in the prior art, and to provide an effective new loop detection scheme, so that compared with the existing loop detection technology, the detection scheme can perform loop detection on directed graphs in all scenarios, is independent of the actual scenario and deployment equipment, has a wider range of applications, and can detect all loops existing in the design diagram at the initial directed graph design stage. The present disclosure provides a directed graph loop detection method, a directed graph loop detection device, a directed graph loop detection system, an electronic device and a readable storage medium.

[0043] It should be noted that the directed graph loop detection method and device of the embodiments of the present disclosure can be applied to the fields of information security technology and the Internet of Things technology, and can also be applied to any field other than the fields of information security technology and the Internet of Things technology, such as the financial services field. The application field of the directed graph loop detection method and device of the embodiments of the present disclosure is not specifically limited.

[0044] Figure 1 An exemplary system architecture to which a loop detection method of a directed graph can be applied according to an embodiment of the present disclosure is schematically shown.

[0045] It should be noted that Figure 1 What is shown is merely an application example to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the loop detection method of the directed graph of the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0046] like Figure 1As shown, the system architecture 100 according to this embodiment may include a data request system 110, and a server system 120 that establishes data communication with the data request system 110, wherein the server system includes servers M, 121, 122, 123, 124, and 125 that establish data transmission channels with the data request system 110, wherein server M is a primary access server that can obtain instruction information from users. Servers 121, 122, 123, 124, and 125 are secondary access servers, and the data request system 110 and servers M, 121, 122, 123, 124, and 125 can be implemented based on an internal cloud network server C. Alternatively, when the primary server M among the servers M, 121, 122, 123, 124, and 125 is a network server, that is, relative to the intranet of other terminal devices 111, 112, 113, 114, and 115, the primary server M of the server system 120 can be located in an external network. At this time, the cloud network server C is used as a medium for providing communication links between other terminal devices 111, 112, 113, 114 and 115. The data transmission channel between the server system 120 and multiple terminal devices can be implemented through various communication connection types, such as wired, wireless communication links or optical fiber cables.

[0047] It should be noted that, according to the embodiment of the present disclosure, the servers 121, 122, 123, 124 and 125 can be interconnected without encryption.

[0048] The user can use the terminal devices 111, 112, 113, 114 and 115 to interact with the server system 120 to receive or send messages for data transmission or processing, specifically involving access to the database in the main server M in the server system. For example, the terminal device 111 sends business data to the terminal device 112. After receiving the data request from the terminal device 111, the server system 120 will forward the corresponding business data and encrypt the business data under specific needs, so that the business data that finally reaches the terminal device 112 is secure. Various communication client applications can be installed on the terminal devices 111, 112, 113, 114 and 115, such as management applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0049] The terminal devices 111 , 112 , 113 , 114 and 115 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and various application servers.

[0050] The server system 120 may include various types of firewalls that provide various services, such as a filtering firewall (only an example) that provides support for websites browsed by users using terminal devices 111, 112, 113, 114, and 115. The filtering firewall may analyze and process received data such as user requests, and analyze based on the address of the data source and the flag features such as the protocol type to determine whether the request can pass, thereby filtering or blocking unsafe factors.

[0051] It should be noted that the loop detection method for the directed graph provided in the embodiment of the present disclosure can generally be executed by the server system 120. Accordingly, the loop detection device or system for the directed graph provided in the embodiment of the present disclosure can generally be set in the server system 120. The loop detection method for the directed graph provided in the embodiment of the present disclosure can also be executed by other server systems 120 that are different from the server system 120 and can communicate with the terminal devices 111, 112, 113, 114 and 115 and / or the server system 120. Accordingly, the loop detection device or system for the directed graph provided in the embodiment of the present disclosure can also be set in other server systems that are different from the server system 120 and can communicate with the terminal devices 111, 112, 113, 114 and 115 and / or the server system 120.

[0052] It should be understood that Figure 1 The number of terminal devices and servers in the embodiment is only for illustration. Any number of terminal devices and servers may be provided according to implementation requirements.

[0053] The following combination Figure 2-Figure 12 , a directed graph loop detection method, a directed graph loop detection device, a directed graph loop detection system, an electronic device and a computer-readable storage medium provided in one embodiment of the present disclosure are further described in detail.

[0054] Figure 2 The flowchart of the loop detection method of the directed graph according to the embodiment of the present disclosure is schematically shown.

[0055] like Figure 2 As shown, one aspect of the present disclosure provides a method for loop detection in a directed graph, which includes steps S201-S203.

[0056] In step S201, according to the data relationship in the stack structure and the linked list structure, the nodes pointed to by the current node in the directed graph are traversed;

[0057] In step S202, the linked list data in the linked list structure obtained during the traversal process is stored in the loop storage set; and

[0058] In step S203, it is determined that the linked list data in the loop storage set is loop data.

[0059] In the embodiments of the present disclosure, a stack structure is a data structure that can be applied to a storage system or a data processing system. Generally, a stack structure processes node data in a last-in-first-out manner. The stack structure can only be operated at the operation end, which is the top of the stack, and the non-operation end at the other end is the bottom of the stack. Therefore, in the stack structure, only the top data can be accessed or read, which is mainly reflected in the push and pop of the top data.

[0060] A linked list structure (list) is another data forwarding structure that can be applied to a storage system or a data processing system. The data stored in the linked list structure can form linked list data with a specific data sequence based on the time and order of its entry into the linked list structure, so that the linked list data in the linked list structure can be processed in sequence when it is called.

[0061] The data relationship between the top data in the stack structure and the linked list data in the linked list structure, such as the presence or absence of the top data and the presence or absence of the linked list data, is used to set the traversal of the nodes pointed to by the current node in the directed graph.

[0062] A directed graph consists of two parts: nodes and directed line segments. A directed line segment is responsible for connecting two adjacent nodes and defining the direction from one node to another. When walking in a directed graph, one can only walk from one node to another in the direction of the directed line segment. When the starting node walks to the node it points to, and finally points from the node it points to to the starting node, these nodes will form a loop. Therefore, by traversing these nodes in order according to the node pointing order, the corresponding traversal data can be determined.

[0063] The above-mentioned traversal data of the nodes are stored in the linked list structure to form linked list data in sequence. When the traversal is completed, the linked list data can be directly stored in the loop storage set. The loop storage set (set) can be used to store multiple linked list data at the same time, and ensure that the stored multiple linked list data are different.

[0064] When each linked list data is stored in the loop storage set, a corresponding loop data is formed. That is, the number of loop data stored in the loop storage set represents the number of loops detected by the detection method of the embodiment of the present disclosure, and each loop data is different, that is, each loop of the directed graph detected during the traversal process can be accurately confirmed, while ensuring that the detection time is limited.

[0065] Therefore, compared with the existing loop detection technology, it does not rely on actual scenarios and deployed equipment, has a wider range of applicable scenarios, and can detect all loops in a directed graph within a limited time.

[0066] Figure 3 Another flow chart of a loop detection method for a directed graph according to an embodiment of the present disclosure is schematically shown.

[0067] like Figure 3 As shown, according to an embodiment of the present disclosure, before traversing the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure in step S201, the method further includes step S301.

[0068] In step S301, based on the key-value data structure rule, the storage structure of the directed graph is defined to store the directed graph in the data form of key-value pairs.

[0069] Figure 4 A flowchart schematically illustrates an application example of a loop detection method for a directed graph according to an embodiment of the present disclosure.

[0070] like Figure 4 As shown, in step S401, the storage structure of the directed graph is defined, and the directed graph is stored in the form of key-value pairs to achieve parameterization of the directed graph, and the directed graph is expressed in the form of data, which makes it easy to save the directed graph in a storage medium and facilitate data calls of the directed graph.

[0071] Figure 5 A composition diagram of a directed graph according to a loop detection method of a directed graph according to an embodiment of the present disclosure is schematically shown.

[0072] like Figure 5 The directed graph shown in the figure consists of two parts: nodes 1-5 and directed line segments. The directed line segments are responsible for connecting two adjacent nodes and defining the direction from one node to another. For example, node 1 points to node 3 and node 2, and nodes 1 can only point to nodes 3 and 2 in the direction of the directed line segments.

[0073] The key-value data structure has high availability, high scalability, good fault recovery and operation performance through the correspondence between keywords and values. It can ensure that data is not easily lost and services are not easily terminated. It can also perceive and automatically recover and optimize faults, and has extremely high read and write performance.

[0074] In the embodiment of the present disclosure, a directed graph is saved by means of a key-value data structure, wherein the key represents the number of a node, and the value is a list structure, which stores all other nodes pointed to by the key node, for example Figure 5 The corresponding key-value storage data of the directed graph is as follows:

[0075] {

[0076] "Node 1": ["Node 2", "Node 3"],

[0077] "Node 2": ["Node 5"],

[0078] "node3": ["node4"],

[0079] "node4": ["node5"],

[0080] "Node 5": []

[0081] }

[0082] That is, it contains a total of 5 key-value pairs, such as the key is "node 1", and its corresponding value is "node 2" and "node 3". Therefore, through the above key-value structure data storage technology, the storage medium related to the key-value structure can be used to perform persistent directed graph storage.

[0083] like Figure 3 As shown, according to an embodiment of the present disclosure, before traversing the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure in step S201, the method further includes steps S302-S303.

[0084] In step S302, the stack structure, the linked list structure and the loop storage set are initialized so that the data in the stack structure, the linked list structure and the loop storage set are all empty; and

[0085] In step S303, in response to the end of the initialization process, the starting two-tuple data corresponding to the starting node in the directed graph is inserted into the stack structure.

[0086] like Figure 4 As shown, in step S402, an empty stack stack = [], an empty linked list list = [], and an empty loop storage set set = {} are initialized, wherein the data states in the stack stack, the linked list list, and the loop storage set set are all empty.

[0087] Further, in step S403, starting from the starting node node of the directed graph S (like Figure 5 Starting from the starting node 1), the starting node node S The corresponding starting tuple data (node S , 1) is inserted into the stack. The starting node is the node that is not pointed to by any other node. In addition, (node S, 1) in which 1 represents the hierarchical depth of the traversed graph nodes. The hierarchical depth of the starting node is 1, and the hierarchical depth of the subsequent nodes increases gradually as the traversal hierarchical depth increases.

[0088] Figure 6 Another flow chart of a loop detection method for a directed graph according to an embodiment of the present disclosure is schematically shown.

[0089] like Figure 6 As shown, according to an embodiment of the present disclosure, in step S201, the nodes pointed to by the current node in the directed graph are traversed according to the data relationship in the stack structure and the linked list structure, including steps S601-S603.

[0090] In step S601, when the data in the stack structure is not empty, a pop operation is performed on the stack structure to obtain the top data of the stack corresponding to the current node;

[0091] In step S602, all linked list data whose index position in the linked list structure is greater than or equal to the traversal level depth in the stack top data are deleted; and

[0092] In step S603, the current node is inserted into the end of the linked list structure after the deletion operation is performed.

[0093] like Figure 4 As shown, in step S404, it is determined whether the stack is empty, and if not empty, step S405 is executed.

[0094] like Figure 4 As shown, in step S405, stack performs a pop operation to obtain the top element of the stack, that is, the top data of the stack (node t , c), where c is the traversal level depth of the current node. At the same time, delete all data in the list with an index position greater than or equal to c, and replace node t Insert to the end of the list. It should be noted that the index position in the list starts from 1 and increases.

[0095] Figure 7 Another flow chart of a loop detection method for a directed graph according to an embodiment of the present disclosure is schematically shown.

[0096] like Figure 7 As shown, according to an embodiment of the present disclosure, in step S201, according to the data relationship in the stack structure and the linked list structure, the nodes pointed to by the current node in the directed graph are traversed, and steps S701-S703 are also included.

[0097] In step S701, when there is no duplicate node data in the linked list structure at the end of which the current node is inserted, the top data in the stack structure is removed;

[0098] In step S702, according to the node pointing rule of the directed graph, the node pointed to by the current node is searched; and

[0099] In step S703, when the pointing node corresponding to the current node is not empty, the pointing tuple data corresponding to the pointing node is inserted into the stack structure from which the top data of the stack is removed.

[0100] like Figure 4 As shown, in step S406, it is determined whether there is duplicate data in the list, wherein the so-called duplicate data refers to the node name data that is repeated in the list. If there is no duplicate data in the list linked list, the top data of the stack is removed and step S408 is executed.

[0101] In step S408, key=node is searched from the storage medium of the key-value data structure. t The corresponding value executes step S409. The node pointing rule is the correspondence between the current node and the node it points to defined according to the current node pointing in the directed graph. Among them, when the key keyword defined in the Key-value data structure is the current node, the value value corresponds to the node pointed to by the current node, that is, the key-value pair defined in the Key-value data structure parameterizes the node pointing rule of the directed graph.

[0102] In step S409, it is determined whether the value of value is empty. If value is empty, the process returns to step S404 and if value is not empty, the process continues to step S410.

[0103] In step S410, value is not empty, that is, there are data nodes. Assume that value is [node1, node2, ..., node n ], then insert all the tuple data (node1, c+1), (node2, c+1), ..., (noden, c+1) corresponding to these node nodes into the stack, and continue to execute step S404.

[0104] Figure 8 Another flow chart of a loop detection method for a directed graph according to an embodiment of the present disclosure is schematically shown.

[0105] like Figure 8 As shown, according to an embodiment of the present disclosure, in step S202, the linked list data in the linked list structure obtained during the traversal process is stored in the loop storage set, including step S801.

[0106] In step S801, when there are duplicate node data in the linked list structure at the end of which the current node is inserted, the linked list data obtained during the traversal process in the linked list structure are stored in the loop storage set.

[0107] like Figure 4 As shown, in step S406, when it is determined that there is duplicate data in the list, it indicates that there is a loop in the directed graph, and then step S407 is continued.

[0108] In step S407, the linked list data stored in list at this time is put into the loop storage set set.

[0109] like Figure 8 As shown, according to an embodiment of the present disclosure, in step S202, the linked list data in the linked list structure obtained during the traversal process is stored in the loop storage set, and steps S802-S803 are also included.

[0110] In step S802, the last inserted node in the linked list structure is deleted; and

[0111] In step S803, the top data in the stack structure is removed to further determine whether the data in the stack structure is empty.

[0112] Referring to step S406 above, if there is duplicate data in the list, it means that there is a loop in the directed graph, and it is necessary to continue to delete the last inserted node in the list. t Data node.

[0113] In addition, it is necessary to further remove the top data of the stack and execute step S404 again.

[0114] According to an embodiment of the present disclosure, determining in step S203 that the linked list data in the loop storage set is loop data includes: when the data in the stack structure is empty, determining the loop data in the loop storage set.

[0115] like Figure 4 As shown, in step S404, when it is determined that the stack is empty, step S411 is executed.

[0116] In step S411, all nodes of the directed graph have been traversed. At this time, the linked list data stored in the set collection is all the loop data existing in the traversed directed graph. The number of loop data represents the number of loops.

[0117] In order to enable those skilled in the art to further understand the directed graph loop detection method of the embodiment of the present disclosure, another specific implementation case is given to explain the directed graph loop detection method in detail as follows:

[0118] Fig. 9 A composition diagram of another directed graph according to the loop detection method of a directed graph according to an embodiment of the present disclosure is schematically shown.

[0119] like Fig. 9 The directed graph shown in the figure consists of two parts: nodes 1-5 and directed line segments. The directed line segments are responsible for connecting two adjacent nodes and defining the direction from one node to another. For example, we can only follow the direction of the directed line segments from node 1 to node 3 and node 2, from node 2 to node 5, from node 5 to node 4, from node 4 to node 3, and from node 3 to node 5, forming a sequence of nodes. Fig. 9 The nodes of the directed graph shown are regular.

[0120] Therefore, according to the key-value data structure, the above directed graph can be converted into a key-value storage structure as shown below:

[0121] {

[0122] "1": ["2", "3"],

[0123] "2": ["5"],

[0124] "3": ["5"],

[0125] "4": ["3"],

[0126] "5": ["4"]

[0127] }

[0128] Based on the above Fig. 9 The parameterized storage form of the key-value data structure of the directed graph shown in Figure 4 Step S401), according to the loop detection method of the directed graph of the embodiment of the present disclosure, Fig. 9 All loops in the directed graph shown are detected as follows:

[0129] Step s1: Starting from the initial node 1, put (1, 1) into the stack. At this time, stack = [(1, 1)], list = []. Among them, step s1 actually corresponds to Figure 4 In step S403, the initialization process in the above step S402 is not described in detail.

[0130] Step s2: stack performs a pop operation to obtain the top data (1, 1), and inserts node 1 into list. At this time, stack = door, list = [1].

[0131] Step s3: Check if the list contains duplicate data. Here, it does not contain duplicate data. Get all the next nodes of node 1 from the key-value storage structure, which are node 2 and node 3. Insert (2, 2) and (3, 2) into the stack. Now stack = [(2, 2), (3, 2)], list = [1].

[0132] Step s4: stack performs a pop operation, obtains the top data (3, 2), and inserts node 3 into list. At this time, stack = [(2, 2)], list = [1, 3].

[0133] Step s5: Check if the list contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 3 from the key-value storage structure, which is 5 here, and insert (5, 3) into the stack. Now stack = [(2, 2), (5, 3)], list = [1, 3].

[0134] Step s6: stack performs a pop operation to obtain the top data (5, 3) and inserts node 5 into list. At this time, stack = [(2, 2)], list = [1, 3, 5].

[0135] Step s7: Check if the list contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 5 from the key-value storage structure, which is 4 here. Insert (4, 4) into the stack. Now stack = [(2, 2), (4, 4)], list = [1, 3, 5].

[0136] Step s8: stack performs a pop operation to obtain the top data (4, 4), and inserts node 4 into list. At this time, stack = [(2, 2)], list = [1, 3, 5, 4].

[0137] Step s9: Check if the list contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 4 from the key-value storage structure, which is 3 here. Insert (3, 5) into the stack. Now stack = [(2, 2), (3, 5)], list = [1, 3, 5, 4].

[0138] Step s10-stack performs a pop operation, obtains the top data (3, 5), and inserts node 3 into list. At this time, stack = [(2, 2)], list = [1, 3, 5, 4, 3].

[0139] Step s11: Check whether the list contains duplicate data. If it does, put the contents of the list into set and delete the last data in the list. At this time, set = {[1, 3, 5, 4, 3]}, list = [1, 3, 5, 4], stack = [(2, 2)].

[0140] Among them, the above steps s2 and s3, s4 and s5, s6 and s7, s8 and s9 correspond to the above Figure 4 The loop operation in the node traversal process of steps S405-S406-S407-S408-S409-S410-S404-S405 shown in FIG. 1 , wherein steps s2, s4, s6, s8 and s10 correspond to the above Figure 4 Step S405, steps s3, s5, s7, and s9 correspond to the above Figure 4 The operations of steps S406-S407-S408-S409-S410 are shown, and step s11 corresponds to steps S406-S407, which means that a loop in the directed graph has been detected, and the loop storage set is obtained as set = {[1, 3, 5, 4, 3]}, that is, the loop data is [1, 3, 5, 4, 3], which means that the first loop detected in the directed graph is 1->3->5->4->3.

[0141] Step s12: stack performs a pop operation to obtain the top data (2,2). Here, the data with an index greater than or equal to 2 must be deleted from the list first, and then node 2 is inserted into the list. At this time, stack = [], list = [1, 2].

[0142] Step s13: Check if the list contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 2 from the key-value storage structure, which is 5 here. Insert (5,3) into the stack. Now stack = [(5,3)], list = [1,2].

[0143] Step s14: stack performs a pop operation, obtains the top data (5,3), and inserts node 5 into list. At this time, stack = [], list = [1, 2, 5].

[0144] Step s15: Check if listF contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 5 from the key-value storage structure, which is 4 here. Insert (4,4) into stack. Now stack = [(4,4)], list = [1,2,5].

[0145] Step s16: stack performs a pop operation, obtains the top data (4, 4), and inserts node 4 into list. At this time, stack = [], list = [1, 2, 5, 4].

[0146] Step s17: Check if the list contains duplicate data, which is not the case here. Get all the next nodes of node 4 from the key-value storage structure, which is 3 here, and insert (3, 5) into the stack. At this time, stack = [(3, 5)], list = [1, 2, 5, 4].

[0147] Step s18: stack performs a pop operation, obtains the top data (3, 5), and inserts node 3 into list. At this time, stack = [], list = [1, 2, 5, 4, 3].

[0148] Step s19: Check if the list contains duplicate data. It does not contain duplicate data here. Get all the next nodes of node 3 from the key-value storage structure, which is 5 here. Insert (5,6) into the stack. Now stack = [(5,6)], list = [1, 2, 5, 4, 3].

[0149] Step s20: stack performs a pop operation, obtains the top data (5, 6), and inserts node 5 into list. At this time, stack = [], list = [1, 2, 5, 4, 3, 5].

[0150] Step s21: Check if the list contains duplicate data. If so, it does. Put the contents of the list into a set, delete the last data in the list, and remove the top data of the stack. At this time, set = {[1, 3, 5, 4, 3], [1, 2, 5, 4, 3, 5]}, list = [1, 2, 5, 4, 3], and stack = [].

[0151] Similarly, the above steps s12 and s13, s14 and s15, s16 and s17, s18 and s19 correspond to the above Figure 4 The loop operation in the node traversal process of steps S405-S406-S407-S408-S409-S410-S404-S405 shown in FIG. 1 , wherein steps s12, s14, s16, s18 and s20 correspond to the above Figure 4 Step S405, steps s13, s15, s17, and s19 correspond to the above Figure 4The operations of steps S406-S407-S408-S409-S410 are shown, and step s21 corresponds to steps S406-S407, which means that another loop in the directed graph has been detected, and the acquired loop storage set is set = {[1, 3, 5, 4, 3], [1, 2, 5, 4, 3, 5]}, that is, the loop data detected at this time are [1, 3, 5, 4, 3] and [1, 2, 5, 4, 3, 5], relative to the above-mentioned first loop data of [1, 3, 5, 4, 3], that is, the second loop detected by the directed graph is 1->2->5->4->3->5.

[0152] Step s22: Since the stack is empty at this time, refer to the above Figure 4 Steps S404-S411 are shown, ending the entire traversal process.

[0153] Finally, based on the execution process of the directed graph loop detection method of steps s1-s22 above, the loop storage set set = {[1, 3, 5, 4, 3], [1, 2, 5, 4, 3, 5]} can be obtained, indicating that Fig. 9 There are two cycles in the directed graph shown, namely 1->3->5->4->3 and 1->2->5->4->3->5.

[0154] Therefore, compared with the loop detection technology in the prior art that can only detect whether there is a loop in the network, or can only detect one or part of the loops, the loop detection method according to the embodiment of the present disclosure can detect all loops in the directed graph within a limited time. Obviously, this has more important practical application significance for accurately eliminating the loop structure in the directed graph. In addition, the loop detection method can be applied to directed graph detection in any application or scenario that can be abstracted as a directed graph, and has greater universality than the loop detection method proposed in the prior art for specific applications or environments.

[0155] Fig.10 The exemplary architecture of a loop detection device for a directed graph according to an embodiment of the present disclosure is schematically shown;

[0156] Another aspect of the present disclosure provides a loop detection device 1000 for a directed graph, which includes a node traversal module 1010, a data storage module 1020, and a loop data determination module 1030. The node traversal module 1010 is used to traverse the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure; the data storage module 1020 is used to store the linked list data in the linked list structure obtained during the traversal process into the loop storage set; and the loop data determination module 1030 is used to determine that the linked list data in the loop storage set is loop data.

[0157] The node traversal module 1010, the data storage module 1020 and the loop data determination module 1030 can be used to implement the following respectively: Figure 2 The methods of the process steps S201, S202 and S203 shown, that is, the implementation method of the loop detection device part of the directed graph mentioned above is similar to the implementation method of the loop detection method part of the directed graph, and the technical effects achieved are also similar, which will not be repeated here.

[0158] It should be noted that Fig.10 The system architecture 1000 shown is merely an example to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0159] Fig.11 An exemplary architecture of a directed graph loop detection system according to an embodiment of the present disclosure is schematically shown.

[0160] like Fig.11 As shown, another aspect of the present disclosure provides a directed graph loop detection system 1100, which includes: a database 1110 and the directed graph loop detection device 1120. The database 1110 is used to store and update the structure data of the directed graph; the directed graph loop detection device 1120 is used to read the structure data in the database to implement the above method.

[0161] The above-mentioned directed graph loop detection device 1120 can be used to implement the following Figure 2 The method of the process steps S201, S202 and S203 shown, that is, the implementation method of the loop detection device 1120 of the directed graph mentioned above is similar to the implementation method of the loop detection method of the directed graph, and the technical effects achieved are also similar, which will not be repeated here.

[0162] It should be noted that Fig.11 The system architecture 1100 shown is merely an example to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0163] like Fig.11 As shown, based on the detection method for all loops existing in a directed graph disclosed in the above embodiments of the present disclosure, the present disclosure further proposes a loop detection system 1100 for a directed graph, which mainly includes: a database 1110 and a loop detection device 1120.

[0164] The database 1110 is responsible for storing and maintaining the structural data of the directed graph, such as the structural data of the directed graph embodied by the key-value storage data mentioned above. In addition, the database 1110 is also used to save and maintain a set of data, which can be used to store all the starting nodes of the directed graph (the starting node refers to the node that is not pointed to by any other node). Among them, when the network structure of the directed graph changes, the database 1110 can realize adaptive data update of the stored data structure. The loop detection device 1120 specifically refers to the above-mentioned device 1000, which is mainly responsible for reading the latest structural data of the directed graph from the database 1110, and implementing the loop detection method of the directed graph mentioned above to obtain all loops existing in the detected directed graph.

[0165] Therefore, no matter how the directed graph changes, as long as it can be abstracted into an application or scenario of a directed graph, it is applicable to the directed graph loop detection method proposed in the above embodiments of the present disclosure, which has greater universality than the loop detection method proposed in the prior art for specific applications or environments.

[0166] Fig.12 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown.

[0167] Another aspect of the present disclosure provides an electronic device, including one or more processors and a memory; the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method of the embodiment of the present disclosure.

[0168] Fig.12 A block diagram of an electronic device according to an embodiment of the present disclosure is schematically shown. Fig.12 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0169] like Fig.12 As shown, the computer system 1200 according to an embodiment of the present disclosure includes a processor 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. The processor 1201 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1201 may also include an onboard memory for caching purposes. The processor 1201 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0170] In RAM 1203, various programs and data required for the operation of system 1200 are stored. Processor 1201, ROM 1202 and RAM 1203 are connected to each other through bus 1204. Processor 1201 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1202 and / or RAM 1203. It should be noted that the program can also be stored in one or more memories other than ROM 1202 and RAM 1203. Processor 1201 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0171] According to an embodiment of the present disclosure, the system 1200 may further include an input / output (I / O) interface 1205, which is also connected to the bus 1204. The system 1200 may further include one or more of the following components connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1208 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0172] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the processor 1201, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0173] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0174] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1202 and / or RAM 1203 described above and / or one or more memories other than ROM 1202 and RAM 1203.

[0175] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0176] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method of the embodiment of the present disclosure when executed.

[0177] Specifically, the computer-readable storage medium may be included in the device / apparatus / system described in the above embodiment; or it may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the loop detection method of the directed graph according to the embodiment of the present disclosure is implemented.

[0178] Alternatively, the computer-readable storage medium may be included in the device / apparatus / system described in the above embodiment; or it may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0179] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions. When the instructions are executed, they are used to implement the loop detection method for the directed graph of the embodiment of the present disclosure.

[0180] So far, the embodiments of the present disclosure have been described in detail with reference to the accompanying drawings.

[0181] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0182] It will be appreciated by those skilled in the art that, although the present disclosure has been shown and described with reference to specific exemplary embodiments of the present disclosure, it will be appreciated by those skilled in the art that, without departing from the spirit and scope of the present disclosure as defined by the appended claims and their equivalents, various changes in form and detail may be made to the present disclosure. Therefore, the scope of the present disclosure should not be limited to the above-described embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.

[0183] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A loop detection method for a directed graph, wherein: include: According to the data relationship in the stack structure and the linked list structure, traverse the nodes pointed to by the current node in the directed graph, Before traversing the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method includes: Based on the key-value data structure rule, a storage structure is defined for the directed graph, so as to store the directed graph in the data form of key-value pairs; Initializing the stack structure, the linked list structure, and the loop storage set so that the data in the stack structure, the linked list structure, and the loop storage set are all empty; and In response to the completion of the initialization process, inserting the starting tuple data corresponding to the starting node in the directed graph into the stack structure, Wherein, in traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method includes: When the data in the stack structure is not empty, performing a pop operation on the stack structure to obtain the top data of the stack corresponding to the current node; Delete all linked list data in the linked list structure whose index position is greater than or equal to the traversal level depth in the stack top data; Inserting the current node to the end of the linked list structure after performing the deletion operation; When there is no duplicate node data in the linked list structure at the end of which the current node is inserted, removing the top data in the stack structure; According to the node pointing rule of the directed graph, query the node pointed to by the current node; and When the pointing node corresponding to the current node is not empty, inserting the pointing tuple data corresponding to the pointing node into the stack structure from which the top data of the stack is removed; The linked list data in the linked list structure obtained during the traversal is stored in the loop storage set, Wherein, storing the linked list data in the linked list structure obtained in the traversal process into the loop storage set includes: When there is duplicate node data in the linked list structure at the end of which the current node is inserted, storing the linked list data obtained in the traversal process in the linked list structure into the loop storage set; and Determine that the linked list data in the loop storage set is loop data.

2. The method according to claim 1, characterized in that The step of storing the linked list data in the linked list structure obtained during the traversal into the loop storage set further includes: Deleting the last inserted node in the linked list structure; and The top data in the stack structure is removed to further determine whether the data in the stack structure is empty.

3. The method according to claim 2, characterized in that In the step of determining that the linked list data in the loop storage set is loop data, the following steps are included: When the data in the stack structure is empty, the loop data in the loop storage set is determined.

4. A loop detection device for a directed graph, wherein: include: A node traversal module is used to traverse the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure. Before traversing the nodes pointed to by the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method includes: Based on the key-value data structure rule, a storage structure is defined for the directed graph, so as to store the directed graph in the data form of key-value pairs; Initializing the stack structure, the linked list structure, and the loop storage set so that the data in the stack structure, the linked list structure, and the loop storage set are all empty; and In response to the completion of the initialization process, inserting the starting tuple data corresponding to the starting node in the directed graph into the stack structure, Wherein, in traversing the pointed nodes of the current node in the directed graph according to the data relationship in the stack structure and the linked list structure, the method includes: When the data in the stack structure is not empty, performing a pop operation on the stack structure to obtain the top data of the stack corresponding to the current node; Delete all linked list data in the linked list structure whose index position is greater than or equal to the traversal level depth in the stack top data; Inserting the current node to the end of the linked list structure after performing the deletion operation; When there is no duplicate node data in the linked list structure at the end of which the current node is inserted, removing the top data in the stack structure; According to the node pointing rule of the directed graph, query the node pointed to by the current node; and When the pointing node corresponding to the current node is not empty, inserting the pointing tuple data corresponding to the pointing node into the stack structure from which the top data of the stack is removed; A data storage module is used to store the linked list data in the linked list structure obtained during the traversal process into the loop storage set. Wherein, storing the linked list data in the linked list structure obtained in the traversal process into the loop storage set includes: When there is duplicate node data in the linked list structure at the end of which the current node is inserted, storing the linked list data obtained in the traversal process in the linked list structure into the loop storage set; and The loop data determination module is used to determine that the linked list data in the loop storage set is loop data.

5. A loop detection system for a directed graph, wherein: include: A database for storing and updating the structure data of the directed graph ; The device of claim 4 is used to read the structural data in the database to implement the method of any one of claims 1-3.

6. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.

7. A computer-readable storage medium storing computer-executable instructions, wherein the instructions are used to implement the method according to any one of claims 1 to 3 when executed.

Citation Information

Patent Citations

  • WS-BPEL control loop detection method based on directed graph

    CN101339501A

  • Circular transaction path detection

    CN103838811A