1 Introduction
Crime incidents such as kidnapping and robbery on roads are not unusual especially in developing countries [46, 32, 45]. Street harassment (e.g., eve teasing, sexual assaults) is a common scenario that mostly women experience on roads [5, 19]. A traveler typically prefers to avoid a road segment with high crime or harassment rate. Similarly, during unrest in a country, people prefer to avoid roads with protests or riots. Also, elderly or sick people may prefer to avoid bumpy roads. However, traditional nearest neighbors (NN) queries that find closest points of interest (POI) (e.g., a fuel station or a bus stop) fail to consider a traveler’s safety or convenience on roads. In realworld scenarios, a user may prefer visiting a nearby POI instead of their nearest one if the slightly longer path to reach the nearby POI is safer than the shortest path to the nearest POI. In this paper, to allow travelers to avoid different types of inconveniences on roads (e.g., crime incidents, harassment, bumpy roads etc.), we introduce a novel query type, called a safest nearby neighbors (SNN) query and propose novel solutions for efficient query processing.
We use safety score of a road segment to denote the associated convenience/safety of traveling on it. In this context, a user may want to avoid roads with low safety scores. Intuitively, a path is safer if it requires a smaller distance to be travelled on the least safe roads. We formally define the Path Safety Score (PSS) of a path in Section 3 but we give an intuitive description using an example below.
Consider the example of Fig. 1 that shows three paths , and from source to a POI , with lengths , and , respectively. Intuitively, we consider a path to be safer than another path if the total distance this path requires traveling on the roads with the lowest safety score is smaller than that of the other path (ties are broken iteratively by considering the total distance traveled on the roads with the next lowest safety scores). In the example, although is longer than , it is safer than because it does not contain any edge with safety score whereas requires traveling km on an edge with safety score . is safer than because, although both require traveling km each on the roads with safety score , requires traveling km on roads with safety score (compared to km by ). In realworld scenarios, a user may want to retrieve the safest paths that are shorter than a userdefined distance constraint . In the example, if km, the safest path from to is whereas the safest path is if km.
In Section 3, we formally define PSS and show that our definition is more general than the definition used in existing works [2, 3, 22] that aim to find the path minimising the total distance travelled through unsafe zones. Furthermore, our solutions are immediately applicable to other measures of PSS as long as they satisfy certain properties.
Given a set of POIs on a road network, a query location and a distance constraint , a SNN query returns POIs (along with paths from to them) with the highest path safety scores considering only the paths with distances less than . In Figure 1 that shows restaurants to , assume that the query location is and km. The restaurants that meet the distance constraint are the candidates for the query answer ( and ). It can be confirmed that is safer than all paths to . Thus, SNN query (also called SNN query) returns along with the path (with length km).
Finding SNNs in a road network is a computational challenge because the number of POIs in the road network and the number of possible paths between a user’s location and a POI can be huge. The processing overhead of a SNN algorithm depends on the amount of required road network traversal and the number of POIs considered for finding the safest nearby POIs. In this paper, we develop two novel indexing structures called Connected Component Tree (tree) and safety score based network Voronoi diagram (SNVD) to refine the search space and propose two efficient algorithms for finding the safest nearby POIs in road networks. In addition, we exploit incremental network expansion (INE) technique [35] to evaluate SNN queries.
A tree recursively partitions the road network graph into connected and safer subgraph(s) by recursively removing the roads with the smallest safety scores. Each node of the tree represents a subgraph, and for every subgraph, the tree stores some distance related information. By exploiting tree properties and the stored distance information, we develop pruning techniques that avoid exploring unnecessary paths that cannot be the safest ones to reach a POI and have distances less than the distance constraint. Although a number of indexing structures [16, 6, 25, 49, 29] have been developed, they are developed to reduce the processing overhead for finding nearest neighbors and cannot be applied or trivially extended for efficient processing of SNN queries.
In the past, the Voronoi diagram [23] has also been widely used for finding nearest neighbors with reduced processing overhead. The traditional Voronoi diagram divides the road network graph into subgrpahs such that each subgraph corresponds to a single POI which is guaranteed to be the nearest POI of every query location in this subgraph. We introduce SNVD that guarantees that, for every query location in a subgraph, its unconstrained safest neighbor (i.e., SNN where the distance constraint is ignored) is its corresponding POI. Note that the unconstrained safest neighbor of a query location is not necessarily its SNN depending on the distance constraint specified by the user. By exploiting the SNVD properties, we develop an algorithm to identify the SNNs, and similar to our tree based approach we improve the performance of our SNVD based algorithm with novel pruning techniques to refine the search space.
Incremental Network Expansion (INE) is among the most efficient nearest POI search techniques that do not rely on any distancebased indexing structure. According to our PSS measure, the PSS of a subpath is greater than or equal to that of the path. This property allows us to adapt the INE based approach for finding SNNs. The INE based approach starts the search from a user’s location, progressively expands the search and continues until the required POIs are identified. Our experiments show that our tree and SNVD based algorithms outperform the INE based approach with a large margin.
The steps of a straightforward solution to evaluate SNNs are as follows: (i) identify candidate POIs which are the POIs with Euclidean distance less than the distance constraint from the query location; (ii) compute the safest paths with distance less than from the query location to each of the candidate POIs; and (iii) select POIs with the highest path safety scores. This solution would incur very high processing overhead because it requires multiple searches. All of our algorithms find SNNs with a single search in the road network. We consider this straightforward approach as a baseline in our experiments and compare the performance of our algorithms against it.
To the best of our knowledge, no work has so far addressed the problem of finding SNNs and quantified the PSS measure. The major contributions of this paper are as follows:

