Methods, apparatus and storage media for calculating mutually exclusive paths

By calculating the first shortest path and its alternative paths from the source node to the destination node in the electronic device, mutually exclusive paths are determined, solving the problems of low efficiency and reliability in the prior art, and realizing efficient and reliable calculation of mutually exclusive paths.

CN119728528BActive Publication Date: 2026-05-26STATE GRID INFORMATION & TELECOMM BRANCH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
STATE GRID INFORMATION & TELECOMM BRANCH
Filing Date
2024-12-12
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing technologies have low efficiency and reliability in calculating mutually exclusive paths in the topology of electronic devices, especially when the network is too large, it is difficult to find two mutually exclusive paths effectively.

Method used

By obtaining the first shortest path from the source node to the destination node, and calculating M+1 alternative paths based on this path and M intermediate nodes, we determine the paths that are mutually exclusive with the first shortest path and identify two mutually exclusive paths. Alternatively, if there are no mutually exclusive paths, we select the shortest path among the M+1 alternative paths as the second alternative path and continue to match two mutually exclusive paths.

Benefits of technology

It improves the efficiency and reliability of electronic devices in calculating mutually exclusive paths, avoids the need to traverse all paths, and ensures that mutually exclusive paths can be found effectively even in large-scale networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728528B_ABST
    Figure CN119728528B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, and storage medium for calculating mutually exclusive paths, relating to the field of power operation and maintenance technology, and is used to improve the efficiency and reliability of calculating mutually exclusive paths for electronic devices. The method includes: obtaining a first shortest path between a source node and a destination node, the first shortest path including M intermediate nodes, M≥0; calculating M+1 candidate paths based on the source node and the M intermediate nodes, each intermediate node corresponding to one candidate path; if there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths; or, if there is no path mutually exclusive with the first shortest path among the M+1 candidate paths, determining two mutually exclusive paths based on a second candidate path, the second candidate path being the shortest path among the M+1 candidate paths.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power operation and maintenance, and in particular to a method, apparatus and storage medium for calculating mutually exclusive paths. Background Technology

[0002] In the field of network communication, various protection strategies are used to improve network survivability in order to reduce losses caused by data loss. Among these, the need to find two mutually exclusive paths is particularly important. Mutually exclusive paths refer to two paths that do not share nodes and can be used to implement applications such as redundant paths, load balancing, and fault tolerance.

[0003] Currently, commonly used pathfinding algorithms include Depth-First Search (DFS) and Breadth-First Search (BFS). However, both algorithms require calculating all possible paths in the network topology and then finding two mutually exclusive paths. When the network topology of electronic devices is too large, calculating mutually exclusive paths becomes inefficient. Alternatively, a "pruned successive shortest path" algorithm can be used. This involves first calculating a shortest path as the working path, then removing all links belonging to the working path from the network topology, and finally calculating a shortest path as the protection path on the pruned network topology. In other words, the calculated working path and protection path are treated as two mutually exclusive paths. However, the protection path may not be found in the pruned network topology.

[0004] In summary, electronic devices have low efficiency and reliability in calculating mutually exclusive paths. Summary of the Invention

[0005] This application provides a method, apparatus, and storage medium for calculating mutually exclusive paths, which can improve the efficiency and reliability of electronic devices in calculating mutually exclusive paths.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] In a first aspect, a method for calculating mutually exclusive paths is provided, applied to an electronic device. The method includes: obtaining a first shortest path between a source node and a destination node, the first shortest path including M intermediate nodes, M≥0; calculating M+1 candidate paths based on the source node and the M intermediate nodes, each intermediate node in the source node and the M intermediate nodes corresponding to a candidate path; if there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths; or, if there is no path mutually exclusive with the first shortest path among the M+1 candidate paths, determining two mutually exclusive paths based on a second candidate path, the second candidate path being the shortest path among the M+1 candidate paths.

[0008] Based on the aforementioned mutual exclusion path calculation method, since the electronic device obtains M+1 candidate paths based on the source node and the M intermediate nodes of the first shortest path, it can determine the mutual exclusion path corresponding to the first shortest path from these M+1 candidate paths. Furthermore, if no mutual exclusion path corresponding to the first shortest path exists among the M+1 candidate paths, the electronic device can continue to match two mutual exclusion paths based on the shortest path among the M+1 candidate paths, without needing to traverse all paths from each node to the destination node, thus avoiding the problem of not finding two mutual exclusion paths. Therefore, this application improves both the efficiency and reliability of mutual exclusion path calculation.

[0009] In one possible implementation, the method of "calculating M+1 alternative paths based on the source node and M intermediate nodes" includes: for any node among the source node and M intermediate nodes, taking any node as the deviation point, calculating the second shortest path between any node and the destination node; and calculating the alternative path corresponding to any node based on the second shortest path and the third shortest path between the source node and any node.

[0010] In one possible implementation, before the above statement "in the case that there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, determine the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths", the mutually exclusive path calculation method further includes: matching the first shortest path with each of the M+1 candidate paths pairwise, and determining that there is a path mutually exclusive with the first shortest path among the M+1 candidate paths if the first candidate path and the first shortest path do not contain the same intermediate node.

[0011] In one possible implementation, the method of "determining the first shortest path and the first alternative path mutually exclusive with respect to the first shortest path as two mutually exclusive paths when there is a path mutually exclusive with the first shortest path among the M+1 alternative paths" includes: when there is a path mutually exclusive with the first shortest path among the M+1 alternative paths, obtaining the cost of the first shortest path and the cost of the first alternative path; and when the difference between the cost of the first shortest path and the cost of the first alternative path is less than a preset threshold, determining the first shortest path and the first alternative path as two mutually exclusive paths.

