A shortest path and path enumeration based method and system for site selection on road networks
By establishing an undirected weighted graph in road network location selection, pre-calculating the shortest distance and setting path thresholds, and combining it with the DFS method, the problems of low search efficiency and low cost-effectiveness in existing technologies are solved, and an efficient road network location selection method is realized.
Patent Information
- Application Number
- CN202310343069.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2043-04-03
AI Technical Summary
Among existing road network location methods, the Dijkstra algorithm-based method suffers from blindness, resulting in low search efficiency, while the DFS-based method suffers from low cost-effectiveness and slow search speed due to the lack of path threshold constraints.
We employ a method based on shortest path and path enumeration. By reading real road network datasets, we construct an undirected weighted graph, use Dijkstra's algorithm to pre-calculate the shortest distance from the endpoint to other vertices, set path thresholds for pruning, and combine this with depth-first search (DFS) to find and sort paths that meet the path threshold range.
It improves search efficiency, avoids blind searches and invalid path enumeration, and realizes a more efficient road network site selection process, which is applicable to multiple practical application fields.
Smart Images

Figure CN116450960B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of graph computing and big data technology, and more particularly, relates to a road network site selection method and system based on shortest path and path enumeration. BACKGROUND
[0002] Road network site selection refers to selecting a suitable location to build service facilities in a given road network to meet user needs and optimize resource utilization. In real life, the increasing demand for location selection applications makes road network site selection services more and more important, and its applications have covered multiple fields such as social, travel, and comprehensive life services. Users have become accustomed to and fully use the convenience brought by "road network site selection services + mobile applications", such as Gaode Map, Meituan, and Didi Chuxing commonly used in life. From the perspective of both end users and map operators, road network site selection has become an indispensable basic service in social life. Therefore, it is of great practical significance to find a road network site selection method that meets the diversity and accuracy of user needs.
[0003] Since the existing road network site selection method is too single in its measurement, the road network site selection method is mainly based on the shortest path method or the path enumeration method. The first method is based on Dijkstra algorithm, which defines a vertex set S for storing vertices whose shortest paths have been determined, and a distance set D for storing the shortest distance from the starting point to each vertex. At the beginning of the algorithm, the starting point is added to set S, and its distance is set to 0. Then, the algorithm continuously adds the vertex with the shortest distance to set S, and updates the distance from the starting point to other nodes, until set S contains all vertices or the end point is found. The second method is based on Depth First Search (DFS), which basically starts from a starting point, walks along a direction to the end, or cannot continue to walk down until the end point is reached. In path enumeration, depth first search can be used to find all paths starting from a starting point.
[0004] However, the above two methods have some defects that cannot be ignored: first, the road network site selection method based on Dijkstra algorithm is based on Dijkstra algorithm to calculate the shortest path between two vertices, which is a greedy algorithm based on local optimal solution to construct global optimal solution. Since the search process can only make decisions based on known information, it cannot predict the position of the end point in advance, and it is blind, resulting in low search efficiency; second, the road network site selection method based on DFS is to select addresses by enumerating all paths. Since no appropriate path threshold is set, users may be overwhelmed by a large number of paths, and enumerating all paths is time-consuming, and even some paths are useless. This method has low cost performance and slow search speed. SUMMARY
[0005] In view of the above defects or improvement needs of the prior art, the present application provides a road network site selection method based on shortest path and path enumeration. The purpose is to solve the technical problems that the existing road network site selection method based on Dijkstra algorithm has blindness and low query efficiency because it can only make decisions based on known information in the search process and cannot predict the position of the end point in advance; and the existing road network site selection method based on DFS has low efficiency and slow search speed because it does not set appropriate path distance constraints, users may be overwhelmed by a large number of paths, and enumerating all paths is time-consuming and some paths are useless.
[0006] To achieve the above purpose, according to one aspect of the present application, a road network site selection method based on shortest path and path enumeration is provided, comprising the following steps:
[0007] (1) reading a real road network data set, extracting the vertex and edge data therein, and establishing an undirected weighted graph according to the extracted vertex and edge data;
[0008] (2) using the function readGraph() to read and process the undirected weighted graph obtained in step (1) to obtain a starting point set;
[0009] (3) using the function readGraph() to read and process the undirected weighted graph obtained in step (1) to obtain a terminal point set;
[0010] (4) using the depth-first search DFS method to process the starting point set obtained in step (2) and the terminal point set obtained in step (3) to obtain all paths between all starting points and all terminal points within a preset path threshold d range.
[0011] (5) sorting all the paths between each origin and each destination in descending order, which are within the preset path threshold d, to obtain the maximum number of paths between each origin and all destinations and the corresponding destination, which is the most relevant point to be selected in the road network site selection.
[0012] Preferably, step (1) is firstly obtaining a real road network dataset from the SNAP dataset official website, then extracting a vertex file from the real road network dataset by using the function read_vertex(), subsequently obtaining the data of all vertices from the vertex file, each vertex data including the vertex number and its corresponding latitude and longitude, then storing the latitude and longitude of each vertex in a vertex set; thereafter, extracting an edge file from the real road network dataset by using the function read_edge(), subsequently obtaining the data of all edges from the edge file, each data including the numbers of the edge origin and destination, then storing the numbers of the edge origin and destination in an edge set; thereafter, taking out the numbers of the edge origin and destination from the edge set in turn, taking out the corresponding latitude and longitude from the vertex set according to the numbers of the origin and destination, then calculating the weight of the edge according to the latitude and longitude of the two vertices; subsequently, adding the calculated weight between any two vertices to the edge set; finally, establishing an undirected weighted graph according to the edge data stored in the edge set and its corresponding weight.
[0013] Preferably, the weight of the edge is calculated according to the following formula:
[0014]
[0015] wherein R represents the radius of the earth; respectively represent the latitudes of vertex 1 and vertex 2; λ1, λ2 respectively represent the longitudes of vertex 1 and vertex 2.
[0016] Preferably, step (2) includes the following sub-steps:
[0017] (2-1) setting a counter i = 0;
[0018] (2-2) judging whether the counter i is less than or equal to the total number of iterations m, if yes, then entering step (2-3), otherwise the process ends;
[0019] (2-3) performing a read operation on the undirected weighted graph to obtain all the vertices of the undirected weighted graph, then randomly generating an origin by using the function rand(), subsequently inserting the generated origin into an origin set, which is initially empty;
[0020] Preferably, step (3) includes the following sub-steps:
[0021] (3-1) setting a counter j = 0;
[0022] (3-2) Determine whether the counter j is less than or equal to the total number of iterations n, if yes, go to step (3-3), otherwise the process ends.
[0023] (3-3) Perform a read operation on the undirected weighted graph to obtain all vertices of the undirected weighted graph, randomly generate a terminal point using the function rand(), and then go to step (3-4);
[0024] (3-4) Set the counter k = 0;
[0025] (3-5) Determine whether the counter k is less than or equal to the size m of the set of starting points, if yes, go to step (3-6), otherwise set j = j + 1 and return to step (3-2);
[0026] (3-6) Calculate the shortest distance from the jth terminal point in the set of terminal points to the kth starting point in the set of starting points using the Dijkstra algorithm;
[0027] (3-7) Determine whether the shortest distance from the jth terminal point to the kth starting point is less than or equal to the preset path threshold value d, if yes, go to step (3-8), otherwise set k = k + 1 and return to step (3-5).
[0028] (3-8) Insert the jth terminal point into the set of terminal points, which is initially empty.
[0029] Preferably, step (4) comprises the following sub-steps:
[0030] (4-1) Set the counter a = 0;
[0031] (4-2) Determine whether the counter a is less than or equal to the size m of the set of starting points, if yes, go to step (4-3), otherwise the process ends;
[0032] (4-3) Set the counter b = 0;
[0033] (4-4) Determine whether the counter b is less than or equal to the size n of the set of terminal points, if yes, go to step (4-5), otherwise set a = a + 1 and return to step (4-2);
[0034] (4-5) Calculate the shortest distance from each vertex in the undirected weighted graph except the bth terminal point to the terminal point b using the Dijkstra algorithm, and store the calculated plurality of shortest distances in an array SD, which is initially empty;
[0035] (4-6) Set counter c=0 (which is used to record the number of paths from each start point to each end point within the preset path threshold d range), initialize the set Visited to be empty (which is used to store the searched vertices), initialize the searched path distance dis to be zero, and set the a-th start point in the start point set as the current search vertex v;
[0036] (4-7) Determine whether the current search vertex v is equal to the b-th end point in the end point set, if yes, set c=c+1, and then go to step (4-13), otherwise go to step (4-8);
[0037] (4-8) Insert the current search vertex v into the set Visited, and go to step (4-9);
[0038] (4-9) Get the neighbor vertex w of the current search vertex v, and go to step (4-10);
[0039] (4-10) Determine whether the neighbor vertex w is located in the set Visited, if yes, it means that the vertex has been visited and does not need to be searched again to avoid repetition, and return to step (4-9), otherwise go to step (4-11);
[0040] (4-11) Determine whether the neighbor vertex w satisfies the following two conditions: ① whether the searched path distance dis (dis=dis+the distance between the neighbor vertex w and the current search vertex v) is less than or equal to the preset path threshold d; ② whether the shortest distance SD[w] of the vertex w to the end point b calculated by step (4-5) + the searched path distance dis is less than or equal to the preset path threshold d, if yes, go to step (4-12), otherwise perform the pruning operation on the neighbor vertex w, and stop visiting all neighbor vertices of the neighbor vertex w;
[0041] (4-12) Set the neighbor vertex w of the a-th start point as the current search vertex v, and return to step (4-7);
[0042] (4-13) Empty all vertices in the set Visited, and return the number c of paths from the a-th start point in the start point set to the b-th end point in the end point set.
[0043] According to another aspect of the present application, a road network site selection system based on shortest path and path enumeration is provided, comprising:
[0044] A first module is configured to read a real road network data set, extract vertex and edge data therefrom, and establish a directed graph according to the extracted vertex and edge data;
[0045] The second module is configured to read and process the undirected weighted graph obtained by the first module by using a function readGraph(), so as to obtain a starting point set;
[0046] The third module is configured to read and process the undirected weighted graph obtained by the first module by using the function readGraph(), so as to obtain a terminal point set;
[0047] The fourth module is configured to process the starting point set obtained by the second module and the terminal point set obtained by the third module by using a depth-first search (DFS) method, so as to obtain all paths between all starting points and all terminal points and within a preset path threshold d.
[0048] The fifth module is configured to sort all paths between each starting point and each terminal point and within the preset path threshold d in descending order, so as to obtain a maximum path quantity from each starting point to all terminal points and a corresponding terminal point, which is the most relevant point to be selected in road network site selection.
[0049] Overall, compared with the prior art, the above technical solutions of the present application can achieve the following beneficial effects:
[0050] (1) Since the present application adopts step (4-5), the shortest distance from the terminal point to other vertices except the terminal point is pre-calculated and stored in an array, so that the terminal point position can be predicted in advance according to the shortest distance stored in the array during the search process, thereby avoiding blind search, and thus the technical problem of low search efficiency of the first method described above can be solved.
[0051] (2) Since the present application adopts steps (3-6) and (4-11), a proper path threshold d is set in advance, and it is judged whether the current path distance meets the preset path threshold d, and this condition is used as a pruning condition in the path enumeration process, so that some paths that do not meet the path threshold constraint can be effectively and as much as possible avoided, and thus the technical problems of low cost performance and slow search speed of the second method described above can be solved.
[0052] (3) The method of the present application is simple and effective to implement;
[0053] (4) The method of the present application has wide practical application fields. BRIEF DESCRIPTION OF DRAWINGS
[0054] Figure 1 is a flowchart of a road network site selection method based on shortest path and path enumeration of the present application;
[0055] Figure 2 is an example diagram of a road network site selection request;
[0056] Figure 3 is the algorithm running time broken line chart obtained by the method of the present application. DETAILED DESCRIPTION
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. In addition, the technical features involved in the various embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0058] The basic idea of the present application is to improve the method of road network site selection from four aspects. First, a real network data set is obtained and an undirected weighted graph is established. Second, the undirected weighted graph is read by using the function readGraph(), and the start point and the end point randomly generated by the rand() function are stored in the start point and end point set respectively. Third, the depth-first search (DFS) method is used to find all paths between all start points and all end points within the preset path threshold d. Finally, according to the number of paths from each start point to each end point in descending order, the maximum value of the number of paths from each start point to all end points and the corresponding end point are selected, and the end point is the most relevant point to be selected in the road network site selection.
[0059] As shown in Figure 1 , the present application provides a road network site selection method based on shortest path and path enumeration, comprising the following steps:
[0060] (1) reading a real road network data set, extracting vertex and edge data therefrom, and establishing an undirected weighted graph according to the extracted vertex and edge data;
[0061] Specifically, this step first obtains a real road network data set from the SNAP data set official website, then extracts vertex files from the real road network data set by using the function read_vertex(), subsequently obtains data of all vertices from the vertex files, each vertex data including a vertex number and its corresponding latitude and longitude, then stores the latitude and longitude of each vertex in a vertex set, then extracts edge files from the real road network data set by using the function read_edge(), subsequently obtains data of all edges from the edge files, each data including a start point and an end point number of an edge, then stores the start point and end point number of each edge in an edge set, then takes out the start point and end point number of each edge from the edge set in turn, obtains the corresponding latitude and longitude from the vertex set according to the start point and end point number, then calculates the weight of the edge according to the latitude and longitude of the two vertices (vertex 1 and vertex 2). The weight of the edge is calculated according to the following formula:
[0062]
[0063] This formula is derived from the Haversine formula, where R represents the radius of the earth; respectively represent the latitude of vertex 1 and vertex 2; λ1, λ2 respectively represent the longitude of vertex 1 and vertex 2.
[0064] Subsequently, the calculated weight between any two vertices is added to the edge set; finally, a weighted undirected graph is established according to the edge data stored in the edge set and its corresponding weight.
[0065] (2) The weighted undirected graph obtained in step (1) is read using the function readGraph() to obtain a starting point set;
[0066] Step (2) includes the following sub-steps:
[0067] (2-1) Set counter i = 0;
[0068] (2-2) Determine whether the counter i is less than or equal to the total number of iterations m, if so, go to step (2-3), otherwise the process ends;
[0069] In this embodiment, the total number of iterations m is in the range of 0 to 10, preferably 5;
[0070] (2-3) Read the weighted undirected graph to obtain all vertices of the weighted undirected graph, and use the function rand() to randomly generate a starting point, then insert the generated starting point into the starting point set (which is initially empty);
[0071] (3) The weighted undirected graph obtained in step (1) is read using the function readGraph() to obtain a terminal point set;
[0072] Step (3) includes the following sub-steps:
[0073] (3-1) Set counter j = 0;
[0074] (3-2) Determine whether the counter j is less than or equal to the total number of iterations n, if so, go to step (3-3), otherwise the process ends;
[0075] In this embodiment, the total number of iterations n is in the range of 0 to 1000, preferably 500;
[0076] (3-3) Read the weighted undirected graph to obtain all vertices of the weighted undirected graph, and use the function rand() to randomly generate a terminal point, then go to step (3-4);
[0077] (3-4) Set counter k = 0;
[0078] (3-5) Determine whether the counter k is less than or equal to the size m of the starting set. If yes, proceed to step (3-6); otherwise, set j = j + 1 and return to step (3-2).
[0079] (3-6) Use Dijkstra's algorithm to calculate the shortest distance from the j-th endpoint in the endpoint set to the k-th starting point in the starting point set;
[0080] (3-7) Determine whether the shortest distance from the j-th endpoint to the k-th starting point is less than or equal to the preset path threshold d. If yes, proceed to step (3-8); otherwise, set k = k + 1 and return to step (3-5).
[0081] (3-8) Insert the j-th endpoint into the endpoint set (which is initially empty).
[0082] Specifically, the path threshold d ranges from 3km to 7km, with 5km being the preferred value;
[0083] The advantage of this step is that it pre-calculates the shortest distance from the endpoint to the starting point using Dijkstra's algorithm and selects endpoints whose shortest distances satisfy a preset path threshold d, thus providing valid endpoints for subsequent path searches. This is because if the shortest distance from the endpoint to the starting point is greater than the preset path threshold d, then searching for that endpoint is meaningless.
[0084] (4) Use the depth-first search (DFS) method to process the set of starting points obtained in step (2) and the set of ending points obtained in step (3) to obtain all paths between all starting points and all ending points that are within the preset path threshold d.
[0085] like Figure 2 As shown, it represents an example of a location request in a road network. Figure 2 The blue vertices represent the starting set S = {v0, v4}, and the green vertices represent the ending set T = {v7, v...} 11 ,v 12 Given a preset path threshold d = 5km, the path from the starting point v0 to the ending point v7 is obtained using the Depth-First Search (DFS) method. 11 ,v 12 The number of paths within a 5km range is 2, 3, and 0 respectively, from the starting point v4 to the ending point v7. 11 ,v 12 The number of paths within a 5km range is 2, 4, and 3, respectively.
[0086] Step (4) includes the following sub-steps:
[0087] (4-1) Set counter a = 0;
[0088] (4-2) judge whether the counter a is less than or equal to the size m of the start point set, if yes, go to step (4-3), otherwise, the process ends;
[0089] (4-3) set the counter b = 0;
[0090] (4-4) judge whether the counter b is less than or equal to the size n of the end point set, if yes, go to step (4-5), otherwise, set a = a + 1 and return to step (4-2);
[0091] (4-5) calculate the shortest distance from each vertex except the bth end point to the end point b in the undirected weighted graph using the Dijkstra algorithm, and store the calculated multiple shortest distances in an array SD (the array SD is initially empty);
[0092] The advantage of this step is that the shortest distance from all vertices except the bth end point to the end point b is pre-calculated by the Dijkstra algorithm, which provides a pruning condition for judging whether the path distance meets the preset path threshold d in the subsequent step (4-11).
[0093] (4-6) set the counter c = 0 (which is used to record the number of paths from each start point to each end point that meet the preset path threshold d range), initialize the set Visited to be empty (which is used to store the searched vertices), initialize the searched path distance dis to be zero, and set the a th start point in the start point set as the current search vertex v;
[0094] (4-7) judge whether the current search vertex v is equal to the bth end point in the end point set, if yes, set c = c + 1, and then go to step (4-13), otherwise, go to step (4-8);
[0095] (4-8) insert the current search vertex v into the set Visited, and go to step (4-9);
[0096] The advantage of this step is that the searched vertices are stored in an array, which ensures that the search process does not repeatedly visit the searched vertices, avoiding circular access and reducing query efficiency.
[0097] (4-9) get the neighbor vertex w of the current search vertex v, and go to step (4-10);
[0098] (4-10) judge whether the neighbor vertex w is located in the set Visited, if yes, it means that the vertex has been visited and does not need to be searched again to avoid repetition, and return to step (4-9), otherwise, go to step (4-11);
[0099] (4-11) Determine whether the neighboring vertex w satisfies the following two conditions simultaneously: ① Whether the distance of the searched path dis (dis = dis + distance between the neighboring vertex w and the currently searched vertex v) is less than or equal to the preset path threshold d; ② Whether the shortest distance SD[w] from vertex w to the destination b calculated in step (4-5) + the distance of the searched path dis is less than or equal to the preset path threshold d. If yes, proceed to step (4-12); otherwise, perform a pruning operation on the neighboring vertex w and stop visiting all neighboring vertices of the neighboring vertex w.
[0100] (4-12) Take the neighbor vertex w of the a-th starting point as the current search vertex v, and return to step (4-7);
[0101] (4-13) Clear all vertices in the set Visitid and return the number of paths c from the a-th starting point in the set of starting points to the b-th ending point in the set of ending points.
[0102] (5) Sort all paths from each starting point to each ending point obtained in step (4) in descending order to obtain the maximum number of paths from each starting point to all ending points and its corresponding ending point. The ending point is the most relevant point to be selected in the road network site selection.
[0103] like Figure 2 As shown, step (4) uses the DFS method to obtain the distance from the starting point v0 to the ending point v7. 11 ,v 12 Given that the number of paths within a 5km radius is 2, 3, or 0 respectively, sort the path counts and select the endpoint v corresponding to the path with the largest number of paths. 11 As the most relevant point from the starting point v0; from the starting point v4 to the ending point v7, v 11 ,v 12 Given that the number of paths within a 5km radius is 2, 4, and 3 respectively, sort the path counts and select the endpoint v corresponding to the path with the largest number of paths. 11 As the most relevant point of origin v4
[0104] Specifically, this step defines two variables, `max` and `result`, to store the maximum number of paths and the corresponding endpoint number, respectively, with initial values of 0 for both. The number of paths `c` obtained from each call to step (4) is compared with the value of the `max` variable. If the number of paths `c` is greater than the value of `max`, the value of `c` is assigned to the variable `max` to obtain the maximum number of paths. Simultaneously, the endpoint number of the current traversal is assigned to `result`. The variables `max` and `result` are then output to obtain the maximum number of paths from each starting point to the endpoint and the most relevant point for each starting point, because a greater number of paths between two vertices indicates a stronger correlation between them.
[0105] Simulation test results
[0106] The following describes the test environment, test data and test results of the present application:
[0107] The test environment is C++, and the experimental test is carried out on a computer with an operating system Windows 11, an Intel(R) Core(TM) i7-12700H processor with a main frequency of 2.30 GHz and 16 GB of memory.
[0108] The test data is real road network graph data, including 106600 vertices and 130091 edges.
[0109] The test results are Figure 3 The running time polyline graph of the shortest path and path enumeration algorithm obtained under the test environment is given, the abscissa represents the value of the preset path threshold d, and the ordinate represents the running time required for each change of the preset path threshold d, from Figure 2 It can be seen from the above that the running time of the algorithm increases with the preset path threshold d. The algorithm running time changes little before the path distance constraint d = 5000 meters, and the algorithm running time increases linearly after d = 5000 meters.
[0110] Those skilled in the art will readily understand that the above description is only a preferred embodiment of the present application and is not intended to limit the present application, and any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A shortest path and path enumeration based method for site selection in a road network, characterized in that, The method comprises the following steps: (1) reading a real road network data set, extracting vertex and edge data therein, and establishing an undirected weighted graph according to the extracted vertex and edge data; (2) reading the undirected weighted graph obtained in step (1) by using a function readGraph() to obtain a starting point set; step (2) comprises the following sub-steps: (2-1) setting a counter i = 0; (2-2) judging whether the counter i is less than or equal to a total iteration number m, if yes, proceeding to step (2-3), otherwise ending the process; (2-3) reading the undirected weighted graph to obtain all vertices of the undirected weighted graph, randomly generating a starting point by using a function rand(), and then inserting the generated starting point into the starting point set, which is initially empty; (3) reading the undirected weighted graph obtained in step (1) by using the function readGraph() to obtain a terminal point set; step (3) comprises the following sub-steps: (3-1) setting a counter j = 0; (3-2) judging whether the counter j is less than or equal to a total iteration number n, if yes, proceeding to step (3-3), otherwise ending the process; (3-3) reading the undirected weighted graph to obtain all vertices of the undirected weighted graph, randomly generating a terminal point by using the function rand(), and then proceeding to step (3-4); (3-4) setting a counter k = 0; (3-5) judging whether the counter k is less than or equal to the size m of the starting point set, if yes, proceeding to step (3-6), otherwise setting j = j + 1 and returning to step (3-2); (3-6) calculating a shortest distance from the jth terminal point in the terminal point set to the kth starting point in the starting point set by using a Dijkstra algorithm; (3-7) judging whether the shortest distance from the jth terminal point to the kth starting point is less than or equal to a preset path threshold value d, if yes, proceeding to step (3-8), otherwise setting k = k + 1 and returning to step (3-5); (3-8) inserting the jth terminal point into the terminal point set, which is initially empty; (4) processing the starting point set obtained in step (2) and the terminal point set obtained in step (3) by using a depth-first search DFS method to obtain all paths between all starting points and all terminal points and within the preset path threshold value d; (5) performing descending order sorting processing on all paths between each starting point and each terminal point and within the preset path threshold value d obtained in step (4) to obtain a maximum value of the number of paths from each starting point to all terminal points and a corresponding terminal point, which is the most relevant point to be selected in road network site selection.
2. The shortest path and path enumeration based road network siting method of claim 1, wherein, Step (1) firstly acquires a real road network dataset from the SNAP dataset website, then extracts vertex files from the real road network dataset by using a function read_vertex(), subsequently acquires data of all vertices from the vertex files, each piece of vertex data including a vertex number and its corresponding longitude and latitude, and then stores the longitude and latitude of each vertex in a vertex set; thereafter, extracts edge files from the real road network dataset by using a function read_edge(), subsequently acquires data of all edges from the edge files, each piece of data including the numbers of the start point and the end point of an edge, and then stores the numbers of the start point and the end point of each edge in an edge set; thereafter, takes the numbers of the start point and the end point of each edge from the edge set in turn, takes the corresponding longitude and latitude from the vertex set according to the numbers of the start point and the end point, and then calculates the weight of the edge according to the longitude and latitude of the two vertices; Subsequently, adds the calculated weight between any two vertices to the edge set; finally, establishes a weighted and undirected graph according to the edge data stored in the edge set and its corresponding weight.
3. The shortest path and path enumeration based road network siting method of claim 2, wherein, The weight of an edge is calculated according to the following formula: where R represents the earth radius; respectively represent the latitude of vertex 1 and vertex 2; λ1, λ2 respectively represent the longitude of vertex 1 and vertex 2.
4. The shortest path and path enumeration based road network siting method of claim 1, wherein, Step (4) includes the following sub-steps: (4-1) sets a counter a = 0; (4-2) judges whether the counter a is less than or equal to the size m of the start point set, if yes, goes to step (4-3), otherwise the process ends; (4-3) sets a counter b = 0; (4-4) judges whether the counter b is less than or equal to the size n of the end point set, if yes, goes to step (4-5), otherwise sets a = a + 1 and returns to step (4-2); (4-5) calculates the shortest distances from each vertex except the bth end point to the end point b in the weighted and undirected graph by using the Dijkstra algorithm, and stores the calculated multiple shortest distances in an array SD, which is initially empty; (4-6) sets a counter c = 0, which is used to record the number of paths from each start point to each end point within the preset path threshold d range, initializes the set Visited to be empty, which is used to store searched vertices, initializes the searched path distance dis to be zero, and takes the a th start point in the start point set as the current search vertex v; (4-7) judges whether the current search vertex v is equal to the b th end point in the end point set, if yes, sets c = c + 1, and then goes to step (4-13), otherwise goes to step (4-8); (4-8) inserts the current search vertex v into the set Visited, and goes to step (4-9); (4-9) acquires a neighbor vertex w of the current search vertex v, and goes to step (4-10); (4-10) judges whether the neighbor vertex w is located in the set Visited, if yes, indicates that the vertex has been visited and does not need to be searched again to avoid repetition, and returns to step (4-9), otherwise goes to step (4-11); (4-11) sets the distance between the current search vertex v and the neighbor vertex w as the distance between the current search vertex v and the b th end point in the end point set minus the distance between the neighbor vertex w and the b th end point in the end point set, and then goes to step (4-12); (4-12) judges whether the distance between the current search vertex v and the neighbor vertex w is less than or equal to the distance between the current search vertex v and the b th end point in the end point set, if yes, sets the distance between the current search vertex v and the b th end point in the end point set to be the distance between the current search vertex v and the neighbor vertex w, and then goes to step (4-13), otherwise returns to step (4-9); (4-13) judges whether the counter b is less than or equal to the size n of the end point set, if yes, sets the b = b + 1, and then returns to step (4-5), otherwise sets the a = a + 1, and then returns to step (4-2). (4-11) judge whether the neighbor vertex w satisfies the following two conditions: ① whether the searched path distance dis is less than or equal to the preset path threshold d, dis = dis + the distance between the neighbor vertex w and the current search vertex v; ② whether the shortest distance SD[w] from the vertex w to the terminal point b calculated in step (4-5) + the searched path distance dis is less than or equal to the preset path threshold d, if so, go to step (4-12), otherwise, prune the neighbor vertex w and stop visiting all neighbor vertices of the neighbor vertex w; (4-12) take the neighbor vertex w of the a-th starting point as the current search vertex v, and return to step (4-7); (4-13) clear all vertices in the set Visited, and return the path number c from the a-th starting point in the starting point set to the terminal point b in the terminal point set.
5. A shortest path and path enumeration based road network siting system for implementing the shortest path and path enumeration based road network siting method of any one of claims 1 to 4, characterized by The road network site selection system comprises: A first module for reading a real road network data set, extracting vertex and edge data therefrom, and establishing a directed and weighted graph according to the extracted vertex and edge data; A second module for reading and processing the directed and weighted graph obtained by the first module by using a function readGraph(), to obtain a starting point set; A third module for reading and processing the directed and weighted graph obtained by the first module by using the function readGraph(), to obtain a terminal point set; A fourth module for processing the starting point set obtained by the second module and the terminal point set obtained by the third module by using a depth-first search DFS method, to obtain all paths between all starting points and all terminal points and within a preset path threshold d; A fifth module for performing descending order sorting processing on all paths between each starting point and each terminal point and within the preset path threshold d obtained by the fourth module, to obtain a maximum path number from each starting point to all terminal points and the corresponding terminal point, which is the most relevant point to be selected in road network site selection.
Citation Information
Patent Citations
Marine route planning method and device and readable storage medium
CN115655281A
Multi-pairs shortest path finding method and system
US20100332436A1