Equipment execution method and device based on directed graph and computer equipment
By deeply traversing and topological sorting of the starting nodes in the directed graph, redundant paths are identified and eliminated, the problem of serious performance consumption in large-scale high-concurrency scenarios is solved, the equipment execution results of the optimal path are achieved, and the response speed is improved.
Patent Information
- Application Number
- CN202411661822.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-02-28
AI Technical Summary
When processing application scenarios of equipment with large data computing, it is difficult for the prior art to achieve optimal results in large-scale equipment and high-concurrency search scenarios, resulting in serious system performance consumption.
By obtaining a directed graph, multiple starting nodes are determined, and deep traversal is performed on each starting node to obtain the number of traversal trajectories and target rings. Then, each starting node is topologically sorted according to the number of target rings to obtain the device execution result that characterizes the optimal path.
By identifying and eliminating redundant paths, optimizing the path for equipment to perform tasks can be completed in the shortest time, and improving the overall response speed of the sorting and selection scheme of complex device models.
Smart Images

Figure CN119537652A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a device execution method, apparatus and computer device based on a directed graph. Background Art
[0002] Directed graphs have strict topological properties and strong process expression capabilities. They can be used to display workflows, state transitions, genealogical hierarchies, version history changes, etc. When sorting and scheduling device models, you can only completely traverse the directed graph for full search, so each directed graph sorting algorithm has its applicable scenarios and limitations. In application scenarios where devices with large amounts of data calculations are executed, system performance consumption will inevitably be very serious, especially in high-concurrency search scenarios with large device scales, where a single sorting algorithm may not achieve optimal results. Summary of the invention
[0003] Based on this, the purpose of this application is to provide a device execution method, apparatus and computer device based on a directed graph, which can accurately obtain the device execution results representing the optimal path to solve the technical problems mentioned in the above background technology.
[0004] In a first aspect, the present application provides a device execution method based on a directed graph, including:
[0005] Obtaining a directed graph; the directed graph includes nodes representing devices and edges of topological connections between the devices;
[0006] Determine a plurality of starting nodes in the directed graph, and perform a depth traversal on each starting node to obtain a traversal trajectory and the number of target rings corresponding to each starting node;
[0007] Topologically sort each starting node according to the number of the plurality of target rings to obtain a device execution result representing an optimal path.
[0008] In one embodiment, after obtaining the directed graph, the method further includes: determining a node set; the node set includes a starting node set with an in-degree of 0; the in-degree represents the number of edges pointing to the node; preliminarily sorting the node set according to the Kahn algorithm; and updating the starting node set according to the node attributes after the preliminary sorting.
[0009] In one embodiment, the starting node set is updated according to the node attributes after preliminary sorting, including: searching for at least one initial ring in the preliminary sorted graph; determining the initial node according to the node attributes of each node in the initial ring; the node attributes include priority and weighted value; and adding at least one of the initial nodes to the starting node set.
[0010] In one embodiment, a deep traversal is performed on each starting node to obtain a traversal trajectory and the number of target rings corresponding to each starting node, including: for a current starting node among multiple starting nodes, searching for a traversal trajectory corresponding to the current starting node by a strongly connected component algorithm; determining whether there is a corresponding target ring in the traversal trajectory corresponding to the current starting node; if so, determining the number of target rings corresponding to the current starting node according to configuration information.
[0011] In one embodiment, determining the number of target rings corresponding to the current starting node according to the configuration information includes: when the configuration information indicates that no solution is required, determining the number of target rings corresponding to the current starting node;
[0012] In one embodiment, the above method also includes: determining the corresponding target node according to the node attributes of each node in each of the target rings, and deleting the edges pointing to each of the target nodes; obtaining the next starting node of the current starting node, and returning to the process of finding the traversal trajectory corresponding to the next starting node through the strongly connected component algorithm.
[0013] In one embodiment, the target ring includes an algebraic ring; the above method also includes: when the configuration information representation needs to be solved, calling a solver to solve the algebraic ring; obtaining the next starting node of the current starting node, and returning to the process of searching for the traversal trajectory corresponding to the next starting node through the strongly connected component algorithm to continue.
[0014] In one embodiment, topological sorting is performed on each starting node according to the number of multiple target rings to obtain a device execution result representing the optimal path, including: filtering out a target starting node from multiple starting nodes in turn according to the number of multiple target rings; updating the in-degree of each child node associated with the target starting node; sorting the target starting node and the corresponding multiple child nodes according to the in-degree update result to obtain a sorting result corresponding to the target starting node; and filtering out a device execution result representing the optimal path from the sorting results corresponding to the multiple target starting nodes.
[0015] In a second aspect, the present application also provides a device execution apparatus based on a directed graph, including:
[0016] A deep traversal module is used to obtain a directed graph; the directed graph includes nodes representing devices and edges of topological connections between the devices; determine multiple starting nodes in the directed graph, and perform a deep traversal on each starting node to obtain the traversal trajectory and the number of target rings corresponding to each starting node;
[0017] The topological sorting module is used to perform topological sorting on each starting node according to the number of the plurality of target rings to obtain a device execution result representing an optimal path.
[0018] In a third aspect, the present application further provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above directed graph-based device execution method when executing the computer program.
[0019] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above directed graph-based device execution method are implemented.
[0020] The above-mentioned device execution method, apparatus, computer device and readable storage medium based on a directed graph can accurately obtain the traversal trajectory and the number of target rings corresponding to each starting node by determining multiple starting nodes in the directed graph and performing a deep traversal on each starting node, so that redundant paths can be identified and eliminated through the calculation of the deep traversal and the number of target rings, thereby optimizing the path for the device to execute the task. Then, each starting node is topologically sorted according to the number of multiple target rings to obtain the device execution result representing the optimal path, which can complete the task in the shortest time and improve the overall response speed of the sorting and selection scheme of the complex device model. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 An application environment diagram of a device execution method based on a directed graph in one embodiment;
[0022] Figure 2 A schematic diagram of a flow chart of a device execution method based on a directed graph in one embodiment;
[0023] Figure 3 A schematic flow chart of a directed graph-based device execution method in another embodiment;
[0024] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0026] The device execution method based on the directed graph provided in the embodiment of the present application can be applied to Figure 1In the application environment shown, and through the interaction between the terminal 102 and the server 104. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 is used to obtain the directed graph fed back by the terminal 102, determine multiple starting nodes in the directed graph, and perform a deep traversal of each starting node to obtain the traversal trajectory and the number of target rings corresponding to each starting node. The server 104 is also used to topologically sort each starting node according to the number of multiple target rings, and obtain the device execution result that characterizes the optimal path, so that the terminal 102 displays the device execution result. Among them, the terminal 102 can be, but is not limited to, various personal computers, smart phones, tablet computers, drone equipment, smart vehicle-mounted devices, portable wearable devices, etc. Server 104 is implemented by an independent server or a server cluster composed of multiple servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0027] In one embodiment, Figure 2 As shown, a device execution method based on a directed graph is provided, and the method is applied to Figure 1 The server in the process includes the following steps:
[0028] Step 202, obtaining a directed graph.
[0029] The directed graph includes nodes representing devices and edges that are topologically connected to each device.
[0030] Among them, a directed graph is a data structure for storing device models, including attributes such as vertices, edges, out-degree, path, cycle, and strongly connected component. Vertices (Vertices / Nodes), also known as nodes, are the basic units in the graph and can represent any object such as a device. An edge (Edges) is a line segment connecting two vertices, which has a directionality and is usually represented by an arrow. Out-degree: For a given node, its out-degree refers to the number of edges starting from this node. In-degree: For a given node, its in-degree refers to the number of edges pointing to this node. A path (Path) is a sequence composed of a series of vertices v1, v2... vn, where for each i (1 ≤ i < n), there is an edge from vi to vi+1. If the starting point and the ending point of a path are the same vertex, then this path is called a cycle (Cycle). If there exist paths from any two vertices u and v to each other, then these vertices form a strongly connected component (Strongly Connected Component, SCC).
[0031] Specifically, when the device is various power devices in the power system field, the server pre-generates a directed graph based on the logical topology graph of the power devices in the infrastructure layer, so as to determine the device execution result representing the optimal path through the directed graph. For example, the power flow calculation of the device is determined according to the device execution result, and device fault recovery and reconstruction are performed, etc.
[0032] In one embodiment, the server stores the directed graph using an adjacency list data structure that is convenient for processing.
[0033] In one embodiment, after obtaining the directed graph, it further includes: determining a set of nodes; performing a preliminary sorting on the set of nodes according to Kahn's algorithm; and updating the set of starting nodes according to the node attributes after the preliminary sorting.
[0034] Among them, the set of nodes includes a set of starting nodes with an in-degree of 0. Kahn's Algorithm is used to sort the directed graph. The basic idea of this algorithm is to continuously remove nodes with an in-degree of 0 synchronously until all nodes in the graph have been visited.
[0035] Specifically, the server pre-saves the nodes of various objects such as devices into a set, and then performs a preliminary sorting on the set of nodes based on Kahn's algorithm. Since the node attributes exist for each node and need to be set by itself, the set of starting nodes can be updated according to the actual requirements based on the node attributes after the preliminary sorting. Therefore, through the preliminary sorting and updating of the set of nodes, Kahn's algorithm enhances the robustness of the algorithm for processing complex graph structures, enabling it to adapt to different application scenarios.
[0036] In one embodiment, the starting node set is updated according to the node attributes after preliminary sorting, including: finding at least one initial ring in the preliminary sorted graph; determining the initial node according to the node attributes of each node in the initial ring; and adding at least one initial node to the starting node set.
[0037] Among them, node attributes include priority and weighted value.
[0038] Specifically, during the initial sorting of the node set, the server will also find at least one initial ring without a starting node. When the node attribute is priority, the server determines the node with the highest priority in the initial ring as the initial node, and disconnects the edge pointing to the initial node. The server adds the initial node to the starting node set and repeats the above operation until the starting node is added after traversing the entire directed graph. Therefore, by identifying the initial ring and determining the initial node, and adding the initial node to the starting node set, the system startup process can be optimized, ensuring that the system can start execution from the correct position, and enhancing the flexibility of task scheduling.
[0039] Step 204, determine multiple starting nodes in the directed graph, and perform a depth traversal on each starting node to obtain the traversal trajectory and the number of target rings corresponding to each starting node.
[0040] The starting node is a node with an in-degree of 0.
[0041] Specifically, the server performs a depth traversal of each starting node using a depth-first search algorithm (DFS). After selecting a starting node, mark it as visited, and use it as the current node, visit the current node, and perform necessary operations on the current node, such as printing node information. Then traverse all unvisited adjacent nodes of the current node, and for each unvisited adjacent node, mark the adjacent node as visited. Recursively call the depth-first search function, using the adjacent node as the new current node. After all adjacent nodes of the current node have been visited, the recursive call returns, and continues to explore other branches in the directed graph until all nodes have been visited and the search ends, obtaining the traversal trajectory corresponding to each starting node. At the same time, in the process of deep traversal using the depth-first search algorithm, the server can detect the existence of the target ring and mark the nodes participating in the target ring.
[0042] In one embodiment, the server may break the loop of the target ring by deleting an edge.
[0043] Step 206 , topologically sort each starting node according to the number of multiple target rings to obtain a device execution result representing the optimal path.
[0044] Among them, topological sorting is a method of arranging the nodes in a directed graph into a linear sequence, and such sorting is not unique. Topological sorting is often used in scenarios such as task scheduling.
[0045] Specifically, the server performs topological sorting starting from each starting node in turn according to the number of target rings corresponding to each starting node. Before starting sorting, the server will traverse the directed graph and save the initial in-degree of each node. Then the server searches for the starting node with an initial in-degree of 0 and starts sorting, saving it to a container, which can be sorted according to the priority or weight value of the node until the sorting result corresponding to each starting node is obtained, so that the server can filter out the device execution result representing the optimal path from the sorting results corresponding to multiple target starting nodes. The multiple sorting results can also be combined into an overall sorting result.
[0046] In the above-mentioned device execution method based on directed graph, by determining multiple starting nodes in the directed graph and performing deep traversal on each starting node, the traversal trajectory and the number of target rings corresponding to each starting node can be accurately obtained, so that through deep traversal and calculation of the number of target rings, redundant paths can be identified and eliminated, thereby optimizing the path for device execution tasks. Then, each starting node is topologically sorted according to the number of multiple target rings to obtain the device execution result representing the optimal path, which can complete the task in the shortest time and improve the overall response speed of the sorting and selection scheme of complex device models.
[0047] It is easy to understand that the method of solving the device model in this application is applicable to the sorting of various directed graph models. The de-looping sorting technology in the directed graph has applications in many fields, especially in scenarios where dependencies need to be processed, tasks need to be executed sequentially, or paths need to be optimized. In addition to the above-mentioned power system field, in the field of transportation networks, route planning, signal control, etc. can be performed through the device execution results; in the field of communication networks, data transmission optimization, fault-tolerant mechanism design, etc. can be performed through the device execution results; in manufacturing and supply chain management, production scheduling, logistics distribution, etc. can be performed through the device execution results. This application does not limit the field embodied by the equipment.
[0048] For example, in the field of communication networks, routing algorithms are the key to ensuring that data packets can be correctly transmitted from the starting node to the ending node. Constructing directed graphs and performing topological sorting are the basic steps to implement efficient routing algorithms. Topological sorting is mainly used to detect loops and determine the order relationship between nodes. By defining nodes: determine all devices in the network (such as routers, switches, etc.), each device corresponds to a node; assign a unique identifier to each node. Then define edges: based on actual physical connections or logical connections, determine which nodes have direct communication links; each link is represented by a directed edge, and the direction is set according to the direction of data transmission; assign weights to each edge, which can represent factors such as link cost, delay, and bandwidth limitation.
[0049] In one embodiment, Figure 3 As shown, Figure 3 The flowchart of the device execution method based on a directed graph in another embodiment is shown. Since de-ringing a directed graph is a step in the topological sorting process, that is, the ring structure cannot exist when the topological sorting is performed, it is necessary to search for the ring and delete the edges in the ring of the directed graph. The server creates a directed graph based on the logical topological graph of each device and stores it in the library to determine whether there are any edges in the directed graph. If there are no edges, topological sorting is performed according to the priority of the nodes to obtain the device execution result. If there are any edges, it is checked whether there is a completely closed initial ring. If so, the initial node is determined according to the node attributes of each node in the initial ring, and the initial node is added as a new starting node; if not, the server determines multiple starting nodes in the directed graph, and returns to the process of deep traversal of each starting node for execution.
[0050] In one embodiment, a deep traversal is performed on each starting node to obtain a traversal trajectory and the number of target rings corresponding to each starting node, including: for a current starting node among multiple starting nodes, searching for a traversal trajectory corresponding to the current starting node through a strongly connected component algorithm; determining whether there is a corresponding target ring in the traversal trajectory corresponding to the current starting node; if so, determining the number of target rings corresponding to the current starting node according to configuration information.
[0051] Among them, the strongly connected component algorithm is for example the Tarjan algorithm, which is an efficient algorithm based on depth-first search (DFS) to find strongly connected components. Once all strongly connected components are found, a suitable strategy can be selected to untie the loops within these components. The configuration information is the trigger information pre-set by the user.
[0052] Specifically, after determining multiple starting nodes in the directed graph, the server performs the following processing on each starting node. Here, the current starting node is used as an example for explanation. Figure 3As shown, the server uses the strongly connected component algorithm to perform a deep traversal from the current starting node and records the traversal trajectory. During the traversal execution process, the strongly connected component algorithm maintains two key arrays: dfn and low. The dfn array records the order in which each node is visited, and the low array records the order of the earliest node that each node can trace back to. The key to the strongly connected component algorithm is to identify backward edges, that is, edges from a node to its starting node, because backward edges indicate the existence of a loop. For example, starting from node a, the traversal trajectory of the traversed node is recorded as abcde. If the next node is c and it is a node in the traversal trajectory, it can be determined that a loop is encountered. If it exists, the server will determine the number of target loops corresponding to the current starting node based on the configuration information.
[0053] In this embodiment, the traversal trajectory and the key loops in the directed graph can be accurately identified through the strongly connected component algorithm, and the structure of the directed graph can be more deeply understood, which is crucial for the analysis and optimization of the directed graph. At the same time, the number of target loops can be assisted in determining according to the configuration information specified by the user, so that the task scheduling can be adjusted in a personalized manner.
[0054] In one embodiment, determining the number of target rings corresponding to the current starting node according to the configuration information includes: when the configuration information indicates that no solution is required, determining the number of target rings corresponding to the current starting node.
[0055] Among them, when the configuration information indicates that no solution is required, that is, the user pre-configures that the target ring does not need to be solved, all nodes in the target ring are not treated as a whole. The number of target rings corresponding to the current starting node is recorded while traversing the entire directed graph.
[0056] In one embodiment, the above method also includes: determining the corresponding target node based on the node attributes of each node in each target ring, and deleting the edge pointing to each target node; obtaining the next starting node of the current starting node, and returning to the process of finding the traversal trajectory corresponding to the next starting node through the strongly connected component algorithm to continue.
[0057] Specifically, refer to Figure 3 As shown in the figure, when it is determined that there is a target ring in the traversal trajectory corresponding to the current starting node, but the configuration information does not need to be solved, the server needs to delete the edges in the target ring. When the node attribute is priority, the server determines the node with the highest priority in the target ring as the target node, and disconnects the edge pointing to the target node. After the processing of deleting the edge in the traversal trajectory of the current starting node is completed, the next starting node of the current starting node is obtained, and the process of finding the traversal trajectory corresponding to the next starting node through the strongly connected component algorithm is returned to continue until the starting node of the traversal is the end node.
[0058] In this embodiment, the target ring can be flexibly processed for edge deletion through configuration information, and specific deletion operations can be performed according to the node attributes of each node in each target ring, which can optimize the subsequent topological sorting process and reduce unnecessary path exploration, thereby improving the efficiency of the algorithm.
[0059] In one embodiment, the above method also includes: when the configuration information representation needs to be solved, calling the solver to solve the algebraic ring; obtaining the next starting node of the current starting node, and returning to the process of searching for the traversal trajectory corresponding to the next starting node through the strongly connected component algorithm to continue.
[0060] The target loop includes an algebraic loop; an algebraic loop is a closed loop formed in a feedback path of multiple nodes in control system theory and simulation models, and all nodes in the path are not delay elements.
[0061] Specifically, refer to Figure 3 As shown, when it is determined that there is a target ring in the traversal trajectory corresponding to the current starting node, but the configuration information needs to be solved, that is, the user pre-configures that the target ring needs to be solved. At this time, all nodes in the target ring are treated as a whole and the result is solved. The server directly calls the solver, and the algebraic ring is solved by the optimization algorithm (LMA, Levenberg-Marquardt method) for solving nonlinear quadratic problems. After the solution of the algebraic ring corresponding to the current starting node is processed, the next starting node of the current starting node is obtained, and the process of finding the traversal trajectory corresponding to the next starting node by the strongly connected component algorithm is returned to continue until the traversal starting node is the end node.
[0062] In this embodiment, calling the solver to solve the algebraic ring not only helps to solve the algebraic ring problem and improve the simulation efficiency, but also enhances the adaptability of the algorithm and optimizes the subsequent topological sorting process. When facing complex graph structures and dynamically changing environments, this method of combining the algebraic ring solver and the strongly connected component algorithm can improve the robustness of the system.
[0063] In one embodiment, each starting node is topologically sorted according to the number of multiple target rings to obtain a device execution result representing an optimal path, including: according to the number of multiple target rings, sequentially filtering out a target starting node from multiple starting nodes; updating the in-degree of a child node associated with each target starting node; sorting the target starting node and the corresponding multiple child nodes according to the in-degree update result to obtain a sorting result corresponding to the target starting node; and filtering out a device execution result representing the optimal path from the sorting results corresponding to the multiple target starting nodes.
[0064] Specifically, refer to Figure 3As shown, the server can sequentially use the starting node with the least number of target rings as the target starting node, and update the initial in-degree of each node when traversing the directed graph. The server sequentially saves multiple target starting nodes with an initial in-degree of 0 into a container according to priority, and the container at this time can be a queue or a stack. Then, the first target starting node is added to the sorting result of the topological sorting, that is, a sorting sequence, and the target starting node is removed from the container. For each child node in the traversal trajectory of the target starting node, its in-degree is reduced by 1. If the in-degree update result after the in-degree of the child node is reduced by 1 is equal to 0, then the child node is inserted into the container, and the process of returning to the priority to add the child node with an in-degree of 0 to the sorting result of the topological sorting continues until the traversal reaches the end node in the traversal trajectory, and the latest sorting result is obtained after the topological sorting of the target starting node and the child node is completed. After the topological sorting is completed, the in-degree of all nodes will become 0. The server can filter out the device execution result representing the optimal path from the sorting results corresponding to multiple target starting nodes.
[0065] In this embodiment, by screening the target starting node and updating the in-degree of the child node, the optimal path from the starting point to the end point can be planned more accurately, reducing the search space. Through the screening and sorting process, unnecessary calculations can be reduced, computing resources and time can be saved, and the overall response speed of the sorting selection scheme of complex device models can be improved. In summary, the present application achieves the optimal effect of topological sorting by combining the Kahn algorithm, increasing the node attributes of priority or weighted values, algebraic ring solving and other functions, and can accurately realize the shortest path solution of the directed graph. The method of the present application can be integrated in the product, and the method of the present application can be triggered and implemented through modeling and simulation.
[0066] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0067] Based on the same inventive concept, the embodiment of the present application also provides a directed graph-based device execution apparatus for implementing the directed graph-based device execution method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations of one or more directed graph-based device execution apparatus embodiments provided below can refer to the limitations of the directed graph-based device execution method above, and will not be repeated here.
[0068] In one embodiment, a device execution apparatus based on a directed graph is provided, comprising: a depth traversal module and a topological sorting module, wherein:
[0069] The deep traversal module is used to obtain a directed graph; the directed graph includes nodes representing devices and edges of topological connections between the devices; multiple starting nodes in the directed graph are determined, and each starting node is deeply traversed to obtain the traversal trajectory and the number of target rings corresponding to each starting node.
[0070] The topological sorting module is used to topologically sort each starting node according to the number of multiple target rings to obtain a device execution result representing the optimal path.
[0071] Each module in the above-mentioned directed graph-based device execution can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.
[0072] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store a directed graph. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a device execution method based on a directed graph is implemented.
[0073] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0074] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0075] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0076] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0077] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0078] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0079] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A device execution method based on a directed graph, characterized in that: The method comprises: Obtaining a directed graph; the directed graph includes nodes representing devices and edges of topological connections between the devices; Determine a plurality of starting nodes in the directed graph, and perform a depth traversal on each starting node to obtain a traversal trajectory and the number of target rings corresponding to each starting node; Topologically sort each starting node according to the number of the plurality of target rings to obtain a device execution result representing an optimal path.
2. The method according to claim 1, characterized in that After obtaining the directed graph, it also includes: Determine a node set; the node set includes a starting node set with an in-degree of 0; the in-degree represents the number of edges pointing to the node; Preliminarily sorting the node set according to the Kahn algorithm; The starting node set is updated according to the node attributes after preliminary sorting.
3. The method according to claim 2, characterized in that The updating of the starting node set according to the node attributes after preliminary sorting includes: Finding at least one initial cycle in the initially sorted graph; Determining an initial node according to node attributes of each node in the initial ring; the node attributes include priority and weighted value; Add at least one of the initial nodes to the starting node set.
4. The method according to claim 1, characterized in that: The process of performing a deep traversal on each starting node to obtain the traversal tracks and the number of target rings corresponding to each starting node includes: For a current starting node among multiple starting nodes, searching for a traversal trajectory corresponding to the current starting node by using a strongly connected component algorithm; Determine whether there is a corresponding target ring in the traversal trajectory corresponding to the current starting node; If it exists, the number of target rings corresponding to the current start node is determined according to the configuration information.
5. The method according to claim 4, characterized in that The step of determining the number of target rings corresponding to the current starting node according to the configuration information includes: When the configuration information indicates that no solution is required, determining the number of target rings corresponding to the current starting node; The method further comprises: determining a corresponding target node according to the node attributes of each node in each of the target rings, and deleting an edge pointing to each of the target nodes; The next starting node of the current starting node is obtained, and the process of returning to the strongly connected component algorithm to find the traversal trajectory corresponding to the next starting node is continued.
6. The method according to claim 4, characterized in that The target ring includes an algebraic ring; the method further includes: When the configuration information representation needs to be solved, calling a solver to solve the algebraic loop; The next starting node of the current starting node is obtained, and the process of returning to the strongly connected component algorithm to find the traversal trajectory corresponding to the next starting node is continued.
7. The method according to claim 1, characterized in that Topologically sorting each starting node according to the number of the plurality of target rings to obtain a device execution result representing an optimal path, including: According to the number of multiple target rings, select the target starting node from the multiple starting nodes in turn; Updating the in-degree of each child node associated with the target start node; Sort the target start node and the corresponding multiple child nodes according to the in-degree update result to obtain a sorting result corresponding to the target start node; A device execution result representing an optimal path is screened out from the sorting results corresponding to the plurality of target start nodes.
8. A device execution device based on a directed graph, characterized in that: The device comprises: A deep traversal module is used to obtain a directed graph; the directed graph includes nodes representing devices and edges of topological connections between the devices; determine multiple starting nodes in the directed graph, and perform a deep traversal on each starting node to obtain the traversal trajectory and the number of target rings corresponding to each starting node; The topological sorting module is used to perform topological sorting on each starting node according to the number of the plurality of target rings to obtain a device execution result representing an optimal path.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Information determination method and device, equipment and medium
CN120430727A
Information determination method, device, equipment and medium
CN120430727B
Graphical simulation method and device for signal flow, equipment and storage medium
CN121389536A
A method, device and storage medium for graphical simulation of signal flow
CN121389536B
Battery tab layer number calculation method, device and equipment based on linear programming
CN121505580A