[0012] In one possible implementation, the method of "determining two mutually exclusive paths based on the second alternative path" includes: obtaining N+1 alternative paths based on the source node and N intermediate nodes of the second alternative path, where each intermediate node in the source node and the N intermediate nodes corresponds to an alternative path; N is a positive integer; determining the first sub-path and the second sub-path in the first path set as two mutually exclusive paths; wherein the first path set includes: N+1 alternative paths, the second alternative path, and the first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

[0013] Secondly, a mutual exclusion path calculation device is provided, which is applied to an electronic device and can also be a functional module in the electronic device for implementing the method described in the first aspect or any possible design of the first aspect. The mutual exclusion path calculation device can implement the functions performed by the electronic device in the above aspects or possible designs, and the functions can be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. For example, the mutual exclusion path calculation device includes an acquisition unit, a calculation unit, and a determination unit.

[0014] The acquisition unit is used to acquire the first shortest path between the source node and the destination node. The first shortest path includes M intermediate nodes, where M≥0.

[0015] The calculation unit is used to calculate M+1 candidate paths based on the source node and the M intermediate nodes included in the first shortest path obtained by the acquisition unit. Each intermediate node in the source node and the M intermediate nodes corresponds to a candidate path.

[0016] Determine the unit, used for:

[0017] If among the M+1 candidate paths there exists a path mutually exclusive with the first shortest path, then the first shortest path and the first candidate path mutually exclusive with the first shortest path are determined as two mutually exclusive paths; or,

[0018] If there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, two mutually exclusive paths are determined based on the second candidate path. The second candidate path is the shortest path among the M+1 candidate paths.

[0019] The specific implementation of the mutual exclusion path calculation device can refer to the behavior function of the electronic device in the mutual exclusion path calculation method provided by the first aspect or any possible design of the first aspect, and will not be repeated here. Therefore, the provided mutual exclusion path calculation device can achieve the same beneficial effects as the first aspect or any possible design of the first aspect.

[0020] In one possible implementation, the aforementioned calculation unit is specifically used to calculate the second shortest path between the source node and any one of the M intermediate nodes, taking any one node as an offset point; and to calculate the alternative path corresponding to any node based on the second shortest path and the third shortest path between the source node and any one node.

[0021] In one possible implementation, the determining unit is further configured to, in the case where there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, before determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths, perform pairwise matching of the first shortest path with each of the M+1 candidate paths, and determine that there is a path mutually exclusive with the first shortest path among the M+1 candidate paths if there are no common intermediate nodes between the first candidate path and the first shortest path.

[0022] In one possible implementation, the acquisition unit is further configured to acquire the cost of the first shortest path and the cost of the first candidate path when there is a path mutually exclusive with the first shortest path among the M+1 candidate paths. The determination unit is specifically configured to determine the first shortest path and the first candidate path as two mutually exclusive paths when the difference between the cost of the first shortest path and the cost of the first candidate path acquired by the acquisition unit is less than a preset threshold.

[0023] In one possible implementation, the aforementioned acquisition unit is further configured to acquire N+1 candidate paths based on the source node and the N intermediate nodes of the second candidate path, where each intermediate node in the source node and the N intermediate nodes corresponds to a candidate path; N is a positive integer. The determination unit is specifically configured to determine the first sub-path and the second sub-path in the first path set as two mutually exclusive paths; wherein the first path set includes: N+1 candidate paths, the second candidate path, and the first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

[0024] Thirdly, a mutual exclusion path calculation device is provided, which can be an electronic device or a chip or system-on-a-chip in an electronic device. This mutual exclusion path calculation device can implement the functions performed by the electronic device in the above-mentioned aspects or possible designs. These functions can be implemented in hardware. For example, in one possible design, the mutual exclusion path calculation device may include a processor and a communication interface. The processor can be used to support the mutual exclusion path calculation device in implementing the functions involved in the first aspect or any possible design of the first aspect. For example, the processor calculates M+1 alternative paths based on the source node and the M intermediate nodes included in the first shortest path.

[0025] In another possible design, the mutual exclusion path computing device may further include a memory for storing necessary computer execution instructions and data. When the mutual exclusion path computing device is running, the processor executes the computer execution instructions stored in the memory to cause the mutual exclusion path computing device to perform the mutual exclusion path computing method described in the first aspect or any possible design of the first aspect.

[0026] Fourthly, a mutual exclusion path calculation device is provided. This mutual exclusion path calculation device can be a mutual exclusion path calculation device or a chip or system-on-a-chip within a mutual exclusion path calculation device. This mutual exclusion path calculation device can implement the functions performed by the mutual exclusion path calculation device in the above aspects or possible designs. These functions can be implemented in hardware. For example, in one possible design, the mutual exclusion path calculation device may include a processor and a communication interface. The processor can be used to support the mutual exclusion path calculation device in implementing the functions involved in the first aspect or any possible design of the first aspect. For example, the processor calculates M+1 alternative paths based on the source node and the M intermediate nodes included in the first shortest path.

[0027] In another possible design, the mutual exclusion path computing device may further include a memory for storing necessary computer execution instructions and data. When the mutual exclusion path computing device is running, the processor executes the computer execution instructions stored in the memory to cause the mutual exclusion path computing device to perform the mutual exclusion path computing method described in the first aspect or any possible design of the first aspect.

