Path updating and equivalent path planning method and related device under dynamic network
By improving the Dijkstra algorithm and Single-Change update algorithm, the high time complexity and redundant calculation problems of path updates in dynamic networks are solved, fast and effective equivalent path planning is achieved, and the calculation time is reduced to 1/5 of the original algorithm.
Patent Information
- Application Number
- CN202310360250.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-03-31
AI Technical Summary
When updating paths in dynamic networks, existing technologies have problems such as high time complexity of traversing the adjacency matrix, inability to quickly and effectively determine the affected areas, and excessive redundant calculations. Especially when the network topology changes slightly, the Dijkstra algorithm cannot obtain all equivalent paths.
The improved Dijkstra algorithm and Single-Change update algorithm are adopted. By obtaining network graph information and edge operation set, the Dijkstra algorithm is improved to calculate multiple equivalent parent nodes, reducing the time of calculating equivalent paths, and the improveDijkstra algorithm is improved to calculate the shortest path for all pairs, reducing the calculation time.
The calculation time of the optimal path is significantly shortened, redundant calculations are reduced, and the network service quality is improved. The calculation time is about 1/5 of the original Dijkstra algorithm.
Smart Images

Figure CN116366538B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of solving the shortest path using a local search method, and particularly relates to a path updating and equivalent path planning method and related devices in a dynamic network. Background Art
[0002] In typical link-state routing protocols such as Open Shortest Path First (OSPF) and Intermediate System-to-Intermediate System (IS-IS), the classic Dijkstra algorithm is often used to construct a shortest path tree (SPT) for each router, with itself as the source. However, even with minor changes in the network topology, this method requires recalculating multiple SPTs. This approach not only wastes a large amount of prior knowledge but also takes a long time in large-scale networks, making it impossible to guarantee quality of service (QoS). Furthermore, multiple shortest paths may exist for each router in the network. These equal-cost paths play an important role in network congestion, but the Dijkstra algorithm can only calculate a single optimal path and cannot obtain all equal-cost paths. Current challenges include:
[0003] (1) The input of the classical algorithm is mostly the adjacency matrix. However, in the algorithm implementation, the time complexity of looping through the adjacency matrix is very high, making it difficult to effectively store network information.
[0004] (2) It is impossible to quickly and effectively determine the affected areas when the network topology changes, especially the sites affected by edge deletion operations;
[0005] (3) In the process of updating the affected nodes, there are many redundant calculations. Summary of the Invention
[0006] The purpose of the present invention is to provide a path update and equivalent path planning method and system in a dynamic network to solve the problems of very high time complexity of traversing the adjacency matrix, inability to quickly and effectively determine the affected area, and a large number of redundant calculations.
[0007] To achieve the above object, the present invention adopts the following technical solutions:
[0008] The path updating and equivalent path planning method in a dynamic network includes the following steps:
[0009] Obtain n shortest path trees T based on Dijkstra algorithm sk Storage structure, edge weights, and changing edge set ΔEk+1 Update the shortest path between any two points at time k+1, and obtain the network graph information and edge operation set at time k+1;
[0010] Improve the Dijkstra algorithm to calculate multiple equivalent parent nodes, so that it can calculate all optimal paths between any two points at time k+1, and improve the Single-Change update algorithm to calculate equivalent parent nodes, reducing the time to calculate equivalent paths;
[0011] The above improved Dijkstra algorithm only calculates all equivalent parent nodes, which is not conducive to the calculation of equivalent paths. Therefore, it involves improving the improved Dijkstra algorithm to calculate the shortest path for all pairs, so that it can borrow the information from the source point to other nodes obtained before, thereby reducing the time of calculating the shortest path for each pair.
[0012] G k (V k , E k ) is a directed weighted graph at time k, T sk It is the shortest path tree with s as the source point obtained by Dijkstra algorithm at time k, where s∈V k , ΔE k+1 Represents the set of edge changes from time k to time k+1. This set contains six subsets, including the inserted edge set AddE k+1 and delete edge set DelE k+1 , add node set AddN k+1 and delete node set DelN k+1 , and increase the weight set IncE k+1 , reduce the weight set DecE k+1 .
[0013] Furthermore, obtaining the network graph information and edge operation set at time k+1 specifically includes:
[0014] The adjacency matrix of the network graph is stored in two dictionaries, including the out-degree information and in-degree information of the graph. For the six edge operations that may occur in the routing network: edge weight reduction, edge insertion, vertex insertion, edge weight increase, edge deletion, and vertex deletion, an edge operation set detaEs is defined. This set includes three forms:
[0015] 1) [node1, node2, w, True] means that the weight between node1 and node2 is reduced to w or a link node1→node2 is added with weight w. If node1 is a newly inserted site, then [node1, node2, w, True] means inserting site node1 and adding a link node1→node2 with weight w. The new site is added to nameSet and the new site information is added to outGraph and inGraph.
[0016] 2) [node1, node2, w, False] means the weight between node1 and node2 is increased to w or the link node1→node2 is deleted (in this case w=inf);
[0017] 3) [node, -1] means deleting the site node, which is specifically implemented by deleting all links connected to the site.
[0018] Furthermore, we can obtain the out-degree matrix outGraph and in-degree matrix inGraph of the network:
[0019] Step 1: Read data: Read data from the Excel spreadsheet, loop through the source and destination sites, and store all different sites in the list nameSet in the order they were read. This list contains all the site names in the network diagram.
[0020] Step 2: Output matrix: Loop through the station names in nameSet, set the source and destination points in the data to the station, find all points with the station as the tail node and the station as the head node, and record the neighbor nodes of each station in the dictionary outGraph and dictionary inGraph in the form of {node: weight} in the order of nameSet. If there is no corresponding connection, the weight is recorded as INF.
[0021] Furthermore, the improvement of the Single-Change update algorithm specifically includes:
[0022] The algorithm processes one edge operation at a time, including edge insertion / deletion, edge weight increase / decrease, and vertex addition / deletion. Inserting an edge is equivalent to reducing the weight, that is, reducing the infinite edge weight to a fixed value; deleting an edge is equivalent to increasing the weight, that is, increasing the edge weight with a fixed value to infinity; inserting a vertex is equivalent to inserting an edge connected to the vertex, and deleting a vertex is equivalent to deleting all edges connected to the vertex. It can be summarized as: edge insertion operation and edge deletion operation.
[0023] Furthermore, when inserting edge e(x, y): determine the relationship between dist(y) and dist(x)+W(x, y) to determine whether node y is affected; if dist(y)≤dist(x)+W(x, y), node y is not affected by the inserted edge and does not need to be updated; if dist(y)>dist(x)+W(x, y), the current distance of node y is not the optimal distance and an update is performed; at this time, all subtrees with y as the root node are affected, define a priority queue and put y into the queue, and apply the Dijkstra algorithm based on the priority queue to update the subtree;
[0024] Delete edge e(x, y): First, determine whether the parent node of node y is x. There are two cases for discussion: If the original len(path(y)) is equal to 1, it means that node y is an isolated point in the SPT. Deleting the edge has no effect on the SPT tree and does not need to be updated; if the original len(path(y)) is greater than 1 but the parent node of node y, path(y)[-2], is not node x, deleting the edge also has no effect on the SPT and does not need to be updated; if the above two cases are not true, then the deleted edge e(x, y) in the SPT will affect all nodes in the subtree with node y as the root. At this time, all nodes in the network are traversed according to the judgment criterion y in path(n), and the affected points are placed in the priority queue; then the affected nodes in the priority queue are updated with the in-degree matrix inGraph, and the updated nodes must also update their neighbor nodes again, otherwise the final result will not be the global optimal solution.
[0025] Furthermore, the Dijkstra algorithm is improved to calculate multiple equivalent parent nodes, specifically including:
[0026] The Dijkstra algorithm based on priority queue only considers iterative updates when dist(y)>dist(x)+W(x, y), and does not consider equivalent parent nodes where dist(y)=dist(x)+W(x, y); initially, parent node parent[y]=[y] is set for each node y. During iterative updates, if dist(y)>dist(x)+W(x, y), update parent[y]=[x]; if dist(y)=dist(x)+W(x, y), add equivalent parent node parent[y].append(x); if the dist from y to the source point is continued to be updated by node z during the next iterative update, then its parent[y]=[z], and it is restored to a single parent node.
[0027] Furthermore, the Single-Change update algorithm is improved to calculate equivalent parent nodes, specifically including:
[0028] The improved Single-Change algorithm is based on the improved Dijkstra algorithm to update equivalent parent nodes. The algorithm is also divided into insert-side update and delete-side update:
[0029] For the operation of inserting edge e(x, y), if dist(y) < dist(x) + W(x, y), then deleting the edge has no effect and no update is required; if dist(y) = dist(x) + W(x, y) and node x is not in parent[y], then node x is the equivalent parent node of node y, parent[y].append(x); if dist(y) > dist(x) + W(x, y), all subtrees with y as the root node are affected, and the affected points are updated according to the improved Dijkstra algorithm;
[0030] For the operation of deleting an edge e(x, y), if node x is not in parent[y], then the edge deletion operation has no effect on the SPT and does not need to be updated; if node x is in parent[y] but len(parent[y])>1, it means that node y already has multiple equivalent parent nodes. In this case, you only need to remove the parent node x and the update is complete; if neither of the above two situations is true, it means that node y has only one parent node x. In this case, all subtrees with y as the root node are affected. At this time, you need to consider whether all neighbor nodes with node y as the out-degree are affected. The evaluation criteria are: for nodes with multiple equivalent parent nodes, you only need to remove the deleted parent node without re-updating; based on this, all affected points are placed in the priority queue; when updating the affected nodes, the Single-Change update process and the improved Dijkstra algorithm are combined for update;
[0031] Nodes with multiple equivalent parent nodes are screened out, and then the paths corresponding to the parent nodes are extracted from the paths calculated by the original Dijkstra algorithm to obtain multiple equivalent paths of the corresponding nodes.
[0032] Furthermore, the improveDijkstra algorithm is improved to calculate the shortest path for all pairs, specifically including:
[0033] Improve the data initialization and iteration parts of the n-loop Dijkstra algorithm, so that the time of calculating the shortest path of all pairs is greatly reduced. Specifically:
[0034] In the data initialization part, each time the current shortest distance of all nodes needs to be assigned to 0 and the shortest path to [node], and the time spent on repeating n times is O(n 2), the collections.defaultdict() package in Python is used to reduce the time of data initialization; in the iteration part, the original Dijkstra algorithm uses the same iterative process each time, and uses labels to mark the calculated source points. If an intermediate point has been calculated during the iteration process, it is directly called.
[0035] Furthermore, the path updating and equivalent path planning system under the dynamic network includes:
[0036] Network graph information and edge operation set acquisition module, used to obtain n shortest path trees T based on Dijkstra algorithm sk Storage structure, edge weights, and changing edge set ΔE k+1 Update the shortest path between any two points at time k+1, and obtain the network graph information and edge operation set at time k+1;
[0037] Algorithm improvement module, used to improve Dijkstra algorithm to calculate multiple equivalent parent nodes, so that it can calculate all optimal paths between any two points at time k+1, and improve Single-Change update algorithm to calculate equivalent parent nodes, reducing the time of calculating equivalent paths;
[0038] The shortest path acquisition module is used to improve the improveDijkstra algorithm to calculate the shortest path for all pairs, so that it can borrow the information from the source point to other nodes obtained previously, thereby reducing the time for calculating the shortest path for each pair.
[0039] Furthermore, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the path update and equivalent path planning method in a dynamic network are implemented.
[0040] Furthermore, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the path updating and equivalent path planning method in a dynamic network are implemented.
[0041] Compared with the prior art, the present invention has the following technical effects:
[0042] The update algorithm designed by the present invention only needs to update the affected nodes. Compared with the existing Dijkstra algorithm in the industry, the Single Change update algorithm designed by the present invention runs in 1 / 50 of the time of the existing algorithm in the industry, greatly shortening the calculation time of the optimal path.
[0043] The existing update algorithm, Dynamic-Dijkstra, considers significant changes in the network structure by directly identifying and updating all affected nodes at once. However, this results in a large number of redundant calculations for minor changes in the topology. The update algorithm designed in this paper targets minor changes, performing only one update operation at a time. The overall number of operations required to determine affected nodes is less than that of the Dynamic-Dijkstra algorithm. Results show that the Single Change algorithm reduces the time required for edge insertion, weight reduction, and node deletion by approximately 0.1-0.2ms.
[0044] The existing parallel algorithm was originally designed to accelerate calculations by leveraging existing parallel platforms. However, the two operations of determining and updating affected points are not completely independent, so for sparse graphs, the time consumed is relatively long. The SingleChange algorithm designed in this invention uses serial calculations, and the affected points are not repeatedly calculated after being determined, resulting in significantly better time complexity. The results are shown in Tables 1 and 2.
[0045] The original Dijkstra algorithm does not utilize the existing information of the previously calculated SPT when calculating the optimal path in the routing network, resulting in a large amount of redundant calculations. The improved Dijkstra algorithm designed by the present invention improves the initialization and iteration parts. During the iterative calculation, the calculated SPT is marked and directly used when the same node appears later, effectively reducing repeated calculations. The final calculation time is 1 / 5 of the original Dijkstra algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 The time consumption of the four algorithms of reducing weight and increasing weight in small-scale networks;
[0047] Figure 2 The time consumption of four algorithms for inserting edges and deleting edges in small-scale networks;
[0048] Figure 3 The time consumption of four algorithms for inserting and deleting vertices in a small-scale network;
[0049] Figure 4 The time consumption of the three algorithms of reducing weight and increasing weight in large-scale networks;
[0050] Figure 5 The time consumption of three algorithms for inserting edges and deleting edges in large-scale networks;
[0051] Figure 6 The time consumption of three algorithms for inserting and deleting vertices in large-scale networks. DETAILED DESCRIPTION
[0052] The present invention is further described below with reference to the accompanying drawings:
[0053] The purpose of the present invention is to provide a path update and equivalent path planning method and related devices in a dynamic network, an equivalent path solving algorithm and an improved Dijkstra algorithm for solving the shortest path, so as to accelerate the calculation of the shortest path tree in a dynamic network and ensure the quality of service.
[0054] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions.
[0055] Get the network graph information and edge operation set at time k+1
[0056] Considering the sparse nature of routing networks, this paper stores the adjacency matrix of the network graph in two dictionaries, including the out-degree information and in-degree information of the graph. In addition, the six possible edge operations in the routing network are defined, with the following details:
[0057] Handle outliers. For multiple data points with different weights for the same link, only one is retained. For data points with a weight of 0 between different sites, a fixed non-zero weight is assigned to them.
[0058] Get the out-degree matrix outGraph and in-degree matrix inGraph of the network.
[0059] Step 1: Read data: Read data from the Excel spreadsheet, loop through the source and destination sites, and store all different sites in the list nameSet in the order they were read. This list stores all the site names in the network diagram.
[0060] Step 2: Output matrix: Loop through the station names in nameSet, set the source and destination points in the data to the station, find all the points with the station as the tail node and the point with the station as the head node, and record the neighbor nodes of each station in the dictionary outGraph and dictionary inGraph in the form of {node: weight} according to the order in nameSet. If there is no corresponding connection, the weight is recorded as INF;
[0061] To meet the dynamic needs of routing networks, the new algorithm needs to be applicable to six scenarios: adding or deleting sites / links, increasing or decreasing weights, and defining a set of edge changes, detaEs, in three storage formats.
[0062] [node1, node2, w, True] means that the weight between node1 and node2 is reduced to w or a link node1→node2 is added with weight w. If node1 is a newly inserted site, then [node1, node2, w, True] means inserting site node1 and adding a link node1→node2 with weight w. The new site is added to nameSet and the new site information is added to ourGraph and inGraph.
[0063] [node1, node2, w, False] means the weight between node1 and node2 is increased to w or the link node1→node2 is deleted (in this case w=inf);
[0064] [node, -1] means deleting the site node. Specifically, it deletes all links connected to the site.
[0065] Designing a Single-Change Update Algorithm
[0066] Most operations in routing networks involve single-edge operations: inserting, deleting, or decreasing or increasing the weight of a single edge. Considering that single-edge operations require the shortest time, the present invention designs a Single-Change algorithm. As the name suggests, this algorithm processes only one edge operation at a time. To address the three challenges mentioned above, this algorithm designs the following measures:
[0067] For problem (1), when obtaining the initial information, the network topology information is stored in two dictionaries. The first dictionary stores the out-degree information of the network sites, and the second dictionary stores the in-degree information of the network sites.
[0068] For problem (2), a series of judgment criteria are designed to make decisions and deal with the affected points;
[0069] For problem (3), the idea of iterative updating is adopted to update the affected points so that they gradually converge to the optimal path.
[0070] Algorithm Overview: This algorithm processes one edge operation at a time, including edge insertion / deletion, edge weight increase / decrement, and vertex addition / deletion. Inserting an edge is equivalent to decreasing the weight, reducing an infinite edge weight to a fixed value; deleting an edge is equivalent to increasing the weight, increasing a fixed edge weight to infinity. Inserting a vertex is equivalent to inserting an edge connected to that vertex, and deleting a vertex is equivalent to deleting all edges connected to that vertex. Therefore, all operations can be summarized as: edge insertion and edge deletion.
[0071] Insert edge e(x, y): Determine the relationship between dist(y) and dist(x)+W(x, y) to determine whether node y is affected. If dist(y)≤dist(x)+W(x, y), node y is not affected by the inserted edge and does not need to be updated; if dist(y)>dist(x)+W(x, y), the current distance of node y is not the optimal distance and can be updated. At this time, all subtrees with y as the root node are affected. Define a priority queue and add y to the queue. Apply the Dijkstra algorithm based on the priority queue to update the subtree.
[0072] Deleting an edge e(x, y): First, determine whether node y's parent is x. Two cases are considered: If the original len(path(y)) is equal to 1, node y is an outlier in the SPT. Deleting the edge has no effect on the SPT tree and no update is required. If the original len(path(y)) is greater than 1, but node y's parent, path(y)[-2], is not x, deleting the edge also has no effect on the SPT tree and no update is required. If neither of these two cases holds, then the deleted edge e(x, y) in the SPT affects all nodes in the subtree rooted at node y. In this case, all nodes in the network are traversed according to the criterion y in path(n), and the affected nodes are placed in a priority queue. The affected nodes in the priority queue are then updated using the in-degree matrix inGraph. The updated nodes must also update their neighboring nodes, otherwise the final solution will not be globally optimal.
[0073] This algorithm is advantageous in scenarios with relatively few edge operations. Each edge operation directly affects only one node, requiring only the update of the subtree rooted at that node. This means that the scope of a single update is small, making it particularly advantageous for sparse graphs. However, it also has drawbacks: applying it to dense graphs and multiple edge operations results in a significant amount of redundant computation. For multiple edge operations, the algorithm treats them as a sequential update sequence.
[0074] Improved Dijkstra algorithm to calculate multiple equivalent parent nodes
[0075] The Dijkstra algorithm based on the priority queue only considers iterative updates when dist(y)>dist(x)+W(x, y), and does not consider equivalent parent nodes where dist(y)=dist(x)+W(x, y). The present invention improves the Dijkstra algorithm based on the priority queue. Initially, a parent node parent[y]=[y] is set for each node y. During iterative updates, if dist(y)>dist(x)+W(x, y), parent[y]=[x] is updated; if dist(y)=dist(x)+W(x, y), an equivalent parent node parent[y].append(x) is added. If the dist from y to the source point can be continued to be updated by node z during the next iterative update, then its parent[y]=[z], restoring to a single parent node.
[0076] Single-Change algorithm updates and calculates equivalent parent nodes
[0077] The original Single-Change algorithm is based on the Dijkstra algorithm for updates. Similarly, the improved Single-Change algorithm is based on the improved Dijkstra algorithm for updating equivalent parent nodes. This algorithm is also divided into insert-side update and delete-side update. The basic idea is:
[0078] For the operation of inserting the edge e(x, y), if dist(y) < dist(x) + W(x, y), then deleting the edge has no effect and no update is required; if dist(y) = dist(x) + W(x, y) and node x is not in parent[y], then node x is the equivalent parent node of node y, parent[y].append(x); if dist(y) > dist(x) + W(x, y), all subtrees with y as the root node are affected, and the affected points are updated according to the improved Dijkstra algorithm.
[0079] For the edge deletion operation e(x, y), if node x is not in parent[y], the edge deletion operation has no effect on the SPT and no update is required. If node x is in parent[y] but len(parent[y]) > 1, it indicates that node y already has multiple equivalent parents. In this case, simply remove parent x and the update is complete. If neither of the above two situations is true, it indicates that node y has only one parent x. In this case, all subtrees with y as the root node are affected. At this time, it is necessary to consider whether all neighbor nodes with node y as the out-degree are affected. The evaluation criterion is: for nodes with multiple equivalent parents, only the deleted parent node needs to be removed without re-updating. Based on this, all affected nodes are placed in a priority queue. When updating affected nodes, the Single-Change update process is combined with the improved Dijkstra algorithm for update.
[0080] For the improved Dijkstra algorithm and Single-Change algorithm, the final result is the shortest distance between two nodes and the equivalent parent nodes. This method can be combined with the original Dijkstra algorithm or Single-Change algorithm. First, the nodes with multiple equivalent parent nodes are filtered out, and then the paths corresponding to the parent nodes are extracted from the paths calculated by the original Dijkstra algorithm. Multiple equivalent paths of the corresponding nodes can be obtained.
[0081] ImproveDijkstra algorithm to calculate all-pairs shortest path
[0082] The Dijkstra algorithm can only obtain the shortest distance and path from the source point s to the remaining vertices. To obtain the shortest distance and path between every two nodes, it is necessary to traverse the Dijkstra algorithm n times, which is not only inefficient but also wastes a lot of previously obtained information. Therefore, the present invention improves the Dijkstra algorithm method for solving the all-pairs shortest path to obtain less calculation time.
[0083] Looking at the n-time Dijkstra algorithm, the areas that can be improved are the data initialization part and the iteration part: in the data initialization part, each time the current shortest distance of all nodes needs to be assigned to 0 and the shortest path to [node], and the time spent on repeating n times is O( 2 ), the present invention uses the collections.defaultdict() package in Python to reduce the time of data initialization; in the iteration part, the original Dijkstra algorithm uses the same iterative process each time, and the present invention uses labels to mark the calculated source points. If an intermediate point appears in the iterative process that has been calculated, it can be directly called.
[0084] Experimental data
[0085] The present invention conducts experiments on two sets of data sets, where the small-scale data set includes 345 sets of data and 252 sites; the large-scale data set includes 13,483 sets of data and 8,929 sites. In addition, when testing the improved Dijkstra algorithm to calculate the shortest path of all pairs, three sets of virtual data are generated, namely, small_gene: a total of 300 nodes, each node is connected to at least 3 edges and a maximum of 20 edges, which is approximately 4,000 edges; large_gene1: a total of 1,000 nodes, each node is connected to at least 5 edges and a maximum of 23 edges, which is approximately more than 10,000 edges; large_geene2: a total of 2,000 nodes, each node is connected to at least 5 edges and a maximum of 23 edges, which is approximately more than 20,000 edges.
[0086] In addition to the Single-Change update algorithm, the present invention also selects the Dynamic Dijkstra update algorithm and the Solution4 update algorithm (a serial implementation of a parallel update algorithm). On the premise of ensuring that the three update algorithms are accurate solution algorithms, the time and standard deviation of each algorithm in updating the full shortest path in different scenarios are compared.
[0087] The test data can be constructed in the following two ways:
[0088] 1) Three operations are used to calculate the time it takes to change a single edge: (1) Reduce the weight of each edge in the network to 0.5 times, and randomly select 30 edges as the set to reduce the weight; (2) Increase the weight of each edge in the network to 1.5 times, and randomly select 30 edges as the set to increase the weight; (3) Randomly select 30 edges from the set of all deletable edges in the network as the set to delete. The above three sets are used as test data respectively;
[0089] 2) Analyze the depth of the graph and the degree of each node, and construct a set of edge weights and site changes as test data.
[0090] 2. Experimental results of the first data type
[0091] The purpose of constructing the first test data set was to modify each edge in the network and compare the average execution time of the four algorithms for single-edge modifications. Since the small-scale dataset has over 300 edges, while the large-scale dataset has over 10,000, considering every edge operation would be prohibitively time-consuming. Therefore, for the edge operations of decreasing weight, increasing weight, and deleting edges, 30 edges were randomly selected from the small-scale dataset, and 10 edges were randomly selected from the large-scale dataset. The average execution time for each edge operation was calculated. The experimental results are shown in Tables 1 and 2.
[0092] From the analysis in Table 1, we can see that: 1. The Single Change algorithm performs very well for all three single-edge change operations, the Dynamic Dijkstra algorithm and the Single Change algorithm perform similarly, and the Solution 4 algorithm performs less well; 2. In the case of single-edge changes, the Single Change algorithm and the Dynamic Dijkstra algorithm take about 1 / 50 of the time of the Dijkstra algorithm; 3. Due to the large difference in the number of points affected by different edges selected for the same operation, the standard deviation of the update algorithm is large, which is not very obvious in Table 1; however, for large-scale data sets, the standard deviation of the update algorithm is very good because the number of points affected by different edges varies greatly, as shown in Table 2.
[0093] From the analysis in Table 2, we can see that: 1. In large-scale datasets, the Single Change algorithm works better for single weight reduction operations, the Dynamic Dijkstra algorithm works better for the other two unilateral operations, and Solution 4 works poorly for all three operations; 2. In addition, the standard deviations of the update algorithms vary greatly, for the reasons mentioned above.
[0094] Experimental results of the second data type
[0095] For the second constructed data set, a total of six edge operations were selected: decrease weight, increase weight, insert edge, delete edge, insert vertex, and delete vertex. For the small-scale dataset, the calculation was repeated 30 times, with the average time and standard deviation used for performance. For the large-scale dataset, Solution 4 was removed due to poor experimental results. Due to time constraints, each edge operation was run only once.
[0096] Small-scale datasets
[0097] like Figure 1 The figure shows the runtime of the four algorithms for reducing and removing weights. The figure lists the runtimes for processing one, two, three, and four edges. The figure shows that the Dijkstra algorithm takes the longest time and is not very stable. The Single-Change and Dynamic-Dijkstra update algorithms have similar performance. Solution 4 performs moderately well. Both the Single-Change and Dynamic-Dijkstra update algorithms meet the project targets.
[0098] like Figure 2 The time consumption of the four algorithms in the case of inserting edges and deleting edges is shown. Figure 1 similar; Figure 3This is the time consumption of the four algorithms when inserting vertices (inserting one vertex, 4 edges) and deleting vertices (four vertices correspond to 3 edges, 5 edges, 6 edges, and 21 edges respectively). In the case of deleting vertices, the Dynamic-Dijkstra algorithm loses time when deleting the second, third, and fourth vertices due to Single-Change.
[0099] Large-scale datasets
[0100] As shown in Table 2, solution 4 is not very effective, so this method is removed in large-scale experiments. Figure 4 The time consumption of the three algorithms when reducing and increasing the weight is shown in the figure. It can be seen from the figure that the results of the two update algorithms are similar when the weight is reduced. When the weight is increased, the Single-Change time increases rapidly on the third edge, which may be because more sites are affected by the change.
[0101] Figure 5 、 Figure 6 The situation is similar. Dynamic-Dijkstra works better in the three cases of adding weights, deleting edges, and deleting vertices in large-scale data sets.
[0102] Table 1: Average time (ms) of four algorithms for 30 edge operations in a small-scale network
[0103]
[0104] Table 2: Average time (s) of four algorithms for 10 edge operations in large-scale networks
[0105]
[0106] Experimental results of improving Dijkstra algorithm to calculate the shortest path of all pairs
[0107] Table 3: Comparison of the time required to calculate the shortest path for all four algorithms
[0108]
[0109] Among them, 2+3 improves the data initialization and iteration parts of the Dijkstra algorithm at the same time. From the above table, it can be seen that the overall calculation time of the 2+3 algorithm is more than 1 / 5 of the Dijkstra algorithm, and the optimization effect is obvious.
[0110] The present invention adopts a local search method to solve the shortest path problem, which greatly reduces the calculation time of the shortest path in a dynamic network and solves the problem of solving equivalent paths.
[0111] In typical link-state routing protocols, the classic Dijkstra algorithm is often used to construct a shortest path tree (SPT) for each router, with itself as the source. However, even minor changes to the network topology require recalculating multiple SPTs, which is time-consuming in large-scale networks and cannot guarantee quality of service (QoS). Furthermore, the Dijkstra algorithm can only calculate a single optimal path and cannot obtain all equivalent paths. Therefore, it is essential to design an algorithm that can efficiently update the shortest path.
[0112] Based on the concept of Dijkstra's algorithm, the present invention designs a Single-Change update algorithm that uses a local search method to iteratively update the shortest distance and optimal path of a router. The algorithm is divided into insert edge update and delete edge update. The core concept is to determine whether the edge operation affects the SPT. If it does, all affected points are found and updated iteratively. Experiments have shown that the algorithm can significantly reduce the calculation time of the SPT while accurately solving the problem. In addition, the present invention designs an improved Dijkstra algorithm and an improved Single-Change algorithm that can calculate multiple equivalent parent nodes of a router, providing beneficial assistance for resolving network failures. Finally, the present invention improves the Dijkstra algorithm's brute force method for solving the shortest path of all pairs. The improved algorithm takes more than 1 / 5 of the time of the original Dijkstra algorithm.
[0113] In another embodiment of the present invention, a path updating and equivalent path planning system in a dynamic network is provided, which can be used to implement the above-mentioned path updating and equivalent path planning method in a dynamic network. Specifically, the path updating and equivalent path planning system in a dynamic network includes:
[0114] Network graph information and edge operation set acquisition module, used to obtain n shortest path trees T based on Dijkstra algorithm sk Storage structure, edge weights, and changing edge set ΔE k+1 Update the shortest path between any two points at time k+1, and obtain the network graph information and edge operation set at time k+1;
[0115] Algorithm improvement module, used to improve Dijkstra algorithm to calculate multiple equivalent parent nodes, so that it can calculate all optimal paths between any two points at time k+1, and improve Single-Change update algorithm to calculate equivalent parent nodes, reducing the time of calculating equivalent paths;
[0116] The shortest path acquisition module is used to improve the improveDijkstra algorithm to calculate the shortest path for all pairs, so that it can borrow the information from the source point to other nodes obtained previously, thereby reducing the time for calculating the shortest path for each pair.
[0117] The module division in the embodiments of the present invention is illustrative and represents only one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in various embodiments of the present invention may be integrated into a single processor, exist physically as separate modules, or two or more modules may be integrated into a single module. The integrated modules may be implemented in either hardware or software functional modules.
[0118] In another embodiment of the present invention, a computer device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions in the computer storage medium to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of the path update and equivalent path planning method under a dynamic network.
[0119] In another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the terminal's operating system. In addition, the storage space also stores one or more instructions suitable for being loaded and executed by the processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the path update and equivalent path planning method under a dynamic network in the above-mentioned embodiment.
[0120] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0121] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0122] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0123] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.
Claims
1. A path updating and equivalent path planning method in a dynamic network, characterized in that: The steps include: Obtain n shortest path trees T based on Dijkstra algorithm sk Storage structure, edge weights, and changing edge set ΔE k+1 Update the shortest path between any two points at time k+1, and obtain the network graph information and edge operation set at time k+1; T sk It is the shortest path tree with s as the source point obtained by Dijkstra algorithm at time k, where s∈V k , ΔE k+1 represents the set of edge changes from time k to time k+1; Based on the obtained network diagram information and the set of edge operations above, improve the Dijkstra algorithm to directly calculate multiple equivalent parent nodes, enabling it to calculate all the optimal paths between any two points at time k+1. In addition, based on the improved Dijkstra algorithm, perform equivalent parent node update to obtain an improved Single-Change update algorithm for calculating equivalent parent nodes and reducing the time for calculating equivalent paths; On the basis of the improved Dijkstra algorithm, design an improved improveDijkstra algorithm to calculate the all-pair shortest paths, enabling it to borrow the information from the source point to other nodes obtained previously and reducing the time for calculating the segment pair shortest paths; Improve the Dijkstra algorithm to calculate multiple equivalent parent nodes, specifically including: The Dijkstra algorithm based on the priority queue only considers iterative update when dist(y)>dist(x)+W(x,y), and does not consider the equivalent parent nodes with dist(y) = dist(x)+W(x,y); initially, set the parent node parent[y]=[y] for each node y. During iterative update, if dist(y)>dist(x)+W(x,y), update parent[y]=[x]; if dist(y) = dist(x)+W(x,y), add the equivalent parent node parent[y].append(x); if the dist from y to the source point is updated by node z in the next iterative update, then its parent[y]=[z], reverting to a single parent node; The improved Single-Change update algorithm is divided into insert edge update and delete edge update: For the insert edge e(x,y) operation, if dist(y)<dist(x)+W(x,y), then the delete edge has no impact and no update is required; if dist(y) = dist(x)+W(x,y) and node x is not in parent[y], then node x is the equivalent parent node of node y, and parent[y].append(x); if dist(y)>dist(x)+W(x,y), the subtrees rooted at y are all affected, and the affected points are updated according to the improved Dijkstra algorithm; For the operation of deleting an edge e(x, y), if node x is not in parent[y], then the operation of deleting the edge has no effect on the shortest path tree SPT and does not need to be updated; if node x is in parent[y] but len(parent[y])>1, it means that node y already has multiple equivalent parent nodes. In this case, you only need to remove the parent node x and the update is complete; if neither of the above two situations is true, it means that node y has only one parent node x. In this case, all subtrees with y as the root node are affected. At this time, you need to consider whether all neighbor nodes with node y as the out-degree are affected. The evaluation criteria are: for nodes with multiple equivalent parent nodes, you only need to remove the deleted parent node without re-updating; based on this, all affected points are put into the priority queue; when updating the affected nodes, the Single-Change update process and the improved Dijkstra algorithm are combined for updating; Nodes with multiple equivalent parent nodes are screened out, and then the paths corresponding to the parent nodes are extracted from the paths calculated by the original Dijkstra algorithm to obtain multiple equivalent paths of the corresponding nodes.
2. The path updating and equivalent path planning method in a dynamic network according to claim 1, characterized in that: Obtaining the network graph information and edge operation set at time k+1 specifically includes: The adjacency matrix of the network graph is stored in two dictionaries, including the out-degree information and in-degree information of the graph. For the six edge operations that may occur in the routing network: reducing edge weight, inserting edge, inserting vertex, increasing edge weight, deleting edge, and deleting vertex, an edge operation set detaEs is defined. This set includes three forms: 1) [node1, node2, w, True] means that the weight between node1 and node2 is reduced to w or a link node1→node2 is added with weight w. If node1 is a newly inserted site, then [node1, node2, w, True] means inserting site node1 and adding a link node1→node2 with weight w. The new site is added to nameSet and the new site information is added to outGraph and inGraph. 2) [node1, node2, w, False] means the weight between node1 and node2 is increased to w or the link node1→node2 is deleted (in this case w=inf); 3) [node, -1] means deleting the site node, which is specifically implemented by deleting all links connected to the site; Get the network's outdegree matrix outGraph and indegree matrix inGraph: Step 1: Read data: Read data from the Excel spreadsheet, loop through the source and destination sites, and store all different sites in the list nameSet in the order they were read. This list contains all the site names in the network diagram. Step 2: Output matrix: Loop through the station names in nameSet, set the source and destination points in the data to the station, find all points with the station as the tail node and the station as the head node, and record the neighbor nodes of each station in the dictionary outGraph and dictionary inGraph in the form of {node: weight} in the order of nameSet. If there is no corresponding connection, the weight is recorded as INF.
3. The path updating and equivalent path planning method in a dynamic network according to claim 1, characterized in that: The improvements to the Single-Change update algorithm specifically include: The algorithm processes one edge operation at a time, including edge insertion / deletion, edge weight increase / decrease, and vertex addition / deletion. Inserting an edge is equivalent to reducing the weight, that is, reducing the infinite edge weight to a fixed value; deleting an edge is equivalent to increasing the weight, that is, increasing the edge weight with a fixed value to infinity; inserting a vertex is equivalent to inserting an edge connected to the vertex, and deleting a vertex is equivalent to deleting all edges connected to the vertex. It can be summarized as: edge insertion operation and edge deletion operation.
4. The path updating and equivalent path planning method in a dynamic network according to claim 3, characterized in that: Insert edge e(x, y): Determine the relationship between dist(y) and dist(x)+W(x, y) to determine whether node y is affected; if dist(y)≤dist(x)+W(x, y), node y is not affected by the inserted edge and does not need to be updated; if dist(y)>dist(x)+W(x, y), the current distance of node y is not the optimal distance and an update is performed; at this time, all subtrees with y as the root node are affected, define a priority queue and add y to the queue, and apply the Dijkstra algorithm based on the priority queue to update the subtree; Delete edge e(x, y): First, determine whether the parent node of node y is x. There are two cases for discussion: If the original len(path(y)) is equal to 1, it means that node y is an isolated point in the shortest path tree SPT. Deleting the edge has no effect on the SPT tree and does not need to be updated; if the original len(path(y)) is greater than 1 but the parent node of node y, path(y)[-2], is not node x, deleting the edge also has no effect on the SPT and does not need to be updated; if the above two cases are not true, then the deleted edge e(x, y) in the SPT will affect all nodes in the subtree with node y as the root. At this time, all nodes in the network are traversed according to the judgment criterion y in path(n), and the affected points are placed in the priority queue; then the affected nodes in the priority queue are updated with the in-degree matrix inGraph, and the updated nodes must also update their neighbor nodes again, otherwise the final result will not be the global optimal solution.
5. The path updating and equivalent path planning method in a dynamic network according to claim 1, characterized in that: Improve the improveDijkstra algorithm to calculate the shortest path of all pairs, including: Improve the data initialization and iteration parts of the n-loop Dijkstra algorithm, so that the time of calculating the shortest path of all pairs is greatly reduced. Specifically: In the data initialization part, each time the current shortest distance of all nodes needs to be assigned to 0 and the shortest path to [node], and the time spent on repeating n times is O(n 2 ), the collections.defaultdict() package in Python is used to reduce the time of data initialization; in the iteration part, the original Dijkstra algorithm uses the same iterative process each time, and uses labels to mark the calculated source points. If an intermediate point has been calculated during the iteration process, it is directly called.
6. A path updating and equivalent path planning system in a dynamic network, characterized by: include: Network graph information and edge operation set acquisition module, used to obtain n shortest path trees T based on Dijkstra algorithm sk Storage structure, edge weights, and changing edge set ΔE k+1 Update the shortest path between any two points at time k+1, and obtain the network graph information and edge operation set at time k+1; The algorithm improvement module is used to improve the Dijkstra algorithm based on the obtained network graph information and edge operation set above to directly calculate multiple equivalent parent nodes, enabling it to calculate all the optimal paths between any two points at time k+1. In addition, based on the improved Dijkstra algorithm, an improved Single-Change update algorithm is obtained by updating the equivalent parent nodes to calculate the equivalent parent nodes and reduce the time for calculating equivalent paths. The shortest path acquisition module is used to design an improved improveDijkstra algorithm based on the improved Dijkstra algorithm to calculate the all-pair shortest paths, enabling it to borrow the information from the source point to other nodes obtained previously and reduce the time for calculating the segment pair shortest paths. The improved Dijkstra algorithm calculates multiple equivalent parent nodes, specifically including: The Dijkstra algorithm based on the priority queue only considers iterative updates when dist(y)>dist(x)+W(x, y), and does not consider the equivalent parent nodes with dist(y) = dist(x)+W(x, y). Initially, the parent node parent[y]=[y] is set for each node y. During iterative updates, if dist(y)>dist(x)+W(x, y), update parent[y]=[x]; if dist(y) = dist(x)+W(x, y), add the equivalent parent node parent[y].append(x); if the dist from y to the source point is updated by node z during the next iterative update, then its parent[y]=[z], reverting to a single parent node. The improved Single-Change update algorithm is divided into insert edge update and delete edge update: For the insert edge e(x, y) operation, if dist(y)<dist(x)+W(x, y), then the delete edge has no impact and no update is required; if dist(y) = dist(x)+W(x, y) and node x is not in parent[y], then node x is the equivalent parent node of node y, and parent[y].append(x); if dist(y)>dist(x)+W(x, y), the subtrees rooted at y are all affected, and the affected points are updated according to the improved Dijkstra algorithm. For the operation of deleting an edge e(x, y), if node x is not in parent[y], then the operation of deleting the edge has no effect on the shortest path tree SPT and does not need to be updated; if node x is in parent[y] but len(parent[y])>1, it means that node y already has multiple equivalent parent nodes. In this case, you only need to remove the parent node x and the update is complete; if neither of the above two situations is true, it means that node y has only one parent node x. In this case, all subtrees with y as the root node are affected. At this time, you need to consider whether all neighbor nodes with node y as the out-degree are affected. The evaluation criteria are: for nodes with multiple equivalent parent nodes, you only need to remove the deleted parent node without re-updating; based on this, all affected points are put into the priority queue; when updating the affected nodes, the Single-Change update process and the improved Dijkstra algorithm are combined for updating; Nodes with multiple equivalent parent nodes are screened out, and then the paths corresponding to the parent nodes are extracted from the paths calculated by the original Dijkstra algorithm to obtain multiple equivalent paths of the corresponding nodes.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the path updating and equivalent path planning method in a dynamic network are implemented as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the path updating and equivalent path planning method in a dynamic network are implemented.
Citation Information
Patent Citations
Urban road network data organization and shortest path rapid calculation method
CN105740964A
Multicast tree computing method and device
CN109120537A