We formulate a measure to quantify the PSS by incorporating road safety scores and individual distances associated with the road safety scores. Our solution can be easily extended for any other PSS measure that satisfy certain properties.

We develop two novel algorithms for processing SNN queries efficiently using a tree and an SNVD, respectively. In addition, we adapt INE based approach for finding the safest nearby POIs. We propose novel pruning techniques to refine the search space and further improve the performance of our algorithms.

We conduct an extensive experimental study using real datasets that demonstrates that the two proposed algorithms significantly outperform the baseline and the INE based approach.
The rest of this paper is organized as follows. We discuss the related work in Section 2. In Section 3, we formally define the SSN query. In Sections 4, 5 and 6, we discuss our solutions based on incremental network expansion, Cttree and SNVD, respectively. Experimental study is presented in Section 7 followed by conclusions and future work in Section 8.
2 Related Work
2.1 Route Planning
A variety of route planning problems have been studied in the past such as: shortest route computation [10, 49] which requires to find the path with the smallest overall cost; multicriteria route planning [31, 37] which aims to return routes considering multiple criteria (e.g., length, safety, scenery etc.); obstacle avoiding path planning [43, 24, 26, 47, 4] which returns the shortest path avoiding a set of obstacles in the space; safe path planning [2, 3, 22] that aims to return paths that are safe and short; alternative route planning [28, 31, 27] where the goal is to return a set of routes significantly different from each other so that the user has more options to choose from; multistop route planning (also called trip planning) [17, 42, 37] which returns a route that passes through multiple stops/POIs satisfying certain constraints; and route alignment [44] that requires determining an optimal alignment for a new road to be added in the network such that the cost considering different criteria is minimized. Below, we briefly discuss some of these route planning problems most closely related to our work.
Multicriteria route planning. Existing techniques [13, 40, 31, 37] typically use a scoring function (e.g., weighted sum) to compute a single score of each edge considering multiple criteria. Once the score of each edge has been computed, the existing shortest path algorithms can be used to compute the path with the best score. In contrast, our work cannot trivially use the existing shortest path algorithms due to the nature of the PSS. Also, as noted in [14], it is nontrivial for a user to define an appropriate scoring function combining the multiple criteria. Thus, some existing works [14, 21] approach the multicriteria route planning differently and compute a set of skyline routes which guarantees that the routes returned are not dominated by any other routes. This is significantly different from our work as it returns possibly a large number of routes for an origindestination pair instead of the safest route.
Obstacle avoiding path planning. Inspired by applications in robotics, video games, and indoor venues [8] a large number of existing works [43, 24, 26, 47, 4] focus on finding the shortest path that avoids passing through a set of obstacles (e.g., walls) in the space. A recent work aims at finding indoor paths that avoid crowds [30]. Even when obstacles are considered as unsafe regions, these works are different from our work because, in our case, the path may still pass through unsafe edges whereas these works assume that the path cannot cross an obstacle (e.g., a shopper cannot move through the walls).
Safe path planning. There are several existing works that consider safety in path planning. In [2, 3, 22], the authors divide the space into safe and unsafe zones and minimize the distance travelled through the unsafe zones. However, these works are unable to handle different safety levels of roads and do not consider any distance constraint on the paths. In Section 3, we show that our work is more general and is applicable to a wider range of definitions of safe paths. Some other existing works [13, 14, 40] also consider safety, however, they model the problem as multicriteria route planning and are significantly different from the problem studied in this paper (as discussed above). The most closely related work to our work is [20] which develops an INEbased algorithm to find the safest paths between a source and a destination by considering individual distances associated with different safety scores of a path. We use this as a baseline in our work.
The problem studied in this paper is significantly different from the abovementioned route planning problems. Unlike route planning problems, our problem does not have a fixed destination, (i.e., each POI is a possible destination) and the goal is to find POIs with the safest paths. In other words, the problem studied in this work is a POI search problem similar to a nearest neighbor (NN) query. In our experimental study, we adapt the stateoftheart safe path planning algorithm [20] to compute SNNs and compare against it. Specifically, one approach to find SNNs is to compute the safest path using [20] for each POI that has Euclidean distance less than from the query location. The application of [20] to find SNNs requires multiple independent safest path searches and incurs extremely high processing overhead (as shown in our experimental results). Next, we briefly discuss recent works on NN queries.
2.2 Nearest neighbor Queries
The problem of finding nearest neighbors (NNs) has been extensively studied in the literature. Researchers have exploited the incremental network expansion (INE), incremental euclidean restriction (IER), and indexing techniques to solve NN queries. INE [35] progressively explores the road network paths from the query location in order of their minimum distances until NNs are identified. IER [35] uses the Euclidean lower bound property that the road network distance between two points is always greater than or equal to their Euclidean distance to find NNs in the road network. Different indexing technique dependent NN algorithms like Distance Browsing [38, 39], ROAD [25], Gtree [49] and Voronoi diagram [23] have been developed to refine the search space and reduce the processing overhead. All of the above algorithms except INE are dependent on the distance related properties and cannot be applied or trivially extended for finding SNNs. An extensive experimental study has been conducted in [1] to compare existing NN algorithms on road networks.
The straightforward application of a NN algorithm for finding SNNs is prohibitively expensive as it would require two independent traversals of the road network for finding nearest neighbors as candidate SNNs, and then computing the safest paths from the query location to each of the candidate SNN, respectively. We extend the INE technique to identify SNNs with a single search in the road network.
3 Problem Formulation
We model a road network as a weighted graph , where is a set of vertices and is a set of edges. A vertex represents a road junction in the road network and an edge represents a road between to . Each edge is associated with two values and . Here, is a positive value representing the weight of the edge , e.g., length, travel time, fuel cost etc. For simplicity, hereafter, we use length to refer to . represents the edge safety score (ESS) of (higher the safer). Computing is beyond the scope of this paper and we assume safety scores are given as input (e.g., computed using existing geospatial crime mapping approaches [7]). Table I summarizes the main notations used the paper.
A path between two vertices and is a sequence of vertices such that the path starts at , ends at , and an edge exists between every two consecutive vertices in the path. Cost of a path is the sum of the weights of the edges in the path, e.g., total length, total travel time etc. For simplicity, hereafter, we use distance/length to refer to the cost of a path and denote it as . Let be a userdefined distance constraint. We say that a path is valid if . Before we define Path Safety Score (PSS) of a path , we first define of a path.
Definition 1
Given a path and a positive integer , is the total length of the edges in which have safety score equal to , i.e., .
In Fig. 1, because there are two edges on with safety score equal to and their total length is . Similarly, , . Intuitively, we want a PSS measure that ensures that a path that requires smaller distance to be travelled on less safe roads has a higher PSS. The following property formally defines this requirement.
Property 1
Let and be two valid paths (i.e., have distances less than ). Let be the smallest positive integer for which . The path must have a higher PSS than if and only if .
In Fig. 1, must have a higher PSS than and because is smaller than , i.e., does not require traveling on an edge with safety score whereas and require traveling km on roads with safety score . must have a higher PSS than because, although , is smaller than . Hereafter, we use to denote wherever the path is clear by context.
Next, we define a measure of PSS (Definition 2) which satisfies Property 1. For this definition, we assume that, for each edge, and is a positive integer. These assumptions do not limit the applications because can be achieved by appropriately scaling up if needed and, in most realworld scenarios, safety scores are integer values based on safety ratings (e.g., 110).
Definition 2
Path Safety Score (PSS): Let be the distance constraint and be a valid path (i.e., ). Let be the maximum ESS of any edge in the road network The PSS of is computed as , where .
Here represents the weight (importance) assigned to the edges with ESS equal to . For example, if and , we have , , , and . We calculate PSS for paths and of Figure 1 as follows. values for are , and . The PSS for path is . For , values are , , , , . The PSS for path is . Finally, values for are , , , , . The PSS for is . Thus, as required by Property 1, has the highest PSS followed by and then .
Note that the importance is set such that it fulfils the following condition: a unit length edge with ESS equal to contributes more in the sum than all other edges in a valid path with ESS greater than , i.e., for (this is because and ). This condition ensures that our PSS measure satisfies Property 1. For example, when , we have and . Since each edge has length at least , this implies that because length of is less than .
Although the PSS of a path can vary depending on , the relative ranking of two paths based on PSSs remains the same irrespective of the value of as long as both paths are valid (i.e., have distance less than . Next, we discuss a property of PSS which we exploit in our solutions.
Property 2
Let be a valid path such that where is a concatenation operation. Then, .
Notation  Explanation 

The road network graph  
An edge connecting vertices and  
Weight (e.g., length, travel time) of  
Edge safety score (ESS) of  
Maximum ESS, i.e.,  
A query location  
A userdefined distance constraint  
A POI located at  
A path from a vertex to a vertex  
Sum of weights of edges in  
Total weight of edges in with ESS equal to  
Path safety score of  
The safest path between and that has distance less than  
The shortest path between and  
We remark that our definition of PSS is more general than the previous works [2, 3, 22] that do not have any distance constraint and treat each road segment either as safe or unsafe instead of assigning different safety scores to each road as in our work. Therefore, our definition is more general, e.g., we can easily use our definition to compute the path that minimizes the distance travelled through unsafe zones (as in [2, 3, 22]) by assigning each edge in the safe zone a safety score and each edge in the unsafe zone a safety score such that and setting to be larger than the length of the longest path in the network. Furthermore, our tree algorithm works for any other definition of PSS as long as it satisfies both of the Properties 3 and 4, whereas, our SNVD algorithm is immediately applicable to any definition of PSS as long as it satisfies Property 3.
Property 3
Let be a subpath of a valid path . The PSS computed using the defined measure must satisfy .
Property 4
Let be the minimum safety score among all edges in the path , i.e., . Given two valid paths and such that , the PSS computed using the defined measure must satisfy .
For instance, assume that ESS represents the probability that no crime will occur on this edge (as in
[14]). If PSS is defined as multiplication of ESS on all edges on a path [14] (i.e., probability that no crime will occur on the whole path), this definition of PSS satisfies Property 3 but does not satisfy Property 4. Thus, SNVD based algorithm can be used to handle queries involving such PSS. On the other hand, if PSS corresponds to the minimum ESS on any edge on the path, then this definition of PSS satisfies both properties, therefore, both Cttree and SNVD based approaches can be used. We remark that Definition 2 satisfies both properties thus both algorithms can be used for it.We denote the safest valid path between two vertices and as which is a path with the highest PSS among all valid paths from to . Now, we define SNN query.
Definition 3
A Safest Nearby neighbor (SNN) Query: Given a weighted road network , a set of POIs , a query location and a distance constraint , a SNN query returns a set containing POIs along with the safest valid paths from to each of these POIs such that, for every and every , where and represent the safest valid paths from to and , respectively.
In some cases, there may not be POIs within distance . In such scenario, a SNN query returns all POIs with distances less than , ranked according to their PSSs. Hereafter, a SNN query (i.e., ) is also simply referred as SNN query. Following most of the existing works on POI search, we assume that the POIs and query location lie on the vertices in the graph.
For the ease of presentation, in our problem setting, we assume that each edge has a single safety score . However, if an edge has multiple safety scores representing the road safety conditions at different times of the day (e.g., day vs night) or different types of crimes, our solutions can be immediately applied by only considering the relative safety score for each edge (e.g., safety scores for night time if the query is issued at night).
4 Incremental Network Expansion
The formulation of the PSS measure as a single value that satisfies that the PSS of a path is smaller than that of its subpath (Property 3) allows us to adapt the incremental network expansion (INE) search [35] to find SNNs. Starting from the query location , the INE based search explores the adjacent edges of . For each edge , a path consisting of and is enqueued into a priority queue . The entries in are ordered in the descending order based on their PSSs. Then the search continues by dequeueing a path from and repeating the process by exploring adjacent edges of the last vertex of the dequeued path. Before enqueueing a new path into , its PSS is efficiently computed using Property 2 from the PSS of the dequeued path and the PSS of the path that consists of a single edge . The first SNN is identified once the last vertex of a dequeued path from is a POI and the distance of the path is less than . The search for SNNs terminates when paths to distinct POIs have been dequeued from and the distances of the paths are smaller than .
To refine the search space, we check if a path can be pruned before enqueueing it into using the following pruning rules. Pruning Rule 1 is straightforward as it simply uses the distance constraint for the pruning condition.
Pruning Rule 1
A path can be pruned if , where represents the distance constraint.
A path between and can be pruned if there is already a dequeued path which is at least as short as and at least as safe as . This is for the following reason. For any node , consider a path expanded from , i.e., . It is easy to show using Property 2 that is at least as short as and at least as safe as . Thus, is not required to be expanded. Pruning Rule 2 exploits the above idea to prune such paths. Since the INE based search dequeues paths in descending order of PSSs from and Pruning Rule 2 is applied to a path before enqueueing it into , the PSS of any dequeued path is higher than . Thus, Pruning Rule 2 only checks whether there is a dequeued path to that is at least as short as .
Pruning Rule 2
A path can be pruned if , where represents the distance of the shortest path from to dequeued so far.
We remark that, since is less than when a valid dequeued path to exists, Pruning Rule 2 facilitates the pruning of the valid paths (i.e., the path length is smaller than ). On the other hand, Pruning Rule 1 prunes the invalid paths, when there is no existing dequeued path that ends at , i.e., .
Complexity Analysis. Let be the total number of valid paths (i.e., with length less than ) from to any node in the road network graph . Then, the worst case time complexity for finding SNNs by applying the INE based search using a priority queue is . The number of total paths reduces when we apply Pruning Rule 2. Let be the effect factor of the Pruning Rule 2, i.e., the pruning rule reduces the number of paths by a factor . Thus, by applying the pruning rule the worst case time complexity of the INE based search becomes . The checking of whether a path can be pruned takes constant time, and it can be shown that the number of paths for which the pruning rules are applied is (because INE incrementally explores the search space).
5 Cttree
In this section, we introduce a novel indexing structure, Connected component tree (tree) and develop an efficient solution based on tree to process SNN queries. Index structures like tree [16], Contraction Hierarchy (CH) [15], Quad tree [12], ROAD [25] and tree [49] have been proposed for efficient search of the query answer based on the distance metric and are not applicable for SNN queries. Some of these indexing techniques [16, 12] divide the space into smaller regions based on the position of the POIs, whereas some other indexing techniques [15, 25] divide the space based on the properties of the road network graph. These existing indexing techniques cannot be applied or trivially extended to compute SNNs because they do not incorporate ESSs of the edges in the road network graph.
(a) Cttree subgraphs  (b) Cttree 

5.1 CtTree Construction and Properties
The key idea to construct a tree is to recursively partition the graph by removing the edges with the smallest ESSs in each step. Removing the edges with the smallest ESS may partition the graph into one or more connected components. A component is denoted as , where is a unique identifier for the partitions created by removing edges with ESS . Each connected component is recursively partitioned by removing the edges with the smallest ESS within . The recursive partitioning stops when either contains a single vertex or all edges within have the same ESS.
Without loss of generality, we explain the tree construction process using an example shown in Figure 2. The original graph has edge ESSs in the range of 1 to 4, and for the sake of simplicity, we do not show the edge distances in the figure. The root of the tree represents the original graph . After removing the smallest edge ESS 1, is divided into three connected components , and . These connected components are represented by three child nodes of the root node at tree height . Each of these components is then recursively partitioned by removing the edges with the smallest ESS. For example, the edges with ESS 2 are removed from , and is divided into three connected components , and . The recursive partitioning of and stop as they have edges with same ESS. On the other hand, after removing the edges with ESS 3, is divided into and .
We formally define a tree as follows:
Definition 4
tree: A tree is a connected component based search tree, a hierarchical structure that has the following properties:

The tree root node represents the original graph .

Each internal or leaf tree node represents a connected component , where does not include any edge with ESS smaller than or equal to and is included in the graph represented by its parent node.

The maximum height of the tree,

Each internal or leaf tree node maintains the following information: the number of POIs in , a border vertex set , the minimum border distance and the minimum POI distance for each border vertex .s
Border vertices, the minimum border distance and the minimum POI distance. A vertex is called a border vertex of a subgraph , if there is an outgoing edge from whose ESS is smaller than or equal to and the edge is not included in . We denote the set of border vertices of with . For example, in Figure 3, includes . A border vertex of represented by a tree node is also a border vertex of the subgraphs represented by its descendent nodes. For example, is a border vertex of both and .
For each border vertex, the corresponding tree node stores the minimum border distance and the minimum POI distance. The minimum border distance of a border vertex of is defined as the minimum of the distances of the shortest paths from to for . In Figure 3, the distances of border vertex from other border vertices and are 16 and 21 respectively. Thus, .
The minimum POI distance of a border vertex is defined as is the distance from to its closest POI in . In Figure 3, the distances of border vertex from POIs , and are 16, 10 and 20 respectively. Thus, .
After the construction of the tree, for each vertex in , we store a pointer to each tree node whose subgraph contains . Since the height is , this requires adding at most pointers for each . We remark that the height of the Cttree can be controlled if needed. Specifically, to ensure a height , the domain of possible ESS values is divided in contiguous intervals and, in each iteration, the edges with ESS in the next smallest interval are removed. E.g., if ESS domain is to , a Cttree of height can be constructed by first removing edges with ESS in range and then and (in this order).
5.2 Query Processing
In Section 5.2.1, we first discuss our technique for SNN search using the tree properties and in Section 5.2.2, we present the detailed algorithms.
5.2.1 NN search
The efficiency of any approach for evaluating a SNN query depends on the area of the graph search space for finding the safest paths having distances less than from to the POIs and the number of POIs considered for identifying SNNs. The tree structure and Property 4 of our PSS measure allow us to start the search from the smallest and safest road network subgraph that has the possibility to include SNNs for . By construction of tree, it is guaranteed that the subgraph of a child node is smaller and safer than that of its parent node. Thus, starting from the root node, our approach recursively traverses the child nodes that include . The traversal ends once a child node that includes less than POIs and is reached. The parent of the last traversed child node is selected as the starting node of our SNN search. Note that the subgraph of the starting node includes greater than or equal to POIs.
If the distances of the paths from to at least POIs in is smaller than , then our approach does not need to expand . This is because, by definition, the edges that connect the border vertices in to other vertices that are not in have lower ESSs than those of the edges in . If there are less than POIs in whose safest paths from have distances less than , our tree based approach recursively updates with the subgragh of its parent node until SNNs are identified.
To find the safest path having distance less than from to the POIs in , we improve the INE based safest path search discussed in Section 4 by incorporating novel pruning techniques using tree properties. Specifically, the minimum border distance and the minimum POI distance stored in the tree node allow us to develop Pruning Rules 3 and 4 to further refine the search space in .
Pruning Rule 3
A path can be pruned if and , where is a border vertex of and and are the minimum border distance and the minimum POI distance of , respectively.
Pruning Rule 4
A path can be pruned if and , where is a border vertex of , represents the set of POIs in , and represents the maximum of the current shortest distances of the POIs in from , i.e., .
If the first condition that uses the minimum border distance in Pruning Rule 3 or 4 becomes true then it is guaranteed that the expanded path through cannot cross to reach a POI outside of due to the violation of distance constraint. On the other hand, satisfying the second condition in Pruning Rule 3 means that the expanded path through cannot reach a POI inside due to the violation of distance constraint. For the second condition, Pruning Rule 4 exploits that if the POIs inside are already reached using other paths then , the maximum of the current shortest distances of the POIs in can be used to prune a path. If the second condition in Pruning Rule 4 becomes true then it is guaranteed that the expanded path through cannot provide paths that are safer than those already identified for the POIs in (please see Pruning Rule 2 for details).
Pruning Rule 4 can prune more paths than Pruning Rule 3 when is less than , i.e., at least one path from to every POI in have been identified. On the other hand, Pruning Rule 3 is better than Pruning Rule 4 when is , i.e., no path has yet been identified for a POI in . Hence we consider all pruning rules (Pruning Rule 1–Pruning Rule 4) to check whether a path can be pruned.
Figure 4 shows an example where a path is pruned using Pruning Rule 4 for a query location and . In the example, is a border vertex of , , and . Here, both and are greater than . Hence according to Pruning Rule 3, path can be pruned. From the figure we also observe that if we expand , it cannot reach a POI outside through a border vertex ( or ) or a POI ( or ) in due to the violation of the distance constraint.
5.2.2 Algorithms
Algorithm 1, CtSNN, shows the pseudocode to find SNNs in the road network using the tree index structure. The inputs to the algorithm are , and . The algorithm returns , an array of entries, where each entry includes the safest path from to a POI whose distance is less than . The entries in are sorted in the descending order based on the PSS of the safest path.
The algorithm uses two priority queues and , where is used for the path expansion in , and stores the paths that will be expanded while searching the parent subgraph of . Each entry of these queues represents a path, the PSS and the path’s length. The entries in a queue are ordered in descending order based on their PSSs. The algorithm uses an array , where stores the distance of the shortest dequeued path from to .
The algorithm starts with initializing two priority queues and to and for each to using Function (Line 1). Then, starting from the root node, Function recursively traverses the child nodes using the stored pointers of until it identifies the smallest subgraph of a tree node that includes and has at least POIs (Line 2). The and the corresponding path information are enqueued to . The algorithm iteratively processes the entries in until it becomes empty or SNNs are found (Lines 4–28).
In every iteration, the algorithm dequeues a path from and updates of the last vertex of the dequeued path if (Lines 5–8). If represents a POI that is not already present in , then is added to , and if includes entries, the answer is returned (Lines 9–14).
If is a border vertex of , then there is at least one outgoing edge from with safety score smaller than or equal to , which might need to be later considered if SNNs are not found in current . Thus, and the corresponding path information are enqueued to (Lines 15–17). Note that the ESS of are larger than .
Next, for each outgoing edge of in , the algorithm checks whether the newly formed path by adding at the end of can be pruned using function ( is elaborated below). If the path is not pruned, then and the corresponding path information are enqueued to (Lines 18–22).
At the end of the iteration, the algorithm checks whether the exploration of is complete, i.e., is empty. If this condition is true, then it means that the safest paths having distances less than from to SNNs are not included in . Thus, the algorithm sets the parent of as , assigns to and resets to (Lines 2327).
PrunePath. Algorithm 2 returns if path can be pruned by any of our pruning criteria and otherwise. The algorithm first checks whether can be pruned using the criteria in Pruning Rules 1 or 2. Note that an entry for a vertex is initialized to and later it gets updated once a path to is dequeued from the queue (see Line 7 in Algorithm 1).
If is not pruned, Function checks whether is a border vertex of or one of its descendants. If so, it returns for and the node for which is a border vertex. Otherwise, is set to . By construction of the tree, a border vertex of a tree node is also the border vertex of its descendants. Thus, there may be multiple nodes for which is a border vertex, in which case, is chosen to be the highest node in the tree for which is a border vertex.
If is a border vertex then the algorithm checks whether can be pruned using Pruning Rules 3 or 4 (Lines 5–8). One of the pruning condition that uses the minimum border distance is same in both Pruning Rules 3 and 4, which is checked in Line 5. The left part of the other condition, adding the minimum POI distance with is also same in both pruning rules. The right part is for Pruning Rule 3 and for Pruning Rule 4, where represents the maximum of the current shortest distances of to the POIs in . The shortest distance of every vertex (including POIs) is initialized to (Line 1 of Algorithm 1). Thus, is initially and later may become less than when the paths to POIs in are dequeued from the priority queue (Lines 5–7 of Algorithm 1).
Since the minimum border distance and minimum POI distance of a tree node are greater than or equal to those of its descendants, it is not required to check these pruning conditions for for the descendants of separately.
Comments
There are no comments yet.