[0028] Fifthly, a computer-readable storage medium is provided, which may be a readable non-volatile storage medium storing computer instructions or programs that, when executed on a computer, enable the computer to perform the mutual exclusion path calculation method described in the first aspect or any possible design of the above aspects.

[0029] In a sixth aspect, a computer program product containing instructions is provided, which, when run on a computer, enables the computer to execute the mutual exclusion path calculation method described in the first aspect or any possible design of the above aspects.

[0030] In a seventh aspect, a mutual exclusion path computing device is provided. This device can be a mutual exclusion path computing device or a chip or system-on-a-chip within a mutual exclusion path computing device. The mutual exclusion path computing device includes one or more processors and one or more memories. The one or more memories are coupled to the one or more processors and are used to store computer program code, including computer instructions. When the one or more processors execute the computer instructions, the mutual exclusion path computing device performs the mutual exclusion path computing method as described in the first aspect or any possible design of the first aspect.

[0031] Eighthly, a chip system is provided, comprising a processor and a communication interface. This chip system can be used to implement the functions performed by the mutual exclusion path calculation device in the first aspect or any possible design of the first aspect. For example, the processor calculates M+1 alternative paths based on a source node and M intermediate nodes included in a first shortest path. In one possible design, the chip system further includes a memory for storing program instructions and / or data. The chip system can be composed of chips or may include chips and other discrete devices, without limitation.

[0032] The technical effects of any of the design methods in aspects two through eight can be found in the technical effects of aspect one mentioned above, and will not be repeated here. Attached Figure Description

[0033] Figure 1 This is one of the flowcharts illustrating a mutual exclusion path calculation method provided in an embodiment of this application;

[0034] Figure 2 A second schematic flowchart illustrating a mutual exclusion path calculation method provided in this application embodiment;

[0035] Figure 3 This application provides a schematic diagram of a topology graph structure.

[0036] Figure 4 This is a schematic diagram of the structure of a mutual exclusion path calculation device provided in an embodiment of this application. Detailed Implementation

[0037] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0038] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.

[0039] It should also be understood that the term "comprising" indicates the presence of the described feature, whole, step, operation, element and / or component, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements and / or components.

[0040] As mentioned in the background section, in the fields of network communication and path calculation, an interruption of a single fiber optic segment or a failure of a node device during long-distance information transmission can cause significant service disruptions and data loss in the communication network. Such data loss is unacceptable to network users. To reduce the losses caused by data loss, various protection strategies are used to improve network survivability, among which the need to find two mutually exclusive paths is particularly important. Mutually exclusive paths refer to two paths that do not share nodes and can be used to implement redundant paths, load balancing, fault tolerance, and other application scenarios.

[0041] Current path calculation techniques primarily rely on Dijkstra's algorithm to find the shortest path. Dijkstra's algorithm is a classic single-source shortest path algorithm that determines the shortest path by calculating the edge weights between nodes. However, Dijkstra's algorithm cannot directly compute two mutually exclusive paths; it can only compute one shortest path. This is because Dijkstra's algorithm is based on a greedy strategy, selecting the node with the shortest current distance for expansion at each step, thus preventing it from considering multiple paths simultaneously.

[0042] In addition, DFS and BFS are also commonly used pathfinding algorithms, but they are not suitable for calculating mutually exclusive paths. The DFS algorithm delves deeper along a path until it cannot expand further, then backtracks to the previous node to search for other paths. The BFS algorithm searches in a hierarchical order, first expanding all neighboring nodes of the current node, then expanding the neighboring nodes of those neighboring nodes. Since both DFS and BFS algorithms expand layer by layer, they need to calculate all possible paths in the topology network and then find two mutually exclusive paths. When the topology network of an electronic device is too large, the efficiency of calculating mutually exclusive paths becomes low. Alternatively, the "pruned successive shortest path" algorithm can be used. First, a shortest path is calculated as the working path. Then, all links belonging to the working path are removed from the network topology graph. Finally, a shortest path is calculated on the pruned network topology as the protection path. That is, the calculated working path and protection path are treated as two mutually exclusive paths. However, the protection path may not be found in the pruned network topology. In summary, the efficiency and reliability of calculating mutually exclusive paths for electronic devices are low.

[0043] In view of this, embodiments of this application provide a method for calculating mutually exclusive paths to improve the efficiency and reliability of electronic devices in calculating mutually exclusive paths. The method includes: obtaining a first shortest path between a source node and a destination node, the first shortest path including M intermediate nodes, M≥0; calculating M+1 candidate paths based on the source node and the M intermediate nodes, each intermediate node corresponding to one candidate path; if there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths; or, if there is no path mutually exclusive with the first shortest path among the M+1 candidate paths, determining two mutually exclusive paths based on a second candidate path, the second candidate path being the shortest path among the M+1 candidate paths.

[0044] Based on the above scheme, after the electronic device obtains M+1 candidate paths based on the source node and M intermediate nodes of the first shortest path, it can determine the mutually exclusive path corresponding to the first shortest path from these M+1 candidate paths. Furthermore, if no mutually exclusive path corresponding to the first shortest path exists among the M+1 candidate paths, the electronic device can continue to match two mutually exclusive paths based on the shortest path among the M+1 candidate paths, without needing to traverse all paths from each node to the destination node, thus avoiding the problem of not finding two mutually exclusive paths. Therefore, this application improves both the efficiency and reliability of calculating mutually exclusive paths.

[0045] The methods provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0046] This application provides a method for calculating mutually exclusive paths. For example... Figure 1 As shown, the method may include S101-S103, or may include S101, S102 and S104:

