Efficient shortest path index dynamic maintenance method based on labeled road network
By using a CHLR-based dynamic maintenance method to build and update shortcuts, and employing priority queues and shortcut domain algorithms, the problem of dynamically updating the shortest path index in labeled road networks is solved, achieving efficient index updates and query optimization.
Patent Information
- Application Number
- CN202211654986.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-22
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-12-22
AI Technical Summary
Existing technologies lack effective methods for dynamically maintaining the shortest path index in labeled road networks, especially when the edge weights and label types change, making it impossible to update the shortest path index structure on the graph in real time.
A dynamic maintenance method based on the Contraction Hierarchies Label Restrictions (CHLR) index graph is adopted. By constructing and updating shortcuts, and using priority queues and shortcut domain maintenance algorithms, the propagation and computation of edge changes are optimized, and the computation of unchanged edges is reduced.
It enables efficient updating of the shortest path index when edge weights and labels change, reducing unnecessary calculations, improving query efficiency, and significantly increasing update time and hit rate.
Smart Images

Figure CN115994254B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of computer science, and particularly relates to an efficient shortest path index dynamic maintenance method based on a labeled road network. BACKGROUND
[0002] In graph algorithms, the shortest path problem has been widely concerned because it has many application values. With the rapid popularization and application of the Internet, navigation software has become a necessary tool for many people to go out. Through the navigation software, the shortest distance path or the shortest time path between two points can be obtained. At present, many algorithms for querying the shortest path have been proposed. These algorithms can be divided into two categories: index-free and index-based. Index-free includes traditional Dijkstra, Bellman, Floyd, etc. Recently, many index-based algorithms have also been proposed, such as Hub Labeling (HL) which improves the search efficiency by reducing the points on the shortest path, PLL and PSL based on HL. By introducing the concept of "shortcut", Contraction Hierarchies (CH) can reduce the search and iteration of the shortest path query process, thereby speeding up the shortest path query process.
[0003] From 2015 to 2020, the number of mobile map users increased from 605 million to 768 million. However, for many real-world application scenarios, it is not enough to consider only the shortest path between two points in the physical sense. It is also necessary to consider the actual scenario of the road. For example, some drivers want to avoid toll sections even if the distance is shorter, or some special types of large trucks need to avoid forbidden road sections. For these scenarios, the type of road, that is, the type of edge of the road network, also needs to be considered. Therefore, when querying the shortest path for mobile map applications with such a large number of users, in addition to finding the shortest physical distance, attention should also be paid to the label information on the edge. Based on the CH index, there is currently work that proposes an algorithm for constructing a shortest path index on a labeled road network, Contraction Hierarchies Label Restrictions (CHLR).
[0004] In real-world applications, road networks are constantly changing. Highways that were originally toll during festivals will no longer be toll, large trucks will be forbidden during certain time periods, and some roads will be closed during road repairs. In addition, the actual situation of the road is also constantly changing, such as during peak hours when the road is congested. There are currently many platforms that collect real-time traffic information, such as 85% of the real-time traffic data in a certain map coming from crowdsourcing. Given the large user base of platforms such as a certain drop and a certain map, they can almost completely provide the situation of the road through crowdsourcing. In order to provide real-time shortest path results during dynamic changes, people need to design a method for maintaining a shortest path index in a dynamic network.
[0005] According to the investigation, there is no algorithm to solve the method of dynamically maintaining the shortest path index in the labeled road network at present, and the solution of the problem has important practical application value. SUMMARY
[0006] The purpose of the present application is to provide a method for maintaining the shortest path index in the dynamic labeled road network, that is, given a graph network with labels on the edges, when the weight of the edge increases or decreases, and the label type of the edge changes, the shortest path index structure on the graph is dynamically updated.
[0007] The specific technical scheme to achieve the purpose of the present application is:
[0008] An efficient shortest path index dynamic maintenance method based on labeled road network, the method comprises the following specific steps: A1: constructing a CHLR index graph, when a edge (q, v) of the index graph changes, according to the priority given by the CHLR index graph, finding out the point with smaller priority in the end point of the edge (q, v), assuming it is q; according to the method of constructing CHLR index, if there is a shortcut (u, v) generated by edge (u, q) and edge (q, v), then the change of edge (q, v) will affect the shortcut (u, v), and point q is added to the set θ which stores all points that need to be re-contracted;
[0009] A2: the point with smaller priority in the end point of the shortcut (u, v) is added to the set θ, and the influence brought by this change is continued to be transmitted;
[0010] A3: re-contracting operation in the construction of CHLR index is performed on the points in the set θ, and the updated CHLR index graph is obtained.
[0011] Another efficient shortest path index dynamic maintenance method based on labeled road network, the method comprises the following specific steps: B1: constructing a CHLR index graph, if a shortcut edge e=(u, v) on the index graph is obtained by contracting edges e'=(u, q) and e''=(q, v), then e' and e'' are the parents of e, e is the child of e' and e'', and e' is the partner of e''; the change of an edge is equivalent to the edge weight under the old label becoming infinite and the edge weight under the new label becoming a new weight, and the shortcut weight under the new and old labels is recalculated, that is, the minimum value of the edge weight of the original edge graph and the sum of the edge weights of all parents is found; B2: creating a priority queue Q, and inserting the changed edge into the priority queue Q according to the priority of the edge; the priority comparison method of the edge is that the point with smaller priority in the end point of the edge is compared, the point with lower priority corresponds to the edge with lower priority, and if the value is equal, the edge with fewer labels has lower priority;
[0012] B3: maintain the shortcut domain of the changed edge, for two edges e and e' under the same end point, if the edge weight of e is smaller and the label limit is less, i.e. w(e)≤w(e') and then e covers e', e' is deleted; based on this, for the changed edge e, find whether there is an edge that can cover e so that e is invalid; if e increases, see whether the edge that can be covered by e originally can no longer be covered, and if e decreases, see whether e can cover more edges; wherein w is the weight function of the edge on the graph, and l is the function of associating the edge and the label;
[0013] B4: process the edges in the priority queue Q one by one, for the current element e, find all the partners of e and the children of the pair of parents, if e increases, the shortcut weight of the children needs to be recalculated, if e decreases, directly calculate whether a shorter child shortcut will be generated, for the changed shortcut, insert the priority queue Q and maintain the shortcut domain of the changed shortcut; after all the edges in the priority queue Q are processed, the updated CHLR index graph is obtained.
[0014] Another efficient shortest path index dynamic maintenance method based on a labeled road network, the method comprises the following specific steps: C1: build a CHLR index graph, record the support amount of all shortcuts on the index graph, i.e. the number of parent pairs supporting the current shortcut weight; if the original graph edge weight is equal to the shortcut weight, the support amount is added by 1;
[0015] C2: recalculate the new weight of the corresponding edge under the new and old labels, take the minimum value of the length of the edge on the original graph and the sum of all parent edge weights of the edge as the new weight; create a priority queue Q to store the changed edge, if the new edge weight decreases, directly update, if the edge weight increases, do not update temporarily, only insert the priority queue Q, record that the edge weight increases; maintain the shortcut support amount, if the updated edge weight is equal to the current corresponding shortcut weight, the support amount is added by 1, if the shortcut weight changes, the support amount needs to be recalculated, and the changed edge is inserted into the priority queue Q;
[0016] C3: insert the changed edge into the priority queue Q according to the priority of the edge, the priority comparison method of the edge is to compare the priority of the smaller point in the end point of the edge, the priority of the smaller point corresponds to the priority of the smaller edge, if the value is equal, the edge with fewer labels has lower priority;
[0017] C4: maintain the shortcut domain of the changed edge, for two edges e and e' under the same end point, if the edge weight of e is smaller and the label limit is less, i.e. w(e)≤w(e') and If e covers e', e' is deleted; based on this, for the changed edge e, find whether there is an edge that can cover e so that e is invalid, and for the invalid deleted edge, the support quantity is set to 0; the method for maintaining the shortcut domain of e is as follows: if e increases, find whether the edge that can be covered by e originally can no longer be covered, and if e decreases, find whether e can cover more edges, and the support quantity of the shortcut is maintained according to step C2; wherein w is a weight function of the edge on the graph, and l is a function of associating the edge and the label;
[0018] C5: the edges of the priority queue Q are processed one by one, for the current element e, find all the partners of e and the children of the pair of parents; when e increases, if the original weight of e is just a case that supports the weight of the current child shortcut, the support quantity of the child shortcut is reduced by 1, if the support quantity of the child shortcut is less than 1, the weight of the child shortcut will be increased, and no update is made temporarily, and the priority queue Q is inserted; when e decreases, if the updated weight of e supports the current shortcut weight, the support quantity of the child shortcut is increased by 1, and if the current pair of parents can produce a shorter child shortcut, the child shortcut is updated;
[0019] C6: in view of the fact that only the directly updated edges are reduced, the edges that are increased are not updated temporarily, so for the increased shortcut e, the weight of e is recalculated to find whether the edge that can be covered by e originally can no longer be covered, and for e that is reduced, whether e can cover more edges is found, and the support quantity of the shortcut is maintained according to step C2; when the priority queue Q is empty, the updated CHLR index graph is obtained.
[0020] Another efficient shortest path index dynamic maintenance method based on a labeled road network comprises the following specific steps: D1: a CHLR index graph is constructed, and the support quantity of all shortcuts on the index graph, that is, the number of parent pairs supporting the weight of the current shortcut, is recorded; if the weight of the original graph edge is equal to the weight of the shortcut, the support quantity is increased by 1; the shortcuts on the index graph are assigned a level, if a shortcut has no child, the level of the shortcut is 1, otherwise the level of the shortcut is the maximum value of all child levels plus 1; D2: for a batch of edges to be updated, the update is performed from high to low according to the level number, the edges of the same level are updated together, for an edge to be updated, the new weight of the corresponding edge under the new and old labels is recalculated, and the minimum value of the length of the edge on the original graph and the sum of the weights of all parent edges of the edge is taken as the new weight; if the new edge weight is reduced, the update is directly performed, if the edge weight is increased, the update is not performed temporarily, only the priority queue Q is inserted, and the edge weight increase is recorded; the shortcut support quantity is maintained, if the updated edge weight is equal to the weight of the current corresponding shortcut, the support quantity is increased by 1, if the weight of the shortcut changes, the support quantity needs to be recalculated, and the changed edge is inserted into the priority queue Q;
[0021] D3: insert the changed edge into the priority queue Q according to the priority of the edge, the priority of the edge is compared by comparing the priority of the smaller point in the end point of the edge, the priority of the smaller point corresponds to the priority of the smaller edge, if the value is equal, the edge with fewer labels has lower priority;
[0022] D4: maintain the shortcut domain of the changed edge, for two edges e and e' with the same starting point, if the edge weight of edge e is smaller and the label limit is less, i.e. w(e)≤w(e') and e covers e', e' is deleted; based on this, for the changed edge e, it is found whether there is an edge that can cover e so that e is invalid; if e increases, it is found whether the edge that can be covered by e is no longer covered, if e decreases, it is found whether e can cover more edges, the support amount of the shortcut is maintained according to step D2, for the deleted edge that is invalid, the support amount is set to 0; wherein w is the weight function of the edge on the graph, and l is the function of associating the edge and the label; D5: the edges in the priority queue Q are processed one by one, for the current element e, all partners of e and the children of the pair of parents are found; when e increases, if the original weight of e is just a case that supports the current child shortcut weight, then the child shortcut support amount is reduced by 1, if the child shortcut support amount is less than 1, the child shortcut weight will be increased, and the update is temporarily not done, and the priority queue Q is inserted; when e decreases, if the updated weight of e supports the current shortcut weight, the child shortcut support amount is increased by 1, if the current parents can produce a shorter child shortcut, the child shortcut is updated;
[0023] D6: since the increased edge is temporarily not updated, for the increased shortcut e, the weight of e is recalculated, and the shortcut domain of e is maintained; and for e to decrease, the shortcut domain of e is directly maintained;
[0024] D7: after the update of the edges of one level is completed, the edges of the next level are updated; after the update of the edges of all levels is completed, the updated CHLR index graph is obtained.
[0025] The beneficial effects of the application are verified through multi-dimensional experiments, specifically including:
[0026] 1. 1000 edges are randomly extracted for update, and the average time for updating each edge of the first three methods is compared;
[0027] 2. 0.1%-100% of the edges on the graph are updated in batches at one time, and the total time required by the four methods and the re-constructed index method is compared;
[0028] 3. The ratio of the number of actually changed edges to the number of recalculated edges in the first three methods, i.e. the hit rate, is compared.
[0029] The results show that:
[0030] The first experiment is to record the time used to update the index in the case of increasing and decreasing different proportions. In the case of increasing and decreasing edge weight, the update time of the second method and the third method is 100 milliseconds. It can be seen that the proposed method can efficiently maintain the shortest path index based on the labeled road network. The second method and the third method can improve 2 orders of magnitude compared with the first method, because the second method can avoid a large number of unnecessary edge traversal and calculation, and the third method is the fastest because it further reduces the calculation of unchanged edges, thereby further improving the update efficiency. In addition, the time used is not much different under different update proportions, which shows that the methods proposed by the application have good scalability with the change of edge weight.
[0031] The second experiment gives the analysis result of the time used for batch update. The edges of 0.1%-100% on the graph are updated, and the time required is recorded. The second and third methods of the application are much faster than the first method, and the fourth method of the application can further improve the index maintenance efficiency. When 0.1% of the edges on the graph change, the fourth method improves the time used for re-construction of the index by 3 orders of magnitude.
[0032] The third experiment discusses the hit rate of different methods. The hit rate refers to the ratio of the number of edges actually changed to the number of edges recalculated. With the increase of the number of updated edges, the hit rate also increases, because the more the number of updated edges, the more the number of edges actually changed. The second and third methods of the application have higher hit rate than the first method, and the hit rate of the third method is more than 80%, which shows that the method proposed by the application can efficiently maintain the shortest path of the labeled road graph and reduce a lot of unnecessary calculation of unchanged edges. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 The original graph for the embodiment;
[0034] Figure 2 The CHLR index graph based on Figure 1
[0035] Figure 3 The example graph of the update process of the method 2 of the application;
[0036] Figure 4 The example graph of the update process of the method 3 of the application;
[0037] Figure 5 The result graph of the average running time in the case of decreasing edge weight;
[0038] Figure 6 The result graph of the average running time in the case of increasing edge weight;
[0039] Figure 7 Time required for batch update result graph;
[0040] Figure 8 Hit rate of recomputed edges for changed edges result graph. DETAILED DESCRIPTION
[0041] 1) Construction of CHLR shortest path index graph on labeled road networks
[0042] Michael Rice et al. gave a method of constructing CHLR shortest path index graph on labeled road networks in the paper Graph indexing of Road Networks for Shortest Path Queries with Label Restrictions. For a directed, weighted, labeled road network G = (V, E, w, Σ, l), V and E are the set of vertices and edges respectively. Σ is the character set used to represent labels, w is the weight function of edges in the graph, l is the function that associates edges with labels, and φ(v) is the priority assigned to vertices in the graph. A shortcut can be represented as ((u, v), w, l), and a path from s to t in the graph can be represented as P = {e1, e2, …, en}, the weight of the path w(P) = ∑w(en), the label of the path l(P) = l(e1) ∪ l(e2) … ∪ l(en), and the minimum priority of vertices in the path as the priority of the path φ(P). s,t k s,t 1≤i≤k i s,t k
[0043] For a graph G and a set of label restrictions, a shortest path that meets the restrictions should satisfy that the labels of edges in the path have no intersection with the set of label restrictions, that is, the path does not violate the restrictions, and that the weight of the path is the minimum.
[0044] To construct the CHLR index, the concept of "shortcut" is introduced, which shrinks two edges e' = (u, q) and e" = (q, v) connected to vertex q, and φ(q) < φ(u), φ(q) < φ(v). If there is no path P' that is shorter than P = (e', e") and satisfies φ(P) < φ(P') and Then a shortcut (u, v) is introduced with weight w(e') + w(e") and label l(e') U l(e") because if there is such a P', then the shortcut (u, v) is not necessary.
[0045] According to the priority of the points, each point is contracted in turn. When the point q is contracted, the edges connected to the points with higher priority than q are found in pairs, and the edges e' = (u, q) and e" = (q, v) are found. In the subgraph formed by the points with higher priority than q, the Dijkstra algorithm is called to query whether there is a shorter path P' that meets the label limit condition. If no such P' is found, the shortcut (u, v) is introduced. In this way, the graph G' after the shortcut is introduced can be obtained.
[0046] Figure 1 is the original graph, and the circles represent points. The subscript of V is the serial number of the point, and the number in the box next to each point is the priority of the point. The weight and label information of the edge are represented as (weight, label set). Taking the contraction of the point V3 as an example, the edges (V1, V3) and (V3, V9) will generate a shortcut ((V1, V9), 4, {a, b, c}) because there is no path P' from V1 to V9 that is shorter than P = {(V1, V3), (V3, V9)} and satisfies φ(P) < φ(P') and Figure 2 is the graph after the shortcut is added, and the added shortcut is represented by a dashed line.
[0047] In the graph G' after the shortcut is introduced, the shortest path from s to t that does not pass through the labels in the set R is searched. The specific method is to divide it into a forward graph G ′↑ and a backward graph G'↓. The Dijkstra algorithm is run on the forward graph and the backward graph respectively. When the minimum value of the priority queue in one direction exceeds the current shortest distance, the search in that direction is stopped. After the search in both directions is completed, a shortest path can be found. It can be found that by introducing a shortcut, the number of points traversed in the shortest path can be reduced, thereby improving the retrieval efficiency.
[0048] Embodiment 1
[0049] One of the basic methods of the application is method 1
[0050] For the CHLR index graph on Figure 2 , method 1 is used for dynamic maintenance. If an edge ((v4, v6), 5, {b}) is updated to ((v4, v6), 1, {c}), all affected edges need to be found first, and the set θ = {v4, …, v7, v 11v 12 Next, the points in θ are contracted in order of priority from small to large, such as re-contracting V4, which produces two new shortcuts ((v5, v6), 3, {b, c}) and ((v7, v6), 6, {a, c}).
[0051] For the constructed CHLR index graph, the problem to be solved is how to maintain and update the CHLR index when the weight of the edge on the graph increases or decreases and the label on the edge changes.
[0052] A basic method, namely the method 1, is to find all the affected edges and recalculate, where the edges also include the introduced shortcuts, and the method mainly includes two steps: (1) finding all the affected edges. Specifically, when the edge e = (q, v) is changed, it is assumed that φ(q) < φ(v), and the shortcut (u, v) generated by contracting the point q can be affected, because if (q, v) and (u, q) generate (u, v), then the change of (q, v) can affect (u, v), at this time, the point q needs to be re-contracted to calculate the new weight and label of the shortcut (u, v), and the point q that needs to be re-contracted is put into a set θ that stores all points that need to be re-contracted and calculated, and u and v, the points with lower priority, also need to be added to the set θ to continue to transmit the influence brought by the change. (2) Recalculating the edge. After all the affected edges are found, the method for recalculating the edge weight is to re-contract the vertices generating the edge, that is, to re-contract the points in the set θ, and to re-construct the shortcut, so as to obtain the weight and label of the updated edge.
[0053] For a changed edge, all its adjacent edges need to be traversed to find the shortcuts that can be affected by the changed edge, which needs O(d max ) time, where d max is the maximum degree of each point in the graph after the index is constructed. The found affected points have O(|θ|), and each point in θ is re-contracted, and the adjacent points are contracted in pairs, which needs time. According to the construction process, it is needed to call the Dijkstra algorithm to determine whether a shortcut needs to be generated in the contraction operation, which needs O(m·logn) time, where m and n are the number of edges and points on the graph, respectively. Therefore, the time complexity of the basic algorithm is
[0054] Embodiment 2
[0055] A new algorithm for maintaining the CHLR index of the application, namely the method 2
[0056] For Figure 2The constructed CHLR index graph is maintained dynamically by using method 2. Figure 3 The neighbor relation graph is shown, each rectangle represents an edge in the index graph, the upper bold number pair in the square represents the start and end points of the edge, and the lower is the weight and label set of the edge, represented as (weight, label set); a pair of parents are connected to the same circular connection node through a directed edge, and the connection node points to the children of the pair of parents; the square frame where the edge e o = ((v4, v6), 5, {b}) is assigned a new weight 7 and label {c}, then e o is updated to ((v4, v6), ∞, {b}), which is inserted into the priority queue Q as an increase type, and a new edge e n = ((v4, v6), 7, {c}) is generated and inserted into the priority queue Q as a decrease type. e o The update of e n is propagated to its children e1 = ((v5, v6), 7, {b}) and e2 = ((v7, v6), 7, {a, b}), and the shortcut weights of the two children are recalculated, and it is found that their weights do not change. Next, the update of e n is propagated, generating two children e3 = ((v5, v6), 9, {b, c}) and e4 = ((v7, v6), 12, {a, c}). According to the above, it can be found that e1 has a smaller weight and fewer labels than e3, so e1 will cover e3, and e3 will be invalidated in the graph. Continue to propagate the changes of e4 to generate a new child shortcut e5 = ((v 11 , v6), 16, {a, b, c}). At this point, all edges in Q have been processed, and the CHLR index maintenance process is completed.
[0057] The present application proposes a new CHLR index maintenance algorithm to avoid recalculation of unchanged edges. First, some concepts that assist the algorithm are explained. For a constructed index road network, given edges e = (u, v) and e' = (u, q), e'' = (q, v), if φ(q) < φ(u), φ(q) < φ(v) and l(e) = l(e') ∪ l(e''), then e' and e'' are called the parents of e, e is the child of e' and e'', and e' is the partner of e''. It can be found that a shortcut can have multiple pairs of parents and multiple partners, but a pair of parents can only have one child.
[0058] A shortcut can be a shortcut edge itself or a shortcut edge contracted from its pair of parents, so the weight of a shortcut is the minimum of the weight of the original edge and the sum of the weights of its parents. Based on this, the algorithm to calculate the weight of a shortcut is that the weight of a shortcut needs to be initialized to infinity, if the original edge has a shortcut, then the weight of the shortcut is the weight of the original edge, then retrieve each pair of parents of the target shortcut, check if each pair of parents can produce a shorter weight, if so, the weight of the shortcut needs to be updated. The concept of support will be introduced later.
[0059] Algorithm to calculate the weight of a shortcut in method 2
[0060]
[0061] It can be found through the process of constructing the CHLR index that each edge with different labels under the same start and end points will also affect each other. For two edges e and e' under the same start and end points, if w(e)≤w(e') and Then e is less restricted and has a smaller weight than e', so e will be selected instead of e' under the same start and end points, so e can cover e', e' is covered by e, e' is an element of the cover set of e. When e can cover e', e' can be deleted.
[0062] Algorithm to maintain the shortcut domain in method 2
[0063]
[0064]
[0065] For a shortcut edge e that has changed, its shortcut domain needs to be maintained, which is all the shortcuts with the same start and end points but different labels. If there is a shortcut that can cover e, then e is no longer needed, the weight is set to infinity, and e is added to the cover set of the corresponding shortcut. If e still remains, then it needs to be discussed according to whether the change type of e is an increase or a decrease. If it is an increase type, then the shortcuts originally covered by e may no longer be covered as e increases, so for the cover set of e, all the shortcuts recalculate the weight, if the weight is smaller than e, then it will no longer be covered by e, and needs to be re-added to the graph and maintain the edge weight. For the decrease type, e may cover more edges, for all the edges with the same start and end points and the label is a superset of l(e), if the weight is larger than the current e, then e will cover it, and the weight of the covered edge is set to infinity.
[0066] In order to maintain the CHLR, the application proposes a chain update algorithm, aiming to deal with the changed edges as much as possible, and propagate the changed edges in chain, since all shortcuts are contracted from parents, so the change of edge weight will only propagate to its children. When w(e) decreases, only need to see if this smaller value will bring smaller weight to its children, if so, then update; when w(e) increases, need to recalculate the weight of its children, because if the edge weight of the child is contracted from e, then the increase of w(e) may make the weight of the child no longer supported, so need to recalculate the edge weight of the child under the current situation. All changed edges will be inserted into a priority queue, the priority queue is updated based on the priority of the edge, the method of judging the priority is: for two edges, the smaller point between the endpoints is compared in priority, the edge corresponding to the smaller point has lower priority, if the value is equal, then the edge with fewer labels has lower priority.
[0067] Through the CHLR construction method and the concept of parents and children, it can be found that the priority of child shortcuts is higher than that of parent shortcuts, and updating from low to high priority can ensure that all parents of each child have completed the update before the child is updated. Moreover, the change of a shortcut will only affect the children with higher priority, so when the weight of the shortcut decreases, only need to see if it will bring smaller weight to its children; when the weight of the shortcut increases, the current edge weight of the child may no longer be supported, so the weight of the child needs to be recalculated. The chain propagation of updates from low to high priority of edges can ensure the correctness of the update result. In addition to the chain propagation update process, attention should also be paid to the maintenance of changed shortcut domains through the shortcut domain maintenance algorithm.
[0068] Method 2, a new CHLR maintenance algorithm
[0069]
[0070] In order to maintain the CHLR, a priority queue Q storing all changed edges needs to be initialized, if the label of the edge changes, it is equivalent to resetting the weight under the old label to infinity, and resetting the edge weight under the new label to the new weight. First, recalculate the shortcut weight under the old label, if this shortcut weight is larger, then add it to the priority queue Q, and maintain the shortcut domain under the old label using the shortcut domain maintenance algorithm. If the new weight is smaller than the shortcut weight under the current new label, then update the edge weight of the new label, add it to the priority queue Q, and maintain the shortcut domain under the new label using the shortcut domain maintenance algorithm. If the label does not change, then only need to recalculate the new shortcut weight under the current label, and add it to the priority queue Q according to the type of increase or decrease, and maintain the shortcut domain under the current label using the shortcut domain maintenance algorithm.
[0071] For each edge in the priority queue Q, when a shortcut is changed, all its children need to be found, when the change type is increase and the current child weight is not infinity, the child weight needs to be recalculated to see if its weight is no longer supported, if the new shortcut weight is increased, then the child shortcut is inserted into the priority queue Q and the changed child shortcut domain is maintained using the maintain shortcut domain algorithm. When the change type is decrease, only the weight of the current edge as one of the parents and whether a smaller edge weight will be given to the child need to be recalculated, if yes, the child weight is updated and inserted into the priority queue Q, and the changed child shortcut domain is also maintained using the maintain shortcut domain algorithm.
[0072] Embodiment 3
[0073] A CHLR index maintenance optimization algorithm of the present application, namely method 3
[0074] For the CHLR index graph on Figure 2 , method 3 is used for dynamic maintenance, Figure 4 The neighbor graph with shortcut support quantity is given for Figure 2 When an edge e o = ((v4, v6), 5, {b}) is given a new weight 7 and a label {c}, the weight of its child e1 = ((v5, v6), 7, {b}) does not need to be recalculated, because although e o The original edge weight supports the shortcut weight of e1, but the support quantity of shortcut e1 is greater than 2, which means that there are other cases that can support the shortcut weight of e1, so only the shortcut support quantity of e1 needs to be reduced by 1. It can be found that the optimized algorithm can further improve the maintenance efficiency of the CHLR index.
[0075] The present application proposes a CHLR index maintenance optimization algorithm, which further reduces the recalculation and maintenance of unnecessary shortcuts that have not changed. First, the concept of shortcut support quantity needs to be introduced, which refers to the number of cases that support the current shortcut weight, which includes two parts. If there is an edge with the same weight in the original graph corresponding to the shortcut, then the original edge is a case that supports the current shortcut. The second part is the number of parent pairs in all parents of the shortcut that can support the current shortcut weight. These two parts constitute the support quantity of the shortcut edge weight.
[0076] It can be found that only when the changed edge is the case that supports the current child weight, the change of the edge can affect the child, so only the case that the original weight of the changed edge supports the current child weight is considered, and only under this condition, the shortcut weight of the child needs to be recalculated, otherwise, the change of the edge will not affect the child. In addition, even under the condition that the original weight of the changed edge supports the current child weight, the support amount of the child shortcut needs to be considered. If the support amount is greater than 1, it means that more than one case can support the weight of the current child shortcut, so even if the weight of the current edge increases, it will no longer support the weight of the current child shortcut, but there will be other parents supporting the weight of the current child shortcut, so there is no need to recalculate the weight of the child shortcut, and only the current child shortcut support amount needs to be reduced by 1, indicating that the case supporting the weight of the current child shortcut is reduced by one. In general, when the weight of an edge changes, when traversing the child, if it does not support the weight of the current child, or the current child shortcut support amount is greater than 1, there is no need to recalculate the weight of the child.
[0077] Method 3, i.e., CHLR index maintenance optimization algorithm
[0078]
[0079]
[0080] For the CHLR index maintenance optimization algorithm, the shortcut support amount needs to be maintained. When the label changes, if the weight of the original edge under the old label is equal to the shortcut weight, it means that the original edge on the graph supports the current shortcut, and if its support amount is less than 2, it means that after the weight of the original edge under the old label is updated, there is no longer a case supporting the shortcut, so the support amount needs to be set to 0 and inserted into the priority queue Q for updating. If the new weight is equal to the shortcut weight under the new label, it means that the weight of the new edge can also support the shortcut, so the shortcut support amount is increased by 1 to indicate that there is one more supporting case. If the weight of the new edge is less than the shortcut weight under the new label, it means that the weight of the updated edge is smaller, so the shortcut weight under the new label needs to be updated to the weight of the edge and inserted into the queue Q. If the label does not change and is still under the old label, if the weight of the original edge is the weight of the shortcut under the old label, the support amount of the shortcut under the old label is reduced by 1; if the new weight is equal to the weight of the shortcut under the old label, the support amount of the shortcut under the old label is increased by 1; if the new weight is less than the weight of the shortcut under the old label, it means that there is a smaller original edge weight supporting the shortcut, so the shortcut weight is updated and the support amount is set to 1, and the changed edge is inserted into the priority queue Q; if the new weight is greater than the weight of the shortcut under the old label and the shortcut support amount is less than 1, it means that there is no longer a case supporting the original shortcut weight, and the weight of the edge has increased, so the shortcut support amount needs to be set to 1 and inserted into Q.
[0081] For each edge in the priority queue Q, the chain update is performed according to the priority. For the changed edge e, all the adjacent partners and their children are found to propagate the update. If e is increased and the child weight is not infinite, it is judged whether the child shortcut support quantity is greater than or equal to 1 and the current e and its partner are the parent pair supporting the child shortcut weight. If the condition is satisfied, e will be increased so as to no longer support the child shortcut weight, and thus the child shortcut support quantity is reduced by 1. If the child shortcut support quantity is less than 1 at this time, it is indicated that there is no longer a condition supporting the child shortcut weight, and thus the child shortcut weight is increased and inserted into the queue Q. When e is reduced, if the reduced e and its partner exactly support the child shortcut weight, the child shortcut support quantity is increased by 1, indicating that there is another condition supporting the current shortcut weight. If the weight of the reduced e and its partner is less than the child shortcut weight, the child shortcut weight is updated, and the child shortcut support quantity is set to 1. The child shortcut is reduced and needs to be inserted into the priority queue Q.
[0082] Through the above process, it can be found that when the edge weight is reduced, the update propagation is directly performed to see whether a smaller child shortcut is generated; however, when the edge weight is increased, the update is not performed at present, because the original weight needs to be reserved to see whether the changed e original edge weight supports the child shortcut weight, so as to judge whether the child shortcut changes in combination with the child shortcut support quantity. Therefore, the weight of the increased edge is recalculated at the end of the algorithm, and the shortcut domain of e is maintained. For the reduced case, only the shortcut domain of e needs to be directly maintained.
[0083] For the CHLR index maintenance optimization algorithm, only the changed edge is inserted into the priority queue Q, and the insertion process needs to be performed according to the priority, which needs O (|E Δ |·log|E Δ |) time, wherein E Δ is the changed edge. For the changed shortcut e in Q, if e is reduced, it can be directly updated in O (1); if e is increased and the shortcut support quantity is less than 1, the shortcut weight of e needs to be recalculated, which needs to access all the parents of e to determine the final shortcut weight, and needs O (d max ) time. Therefore, the time complexity of the CHLR index maintenance optimization algorithm is O (|E Δ |·log|E Δ |+|E Δ |·d max ).
[0084] Embodiment 4
[0085] The algorithm for batch maintaining the CHLR index, that is, method 4
[0086] For Figure 2 For the constructed CHLR index graph, according to method 4, first, assign a level to each edge, for edge ((v5, v9), 10, {a, b, c}), there is no child, so the level is 1; for edge ((v4, v6), 5, {b}), its level is the maximum value of all child levels plus 1, so the level is 2. When there are a batch of changed edges, update layer by layer from high to low according to the level.
[0087] Batch update refers to the simultaneous update of multiple edges. In order to maintain the CHLR index, first, the level number needs to be assigned to the edge. The specific method is that for the graph with constructed CHLR index, if the child set of a shortcut is empty set, then the level number of the shortcut is 1; otherwise, the level number of the shortcut is the maximum value of all child shortcuts plus 1.
[0088] According to the above level number definition method, it can be found that the shortcuts in the same level will not affect each other, because the change of an edge will only affect its child shortcuts, and the level of the parent is higher than that of the child. For batch update, update according to the level number from high to low, which can ensure that all parents of each shortcut have completed the update before the update of the shortcut, thereby ensuring the correctness of the update result.
[0089] With the help of the bucket data structure, each bucket stores an edge that needs to be updated at a level, and the edges of each bucket are updated in turn according to the level from high to low. After completing all updates at a level, the edges that need to be updated in the next level are processed. The newly changed edges are inserted into the corresponding level bucket.
[0090] In order to show the efficiency of the CHLR maintenance method proposed in the application, some experiments are carried out from multiple dimensions. The experimental data set comes from DIMACS, which contains a large amount of real road network data set. The specific details of the experimental data set used in the application are shown in Table 1.
[0091] Table 1 Details of data set
[0092]
[0093]
[0094] The first experiment is to record the time used for updating the index under the condition of increasing and decreasing different proportions. The horizontal axis represents the percentage of change, and the vertical axis is the time spent for updating the index. The recording method is to randomly select 1000 edges for updating, and calculate the average time spent for updating each edge. The experimental results are as follows Figure 5 and Figure 6As shown in the figure, the eight subgraphs on each graph from (a) to (h) are respectively corresponding to the running results on the data sets NV to US in Table 1; the basic algorithm is the first item proposed in the part of invention contents; the new maintenance index algorithm is the second item proposed in the part of invention contents; and the CHLR index maintenance optimization algorithm is the third item proposed in the part of invention contents. It can be found that the proposed method 2, i.e., the new maintenance index algorithm, and the method 3, i.e., the CHLR index maintenance optimization algorithm, can improve by 2 orders of magnitude compared with the method 1, i.e., the basic algorithm, in the case of increasing and decreasing edge weights, because the method 2, i.e., the new update index algorithm, proposed by the application can avoid a large number of unnecessary edge traversal and calculation, and the method 3, i.e., the CHLR index maintenance optimization algorithm, is the fastest because it further reduces the calculation of edges that do not change through optimization means, thereby further improving the update efficiency. In addition, the time difference is not large under different update proportions, which shows that the method proposed by the application has good scalability with the change of edge weight.
[0095] The second experiment gives the analysis result of the time used for batch update, and the edges of 0.1%-100% on the graph are updated, and the time required is recorded. The batch maintenance CHLR index algorithm is the fourth item proposed in the part of invention contents, and other algorithms are to update the edges that change one by one. The experimental results are as shown in Figure 7 As shown in the figure, the eight subgraphs on each graph from (a) to (h) are respectively corresponding to the running results on the data sets NV to US in Table 1. It can be found that the method 2, i.e., the new maintenance index algorithm, and the method 3, i.e., the CHLR index maintenance optimization algorithm, proposed by the application are much faster than the method 1, i.e., the basic maintenance index algorithm, and the method 4, i.e., the batch maintenance CHLR index algorithm, proposed by the application can further improve the maintenance index efficiency.
[0096] The third experiment discusses the hit rate of different methods, and the hit rate refers to the ratio of the number of edges that actually change to the number of edges that are recalculated. The results are as shown in Figure 8 As shown in the figure, the eight subgraphs on each graph from (a) to (h) are respectively corresponding to the running results on the data sets NV to US in Table 1. With the increase of the number of updated edges, the hit rate also increases, because the more the number of updated edges, the more the number of edges that actually change. The method 2, i.e., the new maintenance index algorithm, and the method 3, i.e., the CHLR index maintenance optimization algorithm, proposed by the application have higher hit rates than the method 1, i.e., the basic maintenance index algorithm, which shows that the method proposed by the application can reduce a lot of unnecessary calculation of edges that do not change.
Claims
1. An efficient shortest path index dynamic maintenance method based on a labeled link-state network, characterized in that, The method comprises the following specific steps: A1: Construct a CHLR index graph, when a edge of the index graph changes, find out the point with lower priority among the end points of the edge according to the priority given by the CHLR index graph, and assume it is A2: According to the priority given by the CHLR index graph, find out the point with lower priority among the end points of the edge, and assume it is A3: According to the priority given by the CHLR index graph, find out the point with lower priority among the end points of the edge, and assume it is ; According to the method of constructing the CHLR index, if there is an edge and an edge produces a shortcut , then the change of the edge will affect the shortcut , and the point is added to the set storing all the points that need to be re-contracted ; A2: shortcut The point with lower priority in the endpoint joins the set Continue to pass the impact of this change; A3: Reconstruct the contraction operation in the CHLR index for the points in the set to obtain an updated CHLR index graph. Wherein: The shortcut is represented as A path from point to is represented as The weight of the path The label of the path The minimum value of the priority in each point on the path as the priority of the path ; with the contraction point two connected edges and and if there is no shorter path satisfying and and then introduce an edge as a shortcut with weight and label .
2. An efficient shortest path index dynamic maintenance method based on a labeled link-state network, characterized in that, The method comprises the following specific steps: B1: Construct the CHLR index graph. If there is a shortcut edge on the index graph... It is by the side and Obtained through contraction, then and yes Parents yes and children, yes The companion of; the change of an edge is equivalent to the edge weight under the old label becoming infinite, the edge weight under the new label becoming the new weight, recalculating the shortcut weight under the old and new labels, that is, finding the minimum value of the recalculated edge weight of the original graph and the sum of the edge weights of all its parent pairs. B2: Create a priority queue Q, and insert the changed edges into the priority queue Q according to the priorities of the edges; the priority of the edge is compared by comparing the points with lower priorities in the endpoints of the edge; the priority of the corresponding edge is lower if the point has a lower priority; if the value is equal, the edge with fewer labels has a lower priority; B3: maintain shortcut domain of changed edge, for two edges with same end point and if edge has small edge weight and less label limit, i.e. and then cover , is deleted; based on this, for changed edge , find if there is an edge that can cover so that is invalid; if is increased, see if the edge that can be covered by can no longer be covered, if is decreased, see if can cover more edges; wherein, is a weight function of edges on the graph, is a function of associating edges and labels; B4: For each edge in the priority queue Q, process the current element , find all the partners of and the children of this pair of parents, if increases, recalculate the shortcut weight of the children, if decreases, directly calculate whether it will produce a shorter shortcut of the children, insert the changed shortcut into the priority queue Q and maintain the shortcut domain of the changed shortcut; after processing all edges in the priority queue Q, the updated CHLR index graph is obtained.
3. An efficient shortest path index dynamic maintenance method based on a labeled link-state network, characterized in that, The method comprises the following specific steps: C1: Build a CHLR index graph, and record the support quantity of all shortcuts on the index graph, that is, the number of parent pairs supporting the current shortcut weight; if the edge weight of the original graph is equal to the shortcut weight, the support quantity is increased by 1; C2: Recalculate the new weight of the corresponding edge under the new and old labels, take the minimum value of the length of the edge on the original graph and the sum of the weights of all parent edges of the edge as the new weight; create a priority queue Q to store the changed edges; if the new edge weight is reduced, directly update; if the edge weight is increased, do not update temporarily, only insert the priority queue Q, and record the increase of the edge weight; maintain the shortcut support quantity; if the updated edge weight is equal to the current corresponding shortcut weight, the support quantity is increased by 1; if the shortcut weight changes, the support quantity needs to be recalculated; the changed edge is inserted into the priority queue Q; C3: Insert the changed edges into the priority queue Q according to the priorities of the edges; the priority of the edge is compared by comparing the points with lower priorities in the endpoints of the edge; the priority of the corresponding edge is lower if the point has a lower priority; if the value is equal, the edge with fewer labels has a lower priority; C4: maintain shortcut domain of changed edge, for two edges under the same stop point and if the edge weight of edge is small and the label limit is less, i.e. and then cover , is deleted; based on this, for the changed edge , find whether there is an edge that can cover so that is invalid, for the deleted edge that is invalid, the support quantity is 0; the method for maintaining the shortcut domain of is: if increases, see whether the edge that can be covered by can no longer be covered, if decreases, see whether can cover more edges, and maintain the support quantity of the shortcut according to step C2; wherein, is a weight function of the edge on the graph, is a function of associating the edge and the label; C5: for each edge of the priority queue Q, process the current element , find all the partners of and the children of this pair of parents; when increases, if the original weight of is exactly one of the weights that supports the current child shortcut weight, then the child shortcut support amount decreases by 1, if the child shortcut support amount is less than 1, then the child shortcut weight increases, and no update is made, and the priority queue Q is inserted; when decreases, if the updated weight of supports the current shortcut weight, then the child shortcut support amount increases by 1, and if the current parent pair can produce a shorter child shortcut, then the child shortcut is updated; C6: Since only decreasing edges are directly updated, and increasing edges are not updated for the time being, the shortcut for increasing edges... Recalculate The weight, see what was originally able to be Whether the covered edges can no longer be covered, and for Reduce, see To determine whether more edges can be covered, maintain the number of shortcuts supported according to step C2; when the priority queue Q is empty, obtain the updated CHLR index graph.
4. An efficient shortest path index dynamic maintenance method based on a labeled link-state network, characterized in that, The method comprises the following specific steps: D1: Build a CHLR index graph, and record the support quantity of all shortcuts on the index graph, that is, the number of parent pairs supporting the current shortcut weight; if the edge weight of the original graph is equal to the shortcut weight, the support quantity is increased by 1; assign a level to the shortcut on the index graph; if a shortcut has no child, the level of the shortcut is 1; otherwise, the level of the shortcut is the maximum value of all child levels plus 1; D2: For a batch of edges to be updated, update according to the level from high to low; the edges of the same level are updated together; for an edge to be updated, recalculate the new weight of the corresponding edge under the new and old labels; take the minimum value of the length of the edge on the original graph and the sum of the weights of all parent edges of the edge as the new weight; if the new edge weight is reduced, directly update; if the edge weight is increased, do not update temporarily, only insert the priority queue Q, and record the increase of the edge weight; maintain the shortcut support quantity; if the updated edge weight is equal to the current corresponding shortcut weight, the support quantity is increased by 1; if the shortcut weight changes, the support quantity needs to be recalculated; the changed edge is inserted into the priority queue Q; D3: Insert the changed edges into the priority queue Q according to the priorities of the edges; the priority of the edge is compared by comparing the points with lower priorities in the endpoints of the edge; the priority of the corresponding edge is lower if the point has a lower priority; if the value is equal, the edge with fewer labels has a lower priority; D4: maintain shortcut domain of changed edge, for two edges with same end point and if edge has small weight and less label limit, i.e. and then cover , is deleted; based on this, for changed edge , find if there is an edge that can cover so that is invalid; if is increased, see if the edge that can be covered by can no longer be covered, if is decreased, see if can cover more edges, according to step D2, maintain the support amount of shortcut, for the deleted edge that is invalid, the support amount is set to 0; wherein, is a weight function of edge on the graph, is a function of associating edge and label; D5: Process the edges of priority queue Q one by one, starting with the current element. Find All the partners and the children of this couple; when Increase, if If the original weight is exactly one of the cases that supports the current child shortcut weight, then the child shortcut support amount is decreased by 1. If the child shortcut support amount is less than 1, then the child shortcut weight is increased, but no update is made yet, and it is inserted into the priority queue Q; when Decrease, if If the updated weight supports the current shortcut weight, then the number of child shortcuts supported is increased by 1. If the current parent pair can generate a shorter child shortcut, then the child shortcut is updated. D6: Since only decreasing edges are directly updated, and increasing edges are not updated for the time being, the shortcut for increasing edges... Recalculate The weights, and then maintain them. The shortcut domain; and for Reduce, direct maintenance The shortcut domain; D7: After the edges of a level are updated, the edges of the next level are updated; after all the level edges are updated, the updated CHLR index graph is obtained.