A process automation workflow verification method based on directed graph cycle detection
Patent Information
- Application Number
- CN202611141659.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]现有技术中对工作流的结构验证方法通常仅检查是否存在起始和结束节点,无法覆盖孤岛节点、连线引用有效性和循环引用等问题
[0008]本发明通过七维度流水线验证机制实现了对工作流结构问题的全面覆盖。遍历着色循环检测算法不仅能判定循环是否存在,还能通过访问中集合精确记录当前正在遍历的路径,从而定位循环的具体位置。错误信息列表与警告信息列表的清晰分离使用户能够优先关注影响工作流可执行性的致命错误。
Smart Images

Figure CN123011632A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer process automation technology, specifically relating to a process automation workflow verification method, system, terminal device, and computer-readable storage medium based on directed graph cycle detection. Background Technology
[0002] Workflow automation is typically built by users through a visual canvas by dragging and dropping nodes and connecting directed edges. During the building process, users may unintentionally introduce various structural problems, such as omitting start or end nodes, creating isolated nodes that are never executed because they are not connected by any edges, forgetting to configure branch exits after conditional decision nodes, or connecting infinite loop structures containing circular loops.
[0003] Existing workflow structure verification methods typically only check for the existence of start and end nodes, failing to cover issues such as isolated nodes, valid connection references, and circular references. While some solutions implement cycle detection, they employ topology sorting-based methods. These methods can only report "cycle exists" when a cycle is detected, without specifying which nodes constitute the circular path, hindering user problem localization and repair.
[0004] Furthermore, existing verification methods typically couple the various inspection dimensions together for execution, resulting in a mix of error messages from different dimensions. This makes it difficult for users to distinguish between fatal errors (such as a missing start node that renders the workflow completely unexecutable) and warning suggestions (such as a condition node having only one exit point, which allows execution but results in incomplete logic). Summary of the Invention
[0005] The technical problem to be solved by this invention is: in the field of process automation, how to perform multi-dimensional automated verification of user-built workflows, comprehensively detect structural problems such as empty workflows, missing nodes, isolated nodes, incorrect connection references, circular references, and insufficient condition node exits, and provide distinguishable error and warning level reports.
[0006] To address the aforementioned technical problems, this invention provides a workflow automation verification method based on directed graph cycle detection. The core idea of this method is to abstract the workflow as a directed graph model, establish a pipeline verification mechanism with seven inspection dimensions, execute the inspection of each dimension in the order of dependencies, and use a traversal coloring cycle detection algorithm to determine and report circular reference paths.
[0007] Specifically, the process begins by extracting all nodes and directed edges from the workflow to be verified, constructing a directed graph model from the node identifier set and the directed edge set. Then, a seven-dimensional verification pipeline is executed sequentially on the directed graph model. The first dimension checks if the total number of nodes is zero; the second dimension checks for the existence of start-type nodes; the third dimension checks for the existence of end-type nodes; the fourth dimension detects isolated nodes by constructing a set of connected nodes through traversing the directed edge set; the fifth dimension checks if both the source and target nodes of each directed edge exist in the node identifier set; the sixth dimension uses a traversal coloring algorithm to detect circular references—this algorithm maintains three node state sets: unvisited, visited, and visited, and performs a depth-first traversal starting from each node. A circular reference is detected when a node's successor is already in the visited state; the seventh dimension checks if the number of outgoing edges for each condition type node meets the multi-escape requirement. Finally, all outputs from the seven dimensions are summarized to generate a verification report containing valid flags, an error message list, and a warning message list.
[0008] This invention achieves comprehensive coverage of workflow structure issues through a seven-dimensional pipeline verification mechanism. The traversal coloring loop detection algorithm not only determines the existence of loops but also accurately records the currently traversed path by accessing the set, thereby pinpointing the exact location of the loop. The clear separation of error message lists and warning message lists allows users to prioritize critical errors affecting workflow executability. Attached Figure Description
[0009] Figure 1 This is the overall flowchart of the workflow verification method for process automation based on directed graph cycle detection in this embodiment of the invention.
[0010] Figure 2 yes Figure 1 If the check for the existence of an end-type node is negative, the process continues with the local detailed flowchart of the subsequent verification dimensions.
[0011] Figure 1 The meanings of the symbols are as follows: 101 - Obtain the workflow to be verified and build a directed graph model; 102 - Check if the total number of nodes is zero; 103 - Check if there are start type nodes; 104 - Check if there are end type nodes; 105 - Build a set of connected nodes and detect isolated nodes; 106 - Check the validity of the source and target node references of each directed edge; 107 - Perform traversal coloring and circular reference detection; 108 - Check the number of outgoing edges for each condition type node; 109 - Summarize all dimensions and output to generate a verification report.
[0012] Figure 2 The meanings of the symbols are as follows: 204 - Check if there are any end-type nodes. 205 - Build a set of connected nodes and detect isolated nodes. 206 - Check the validity of the source and target nodes of each directed edge. 207 - Perform traversal coloring and circular reference detection. 208 - Check the number of outgoing edges for each condition type node. 209 - Summarize all dimensions and generate a verification report. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0014] like Figure 1 As shown in label 101, this invention first obtains the workflow to be verified. The workflow to be verified is organized in the form of a node array and a directed edge array. Each node contains at least two fields: a unique node identifier and a node type. The node type can be a start type, an end type, a condition type, or other executable node types. Each directed edge contains at least three fields: an edge unique identifier, a source node identifier, and a target node identifier. It may also contain an edge type field to distinguish between default edges, conditionally true branch edges, and conditionally false branch edges. The system extracts the node identifiers of all nodes from the node array to form a node identifier set, and extracts all directed edges from the directed edge array to form a directed edge set, thereby forming a complete directed graph model.
[0015] like Figure 1 As shown in Figures 102 to 108, the system performs checks on seven dimensions in a fixed order. The execution order of each dimension depends on dependencies: for example, circular reference detection depends on the validity of directed edge references being verified (otherwise, accessing non-existent nodes may cause algorithm errors), and conditional node multi-exit checks depend on the complete extraction of node type information. Therefore, the order of the seven dimensions is fixed as a pipeline, and parallel or out-of-order execution is not allowed.
[0016] The first dimension check checks if the total number of nodes in the directed graph model is 0. If the total number of nodes is 0, an error message "Workflow has no nodes" is immediately output. Although subsequent dimension checks can be performed to prevent the user from seeing all the problems at once, an empty workflow has no practical significance in subsequent checks. Therefore, the error message of the empty workflow check will be recorded as the highest priority error.
[0017] The second dimension checks whether a node of type "starter" exists in the directed graph model. If it does not exist, the output will be the error message "Workflow lacks a starter node". The starter node is the only basis for the executor to find the workflow entry point; its absence will cause the workflow to fail completely.
[0018] The third dimension checks whether there are nodes of type "end" in the directed graph model. If not, the output is a warning message: "The workflow is missing an end node and may not terminate properly." Since the executor can automatically terminate after traversing all reachable nodes in some scenarios, the missing end node is considered a warning rather than an error.
[0019] The fourth dimension involves island node detection. The system iterates through each edge in the directed edge set, adding both the source and target node identifiers to a set of connected nodes. Then, it iterates through all nodes, excluding those of start and end types, checking if their node identifier already exists in the set of connected nodes. If a node identifier is not in the set of connected nodes, it means that the node has neither incoming nor outgoing edges—and will never be scheduled during execution. For such nodes, the system outputs a warning message containing the node name and identifier. Start and end type nodes are excluded because start nodes are allowed to have only outgoing edges and no incoming edges, and end nodes are allowed to have only incoming edges and no outgoing edges; these two cases belong to the normal workflow structure and should not trigger island warnings.
[0020] The fifth dimension checks the validity of connection references. The system traverses each directed edge in the set of directed edges, checking if its source node identifier exists in the node identifier set, and then checking if its target node identifier exists in the node identifier set. If the source node identifier does not exist, the output is the error message "The source node of the connection with identifier X does not exist"; if the target node identifier does not exist, the output is the error message "The target node of the connection with identifier X does not exist". The reference validity check ensures that subsequent loop detection algorithms will not encounter anomalies due to accessing non-existent nodes.
[0021] The sixth dimension performs circular reference detection, which is the core algorithm of this invention. The system uses a traversal coloring algorithm. Initially, all nodes are in an unvisited state. The system maintains an empty set of nodes under visit and an empty set of nodes already visited, and performs a depth-first traversal on each node in the node identifier set. The recursive process is as follows: When entering a node, first check if the node already exists in the set of nodes under visit. If so, it means that the same node has been visited a second time on the current depth-first path, that is, there is a circular path starting from this node, passing through several intermediate nodes and finally returning to itself. A circular reference is detected and an error message is output. If the node already exists in the set of nodes already visited, it means that this node and all its successor nodes have been fully checked in the previous traversal and no cycle has been found, so return directly. If neither condition is met, add the node to the set of nodes under visit, obtain a list of all target nodes with directed edges originating from this node, and recursively call the same detection process on each target node in the list. After the recursion returns, remove the node from the set of nodes under visit and add it to the set of nodes already visited, indicating that the subtree rooted at this node has completed the cycle check. Once the entire traversal process is complete, if a loop check is triggered during any recursion, the sixth dimension will output a circular reference error message.
[0022] The seventh dimension checks the multi-exit configuration of condition nodes. The system traverses all nodes of type "condition" and counts the number of directed edges originating from that node. When the number of outgoing edges is 1, the output is a warning message: "Condition node has only one exit." The essence of a condition node is to select different downstream paths to execute based on the calculation result of the condition expression. If there is only one exit, the condition judgment loses its practical meaning, equivalent to an unconditional edge. When the number of outgoing edges is 0, the problem is more serious, but it has already been covered in the fourth dimension's island detection.
[0023] like Figure 1 As shown in mark 109, after all seven dimensions have been executed, the system summarizes the output of all dimensions and generates a structured validation report. The validation report contains three fields: `valid` (valid flag), `errors` (error message list), and `warnings` (warning message list). The `valid` flag is set to `true` when the error message list is empty (valid), and `false` otherwise (invalid). The presence or absence of content in the warning message list does not affect the value of the `valid` flag—warnings are advisory and do not prevent workflow execution.
[0024] In practical applications, for a workflow containing only a start node and an end node but no connecting edges, the verification result is valid (no errors) but contains three warnings: a warning for a missing end node and a warning for two isolated nodes. For a workflow forming a closed loop from node A to node B to node A, the verification result will explicitly indicate that a circular reference error has been detected.
[0025] like Figure 2 As shown, when the result of the third dimension check (checking for the existence of end-type nodes 204) is negative, the system does not terminate the verification process but continues to execute subsequent verification dimensions. Specifically, after determining that no end-type nodes exist, the system sequentially executes the following steps: constructing a set of connected nodes and detecting isolated nodes 205; checking the validity of source and target node references for each directed edge 206; performing traversal coloring to detect circular references 207; checking the number of outgoing edges for each condition type node 208; and finally summarizing the output of all dimensions to generate a verification report 209. This process design ensures that even if a problem is found in one dimension, the checks of other dimensions can still be fully executed, allowing users to obtain all potential problems in one verification, avoiding the tedious process of repeated modifications and re-verification.
[0026] The above description is merely an illustration of specific embodiments of the present invention and is not intended to limit the scope of the invention. Those skilled in the art can make various modifications and improvements without departing from the spirit and scope of the invention, and all such modifications and improvements fall within the protection scope of the present invention.
Claims
1. A method for verifying automated workflows based on directed graph cycle detection, characterized in that, Includes at least the following steps: Obtain the workflow to be verified, extract all nodes and all directed edges in the workflow to be verified, and construct a directed graph model by a set of node identifiers and a set of directed edges. The directed graph model is subjected to a seven-dimensional verification pipeline, which includes the following in sequence: first dimension empty workflow check, second dimension start node existence check, third dimension end node existence check, fourth dimension isolated node detection, fifth dimension connection reference validity check, sixth dimension circular reference detection, and seventh dimension condition node multiple exit check. In the sixth dimension of circular reference detection, a traversal coloring algorithm is used to mark nodes in three states: unvisited, visited, and visited. During the depth-first traversal, it is detected whether a node that is already in the visited state is visited again. Summarize all outputs from the seven-dimensional verification pipeline to generate a verification report containing valid flags, a list of error messages, and a list of warning messages.
2. The method according to claim 1, characterized in that, The circular reference detection step in the sixth dimension specifically includes: initializing an empty set of nodes in the current access set and an empty set of nodes already visited; performing the following recursive process for each node in the set of nodes in the current access set: if the current node already exists in the set of nodes in the current access set, return that a circular reference has been detected; if the current node already exists in the set of nodes already visited, return that no circular reference has been detected; adding the current node to the set of nodes in the current access set; obtaining a list of target nodes for all directed edges with the current node as the source node; recursively performing the recursive process for each target node; removing the current node from the set of nodes in the current access set and adding it to the set of nodes already visited.
3. The method according to claim 1, characterized in that, In the fourth dimension step of detecting isolated nodes, the basis for excluding start type and end type nodes is that start type and end type nodes are structural nodes in the workflow, and are allowed to be without incoming or outgoing edges, and should not be judged as isolated nodes.
4. The method according to claim 1, characterized in that, In the seventh dimension step of detecting multiple exits of condition nodes, the number of directed edges with condition type nodes as source nodes is counted. When the number is equal to 1, the output content is a warning message: "The condition node has only one exit. It is recommended to configure at least two exits: a true branch and a false branch." 5. The method according to claim 1, characterized in that, The validity flag of the verification report is valid when the error message list is empty and invalid when the error message list is not empty; warning messages in the verification report do not affect the value of the validity flag.
6. A workflow automation verification system based on directed graph cycle detection, characterized in that, include: The directed graph construction module is used to obtain the workflow to be verified, extract all nodes and all directed edges in the workflow to be verified, and construct a set of node identifiers and a set of directed edges to form a directed graph model. The seven-dimensional verification module is used to sequentially execute a seven-dimensional verification pipeline on the directed graph model. The seven-dimensional verification pipeline includes an empty workflow check unit, a start node check unit, an end node check unit, an isolated node detection unit, a connection reference check unit, a circular reference detection unit, and a condition node multi-exit check unit. The circular reference detection unit uses a traversal coloring algorithm to maintain three sets: an unvisited node set, a visited node set, and a visited node set. It performs a depth-first traversal starting from each of the nodes. When a node's successor already exists in the visited node set during the traversal, a circular reference is detected. The report generation module is used to summarize all the outputs of the seven-dimensional verification pipeline and generate a verification report containing valid flags, a list of error messages, and a list of warning messages.
7. The system according to claim 3, characterized in that, The recursive process executed by the circular reference detection unit includes: returning "circular reference detected" when the current node already exists in the visited set; returning "not detected" directly when the current node already exists in the visited set; adding the current node to the visited set; obtaining a list of target nodes for all directed edges with the current node as the source node; recursively executing the recursive process for each target node; and removing the current node from the visited set and adding it to the visited set.
8. The system according to claim 3, characterized in that, The isolated node detection unit excludes start type and end type nodes when detecting isolated nodes. The condition node multi-exit inspection unit counts the number of outgoing edges of a condition type node when detecting condition type nodes. When the number of outgoing edges is less than 2, a warning message is output.
9. A terminal device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 3.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