[0047] S101, The electronic device obtains the first shortest path between the source node and the destination node.

[0048] The first shortest path mentioned above includes M intermediate nodes, where M ≥ 0.

[0049] In one possible implementation, the electronic device can calculate the first shortest path between the source node and the destination node using Dijkstra's algorithm.

[0050] It should be noted that for detailed steps on how electronic devices calculate the first shortest path between the source node and the destination node using Dijkstra's algorithm, please refer to the description of how electronic devices calculate the shortest path between the source node and the destination node using Dijkstra's algorithm in related technologies, which will not be repeated here.

[0051] S102. The electronic device calculates M+1 alternative paths based on the source node and M intermediate nodes.

[0052] Each of the source node and the M intermediate nodes corresponds to an alternative path.

[0053] It is understandable that electronic devices can calculate an alternative path corresponding to the source node, and an alternative path corresponding to each of the M intermediate nodes.

[0054] In one possible implementation, the electronic device calculates M+1 alternative paths based on the source node and M intermediate nodes. This can also be understood as the electronic device calculating M+1 alternative paths based on the nodes in the first shortest path excluding the destination node.

[0055] In some embodiments, the above-mentioned S102 can be specifically implemented by the following S102a and S102b:

[0056] S102a. For any one of the source node and M intermediate nodes, the electronic device uses any one node as an offset point and calculates the second shortest path between any one node and the destination node.

[0057] In one possible implementation, the electronic device can calculate the second shortest path between any node and the destination node using Dijkstra's algorithm.

[0058] S102b: The electronic device calculates the alternative path corresponding to any node based on the second shortest path and the third shortest path from the source node to any node.

[0059] Specifically, the electronic device can take the source node and each of the M intermediate nodes as the deviation point, then traverse each deviation point, and for each deviation point, find the shortest path from the deviation point to the destination node. Then, based on the shortest path from the deviation point to the destination node and the shortest path from the source node to the deviation point, calculate the shortest path corresponding to the deviation point.

[0060] In one possible implementation, the electronic device can combine the second shortest path and the third shortest path to obtain an alternative path for any node.

[0061] For example, if the second shortest path is "0-1-6" and the third shortest path is "6-5", the electronic device can obtain the alternative path corresponding to any node as "0-1-6-5".

[0062] In one possible implementation, for any node, if the electronic device calculates two alternative paths and the costs of the two alternative paths are the same, then the electronic device can choose any one of the paths as the alternative path corresponding to any node.

[0063] S103. If there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, the electronic device determines the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths.

[0064] In one possible implementation, the path that is mutually exclusive with the first shortest path can be understood as: a path that does not share any intermediate nodes with the first shortest path, or a path that does not share any nodes with the first shortest path.

[0065] In one possible implementation, the electronic device determining the first shortest path and the first alternative path as two mutually exclusive paths can be understood as: confirming the first shortest path as the primary path, and confirming the first alternative path as the backup path.

[0066] In one possible implementation, the electronic device determining the first shortest path and the first alternative path as two mutually exclusive paths can be understood as: confirming the first shortest path as the working path, and determining the first alternative path as the protection path.

[0067] In one possible implementation, if there are at least two mutually exclusive paths among the M+1 candidate paths that are mutually exclusive with the first shortest path, the electronic device can use the shortest path among the at least two paths as the first candidate path, and then determine the first shortest path and the first candidate path as two mutually exclusive paths.

[0068] In another possible implementation, if there are at least two mutually exclusive paths with the first shortest path among the M+1 candidate paths, and there are two shortest paths, the electronic device can take either of the two shortest paths as the first candidate path, and then determine the first shortest path and the first candidate path as two mutually exclusive paths.

[0069] In one possible implementation, the two mutually exclusive paths can also be referred to as separate dual paths.

[0070] In some examples, such as paths P1 and P2, if P1 and P2 do not share any common nodes except for the source and destination nodes, then P1 and P2 are called separate dual paths.

[0071] In some embodiments, prior to S103 above, the mutual exclusion path calculation method provided in this application further includes the following S201:

[0072] S201. The first shortest path is matched pairwise with each of the M+1 candidate paths. If the first candidate path and the first shortest path in the M+1 candidate paths do not contain the same intermediate node, the electronic device determines that there is a path in the M+1 candidate paths that is mutually exclusive with the first shortest path.

[0073] It is understandable that the electronic device can compare the first shortest path with each of the M+1 candidate paths. If the intermediate nodes of the first candidate path in the M+1 candidate paths are all different from the intermediate nodes of the first shortest path, the electronic device can determine that there is a path in the M+1 candidate paths that is mutually exclusive with the first shortest path, and can identify the first shortest path and the first candidate path in the M+1 candidate paths that is mutually exclusive with the first shortest path as two mutually exclusive paths.

[0074] For example, when the first shortest path is "0-1-3-5" and the M+1 alternative paths are "0-2-4-5", "0-1-4-5", and "0-1-3-4-5", the electronic device can match the first shortest path "0-1-3-5" with the path "0-2-4-5", match the first shortest path "0-1-3-5" with the path "0-1-4-5", and select the first shortest path "0-1-3-5". After matching with path "0-1-3-4-5", the electronic device knows that the first shortest path "0-1-3-5" and path "0-2-4-5" do not contain the same intermediate nodes. Therefore, the electronic device can determine that there is a path mutually exclusive with the first shortest path "0-1-3-5" among the M+1 candidate paths, and can determine the first shortest path "0-1-3-5" and path "0-2-4-5" as two mutually exclusive paths.

[0075] In some embodiments, the above-mentioned S103 can be specifically implemented by the following S103a and S103b:

[0076] S103a. If there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, the electronic device obtains the cost of the first shortest path and the cost of the first candidate path.

[0077] In one possible implementation, the cost of a path can be understood as the weight of the path (i.e., the distance).

[0078] S103b, if the difference between the cost of the first shortest path and the cost of the first alternative path is less than a preset threshold, the electronic device determines the first shortest path and the first alternative path as two mutually exclusive paths.

[0079] In one possible implementation, the preset threshold can be represented by disparity. The specific threshold can be determined based on actual usage requirements, and this application does not limit this.

[0080] For example: the first shortest path is P1, and the cost of the first shortest path is P1d; the first alternative path is P2, and the cost of the first alternative path is P2d; when |P1d–P2d|≤disparity, the electronic device can determine the first shortest path and the first alternative path as two mutually exclusive paths.

[0081] Based on the above technical solution, after the electronic device obtains the first shortest path, it acquires M+1 candidate paths based on the source node and M intermediate nodes of the first shortest path, and then determines the mutually exclusive path corresponding to the first shortest path from the M+1 candidate paths. Therefore, it does not need to traverse all paths from each node to the destination node, thus improving the efficiency of the electronic device in calculating mutually exclusive paths.

[0082] S104. If there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, the electronic device determines two mutually exclusive paths based on the second candidate path. The second candidate path is the shortest path among the M+1 candidate paths.

[0083] In one possible implementation, the electronic device can perform pairwise matching of the first shortest path with each of the M+1 candidate paths. If each of the M+1 candidate paths contains the same intermediate node as the first shortest path, the electronic device can determine that there is no path among the M+1 candidate paths that is mutually exclusive with the first shortest path.

[0084] For example, when the first shortest path is "0-1-3-5" and the M+1 alternative paths are "0-1-6-3-5", "0-1-4-5", and "0-1-3-4-5", the electronic device can match the first shortest path "0-1-3-5" with the path "0-1-6-3-5", match the first shortest path "0-1-3-5" with the path "0-1-4-5", and match the first shortest path "0-1-3-5" with the path "0-1-3-4-5". After matching, the electronic device knows that the first shortest path "0-1-3-5" contains the same intermediate nodes as paths "0-1-6-3-5", "0-1-4-5", and "0-1-3-4-5". Therefore, the electronic device can determine that there is no path mutually exclusive with the first shortest path "0-1-3-5" among the M+1 candidate paths. Thus, the electronic device can determine two mutually exclusive paths based on the shortest path "0-1-4-5" (i.e., the second candidate path mentioned above) among the M+1 candidate paths.

[0085] In one possible implementation, if there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, the electronic device can first determine a shortest path from the M+1 candidate paths, and then determine two mutually exclusive paths based on the shortest path.

[0086] In one possible implementation, the electronic device can determine the shortest path (i.e., the second alternative path mentioned above) from M+1 candidate paths using Dijkstra's algorithm.

[0087] In one possible implementation, if there are two shortest paths among the M+1 candidate paths, the electronic device can use either of the two shortest paths as the second candidate path.

[0088] In some embodiments, the "electronic device determines two mutually exclusive paths based on the second alternative path" in S104 above can be specifically implemented through the following S104a and S104b:

[0089] S104a: The electronic device obtains N+1 alternative paths based on the source node and the N intermediate nodes of the second alternative path.

[0090] In this context, the source node and each of the N intermediate nodes correspond to an alternative path; N is a positive integer.

[0091] In one possible implementation, the electronic device calculates N+1 alternative paths based on the source node and N intermediate nodes. This can also be understood as the electronic device calculating N+1 alternative paths based on the nodes in the second alternative path, excluding the destination node.

[0092] In one possible implementation, for any one of the N intermediate nodes of the source node and the second alternative path, the electronic device can use any one node as a deviation point to calculate the fourth shortest path between any one node and the destination node. Then, the electronic device can calculate the alternative path corresponding to any one node based on the fourth shortest path and the fifth shortest path between the source node and any one node.

[0093] It should be noted that for the detailed steps of obtaining N+1 alternative paths based on the source node and the N intermediate nodes of the second alternative path of the electronic device, please refer to the description of calculating M+1 alternative paths based on the source node and M intermediate nodes in the above embodiment, which will not be repeated here.

[0094] S104b: The electronic device determines the first sub-path and the second sub-path in the first path set as two mutually exclusive paths.

[0095] The first path set includes: N+1 alternative paths, a second alternative path, and a first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

[0096] It is understandable that after obtaining N+1 alternative paths, the electronic device can determine two mutually exclusive paths that do not contain the same intermediate nodes from the N+1 alternative paths, the second alternative path, and the first shortest path.

[0097] In one possible implementation, the electronic device can perform pairwise matching of all sub-paths in the first path set, and determine the first sub-path and the second sub-path as two mutually exclusive paths if the first sub-path and the second sub-path do not contain the same intermediate node.

[0098] Based on the above technical solution, since the electronic device obtains M+1 candidate paths based on the source node and M intermediate nodes of the first shortest path, if there is no mutually exclusive path corresponding to the first shortest path among the M+1 candidate paths, the electronic device can continue to match two mutually exclusive paths based on the shortest path among the M+1 candidate paths, thus avoiding the problem of not being able to find two mutually exclusive paths. Therefore, this application improves the reliability of calculating mutually exclusive paths.

[0099] This application provides a method for calculating mutually exclusive paths. Since the electronic device obtains M+1 candidate paths based on the source node and M intermediate nodes of the first shortest path, it can determine the mutually exclusive path corresponding to the first shortest path from these M+1 candidate paths. Furthermore, if no mutually exclusive path corresponding to the first shortest path is found among the M+1 candidate paths, the electronic device can continue to match two mutually exclusive paths based on the shortest path among the M+1 candidate paths. This eliminates the need to traverse all paths from each node to the destination node and avoids the problem of not finding two mutually exclusive paths. Therefore, this application improves both the efficiency and reliability of calculating mutually exclusive paths.

[0100] In some embodiments, such as Figure 2 As shown, the mutual exclusion path calculation method provided in this application embodiment may include the following steps S1 to S10.

[0101] S1. Input the source node src, destination node dst, topology graph, and preset threshold disparity into the electronic device.

[0102] In one possible implementation, the topology graph consists of several nodes and lines connecting the nodes, wherein the lines between the connected nodes have a direction, and the weight cost of the line is used to represent the distance between two nodes.

[0103] S2. The electronic device calculates the shortest path from src to dst in the topology graph using Dijkstra's algorithm, and denots it as Pk. Then, Pk is put into set A.

[0104] S3. The electronic device treats each node in the shortest path Pk, except for node dst, as an deviation point and denots it as Vi. Then, it traverses each deviation point and calculates the shortest path from deviation point Vi to dst for each deviation point using Dijkstra's algorithm.

[0105] In one possible implementation, i∈[1,x], where x is the number of deviation points.

[0106] S4. For each deviation point, the electronic device combines the shortest path from src to deviation point Vi and the shortest path from deviation point Vi to dst to obtain the alternative path corresponding to each deviation point, and puts the alternative path corresponding to each deviation point into set B.

[0107] In one possible implementation, the alternative path corresponding to each deviation point can also be understood as: the candidate path corresponding to each deviation point.

[0108] In some examples, assuming that the shortest path from src to dst is calculated to be P1, and there is another shortest or second shortest path from src to dst, P2, then P2 is called a candidate path of P1.

[0109] S5. The electronic device determines whether set B is empty.

[0110] If set B is empty, the process ends; if set B is not empty, the electronic device executes S6.

[0111] It is understandable that if set B is empty, the electronic device can determine that there is no mutually exclusive path that meets the conditions, and the process ends.

[0112] S6. The electronic device determines whether there is a mutually exclusive path in the union of set A and set B.

[0113] If a mutually exclusive path exists, the electronic device executes S7 and S9; if no mutually exclusive path exists, the electronic device executes S8.

[0114] S7. The electronic device calculates the difference d between the weights of two mutually exclusive paths.

[0115] S8. The electronic device determines the shortest path from set B and denotes it as Pk. Then, it puts Pk into set A and removes it from set B.

[0116] After executing S8, the electronic device continues to execute S3 in a loop.

[0117] S9. The electronic device determines whether the difference d is ≤ disparity.

[0118] If the difference d ≤ disparity, the electronic device executes S10; if the difference d > disparity, the electronic device executes S8.

[0119] S10. The electronic device uses mutually exclusive paths in the union of set A and set B as separate dual paths.

[0120] It should be noted that the relevant descriptions of steps S1 to S10 can be found in the above embodiments, and will not be repeated here.

[0121] Example 1, with Figure 3 Taking the topology graph shown below as an example, an electronic device can take src=0, dst=5, disparity=3 as input:

[0122] 1. The electronic device calculates the shortest path A[1] using Dijkstra's algorithm: "0-1-3-5", and adds A[1] to set A;

[0123] 2. The electronic device takes A[1] as the iteration path and begins to traverse the offset points:

[0124] (1) Using node "0" (i.e., the source node mentioned above) as the offset point, set the weight between path "0-1" to infinity, and perform Dijkstra's algorithm once to obtain path A^2-1: "0-2-4-5".

[0125] (i.e., the first shortest path mentioned above), with a cost of 3, and add path A^2-1 to set B;

[0126] (2) Using node “1” as the offset point, set the weight between path “1-3” to infinity, perform Dijkstra once to obtain path A^2-2: “0-1-4-5”, with a cost of 3, and add path A^2-2 to set B;

[0127] (3) Using node “3” as the offset point, set the weight between path “3-5” to infinity, perform Dijkstra once to obtain path A^2-3: “0-1-3-4-5”, with a cost of 4, and add path A^2-3 to set B;

[0128] 3. After the offset point traversal is completed, there are four paths in sets A and B: “0-1-3-5”, “0-2-4-5”, “0-1-4-5”, and “0-1-3-4-5”. The electronic device performs pairwise matching on the four paths and determines that paths “0-1-3-5” and “0-2-4-5” are mutually exclusive paths. Furthermore, the difference in cost between the two paths is 0, and 0 < 3 (i.e., the input disparity). Therefore, the electronic device can return the separated dual routes “0-1-3-5” and “0-2-4-5”, and the program ends.

[0129] Example 2, with Figure 3 Using the topology graph shown below as an example, an electronic device can take src=0, dst=6, disparity=3 as input:

[0130] 1. The electronic device calculates the shortest path A[1]: "0-1-6" using Dijkstra's algorithm and adds A[1] to set A;

[0131] 2. The electronic device takes A[1] as the iteration path and begins to traverse the offset points:

[0132] (1) Using node “0” as the offset point, set the weight between path “0-1” to infinity, perform Dijkstra once to obtain path A^2-1: “0-2-1-6”, with a cost of 3, and add path A^2-1 to set B;

[0133] (2) Using node “1” as the offset point, set the weight between path “1-6” to infinity, perform Dijkstra once to obtain path A^2-2: “0-1-3-6”, with a cost of 3, and add path “A^2-2” to set B;

[0134] 3. After the offset point traversal is completed, there are three paths in set A and set B: "0-1-6", "0-2-1-6" and "0-1-3-6". The electronic device performs pairwise matching on the three paths to determine that there are no mutually exclusive paths, and the process continues.

[0135] 4. The electronic device puts the path "0-2-1-6" (i.e. the second alternative path mentioned above) with the least cost in set B into set A as A[2], and removes it from set B.

[0136] 5. The electronic device uses A[2] "0-2-1-6" as the iteration path and begins to traverse the offset points:

[0137] (1) Using node “0” as the offset point, set the weight between path “0-2” to infinity and perform Dijkstra once to obtain path A^3-1: “0-1-6”. However, the set B already has this path, so there is no offset path.

[0138] (2) Using node “2” as the offset point, set the weight between path “2-1” to infinity, perform Dijkstra once to obtain path A^3-2: “0-2-4-3-6”, with a cost of 4, and add path A^3-2 to set B;

[0139] (3) Using node “1” as the offset point, set the weight between path “1-6” to infinity, perform Dijkstra once to obtain path A^2-3: “0-1-4-3-6”, with a cost of 4, and add path A^3-3 to set B;

[0140] 6. After the offset point traversal is complete, there are a total of 5 paths in set A and set B: "0-1-6", "0-2-1-6", "0-1-3-6", "0-2-4-3-6", and "0-1-4-3-6". The electronic device performs pairwise matching on the five paths and determines that the paths "0-1-6" and "0-2-4-3-6" are mutually exclusive paths. Furthermore, the difference in cost between the two paths is 2, and 2 < 3 (i.e., the input disparity). Therefore, the electronic device can return the separated dual routes "0-1-6" and "0-2-4-3-6", and the program ends.

[0141] In the embodiments of this application, the time complexity of the mutual exclusion path calculation method provided in this application depends on the number of nodes traversed and the time required for each Dijkstra's algorithm to calculate the shortest path. Let the number of nodes be n and the variable be m. The time complexity of the heap-optimized Dijkstra's algorithm is O((V+E)logV). In the best case, this method calculates two shortest paths to satisfy the separation of two paths, thus the time complexity is 2*O((V+E)logV). In the worst case, this method traverses all nodes and edges before finally finding the separation of two paths, thus the time complexity is O(V+E)*O((V+E)logV).

[0142] The various solutions in the above embodiments of this application can be combined without contradiction.

[0143] This application embodiment can divide the mutual exclusion path calculation device into functional modules or functional units according to the above method example. For example, each function can be divided into a separate functional module or functional unit, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or in software functional modules or functional units. The module or unit division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0144] When dividing each function into modules according to its corresponding function. Figure 4 A schematic diagram of a mutual exclusion path calculation device 70 is shown. The mutual exclusion path calculation device 70 can be an electronic device or a chip applied to an electronic device. The mutual exclusion path calculation device 70 can be used to perform the functions of the electronic device involved in the above embodiments. Figure 4 The mutual exclusion path calculation device 70 shown may include: an acquisition unit 701, a calculation unit 702, and a determination unit 703.

[0145] The acquisition unit 701 is used to acquire the first shortest path between the source node and the destination node. The first shortest path includes M intermediate nodes, where M≥0.

[0146] The calculation unit 702 is used to calculate M+1 candidate paths based on the source node and the M intermediate nodes included in the first shortest path obtained by the acquisition unit 701. Each intermediate node in the source node and the M intermediate nodes corresponds to a candidate path.

[0147] Determine unit 703, used for:

[0148] If among the M+1 candidate paths there exists a path mutually exclusive with the first shortest path, then the first shortest path and the first candidate path mutually exclusive with the first shortest path are determined as two mutually exclusive paths; or,

[0149] If there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, two mutually exclusive paths are determined based on the second candidate path. The second candidate path is the shortest path among the M+1 candidate paths.

[0150] In one possible implementation, the aforementioned calculation unit 702 is specifically used to calculate the second shortest path between the source node and any one of the M intermediate nodes, taking any one node as an offset point; and to calculate the alternative path corresponding to any node based on the second shortest path and the third shortest path between the source node and any one node.

[0151] In one possible implementation, the determining unit 703 is further configured to, in the case where there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, before determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths, perform pairwise matching of the first shortest path with each of the M+1 candidate paths, and determine that there is a path mutually exclusive with the first shortest path among the M+1 candidate paths if there is no common intermediate node between the first candidate path and the first shortest path.

[0152] In one possible implementation, the acquisition unit 701 is further configured to acquire the cost of the first shortest path and the cost of the first candidate path when there is a path mutually exclusive with the first shortest path among the M+1 candidate paths. The determination unit 703 is specifically configured to determine the first shortest path and the first candidate path as two mutually exclusive paths when the difference between the cost of the first shortest path and the cost of the first candidate path acquired by the acquisition unit is less than a preset threshold.

[0153] In one possible implementation, the acquisition unit 701 is further configured to acquire N+1 candidate paths based on the source node and the N intermediate nodes of the second candidate path, where each intermediate node in the source node and the N intermediate nodes corresponds to a candidate path; N is a positive integer. The determination unit 703 is specifically configured to determine the first sub-path and the second sub-path in the first path set as two mutually exclusive paths; wherein the first path set includes: N+1 candidate paths, the second candidate path, and the first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

[0154] As another feasible approach Figure 4The acquisition unit 701, calculation unit 702 and determination unit 703 in the process can be replaced by a processor that can integrate the functions of the acquisition unit 701, calculation unit 702 and determination unit 703.

[0155] This application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be implemented by a computer program instructing related hardware. This program can be stored in the computer-readable storage medium, and when executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be an internal storage unit of the mutual exclusion path computing device in any of the foregoing embodiments, such as the hard disk or memory of the mutual exclusion path computing device. The computer-readable storage medium can also be an external storage device of the terminal device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device. Further, the computer-readable storage medium can include both the internal storage unit of the mutual exclusion path computing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the mutual exclusion path computing device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0156] It should be noted that the terms "first" and "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0157] It should be understood that in this application, "at least one (item)" means one or more, "more than one" means two or more, "at least two (items)" means two or three or more, and "and / or" is used to describe the relationship between related objects, indicating that there can be three relationships. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the related objects before and after are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0158] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0159] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0160] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0161] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0162] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0163] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for calculating mutually exclusive paths, characterized in that, Applied to electronic devices, the method includes: Obtain the first shortest path between the source node and the destination node, where the first shortest path includes M intermediate nodes, M≥0; Based on the source node and the M intermediate nodes, M+1 alternative paths are calculated, where each of the source node and the M intermediate nodes corresponds to one alternative path. If among the M+1 candidate paths there exists a path mutually exclusive with the first shortest path, then the first shortest path and the first candidate path mutually exclusive with the first shortest path are determined as two mutually exclusive paths; or, If there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, two mutually exclusive paths are determined based on the second candidate path, and the second candidate path is the shortest path among the M+1 candidate paths. Based on the source node and the M intermediate nodes, M+1 alternative paths are calculated, including: For any one of the source node and the M intermediate nodes, take that any one node as an offset point and calculate the second shortest path between that any one node and the destination node; Based on the second shortest path and the third shortest path from the source node to any node, the alternative paths corresponding to any node are calculated. The determination of two mutually exclusive paths based on the second alternative path includes: Based on the source node and the N intermediate nodes of the second alternative path, obtain N+1 alternative paths, where each intermediate node in the source node and the N intermediate nodes corresponds to an alternative path; N is a positive integer. The first sub-path and the second sub-path in the first path set are determined to be two mutually exclusive paths. The first path set includes: the N+1 alternative paths, the second alternative path, and the first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

2. The method according to claim 1, characterized in that, Before determining the first shortest path and the first candidate path mutually exclusive with the first shortest path as two mutually exclusive paths when there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, the method further includes: The first shortest path is matched pairwise with each of the M+1 candidate paths. If the first candidate path and the first shortest path do not share any intermediate nodes, it is determined that there exists a path in the M+1 candidate paths that is mutually exclusive with the first shortest path.

3. The method according to claim 1 or 2, characterized in that, When there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, the first shortest path and the first candidate path mutually exclusive with the first shortest path are determined as two mutually exclusive paths, including: If there is a path mutually exclusive with the first shortest path among the M+1 candidate paths, obtain the cost of the first shortest path and the cost of the first candidate path. If the difference between the cost of the first shortest path and the cost of the first alternative path is less than a preset threshold, the first shortest path and the first alternative path are determined as two mutually exclusive paths.

4. A mutually exclusive path calculation device, characterized in that, Applied to electronic devices, the device includes: The acquisition unit is used to acquire the first shortest path between the source node and the destination node, wherein the first shortest path includes M intermediate nodes, M≥0; The calculation unit is used to calculate M+1 candidate paths based on the source node and the M intermediate nodes included in the first shortest path obtained by the acquisition unit, wherein each intermediate node in the source node and the M intermediate nodes corresponds to a candidate path. Determine the unit, used for: If among the M+1 candidate paths there exists a path mutually exclusive with the first shortest path, then the first shortest path and the first candidate path mutually exclusive with the first shortest path are determined as two mutually exclusive paths; or, If there is no mutually exclusive path with the first shortest path among the M+1 candidate paths, two mutually exclusive paths are determined based on the second candidate path, and the second candidate path is the shortest path among the M+1 candidate paths. The calculation unit is specifically used to calculate the second shortest path from the source node to the destination node, taking the source node and any one of the M intermediate nodes as the deviation point; and to calculate the alternative path corresponding to the source node based on the second shortest path and the third shortest path from the source node to the destination node. The acquisition unit is further configured to acquire N+1 alternative paths based on the source node and the N intermediate nodes of the second alternative path, wherein each intermediate node of the source node and the N intermediate nodes corresponds to an alternative path; N is a positive integer; The determining unit is specifically used to determine the first sub-path and the second sub-path in the first path set as two mutually exclusive paths. The first path set includes: the N+1 alternative paths, the second alternative path, and the first shortest path; the first sub-path and the second sub-path do not contain the same intermediate nodes.

5. A computer-readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed, implement the method as described in any one of claims 1-3.

6. A mutually exclusive path calculation device, characterized in that, include: The processor, memory, and communication interface; wherein the communication interface is used for communication of the mutual exclusion path computing device; The memory is used to store one or more programs, the one or more programs including computer-executable instructions. When the mutex path computing device is running, the processor executes the computer-executable instructions stored in the memory to cause the mutex path computing device to perform the method according to any one of claims 1-3.