Class EdgeBasedWitnessPathSearcher
(source edge) -- s -- x -- t -- (target edge) Let x be a node to be contracted (the 'center node') and s and t neighboring un-contracted nodes of x that are directly connected with x (via a normal edge or a shortcut). This class is used to find out whether a path between a given source edge incoming to s and a given target edge outgoing from t exists with a given maximum weight. The weights of the source and target edges are not counted in, but the turn costs from the source edge to s->x and from x->t to the target edge are. We also distinguish whether this path is a 'bridge-path' or not:
1) The path only consists of one edge from s to x, an arbitrary number of loops at x, and one edge from x to t. This is called a 'bridge-path' here. 2) The path includes an edge from s to a node other than x or an edge from another node than x to t. This is called a 'witness-path'. Note that a witness path can still include x! This is because if a witness includes x we still do not need to include a shortcut because the path contains another (smaller) shortcut in this case.
To find the optimal path an edge-based unidirectional Dijkstra algorithm is used that takes into account turn-costs. The search is initialized for a given source edge key and node to be contracted x. Subsequent searches for different target edges will keep on building the shortest path tree from previous searches. For the performance of edge-based CH graph preparation it is crucial to limit the local witness path searches as much as possible.
- Author:
- easbar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
void
initSearch
(int sourceEdgeKey, int sourceNode, int centerNode, com.graphhopper.routing.ch.EdgeBasedWitnessPathSearcher.Stats stats) Deletes the shortest path tree that has been found so far and initializes a new witness path search for a given node to be contracted and source edge key.double
runSearch
(int targetNode, int targetEdgeKey, double acceptedWeight, int maxPolls) Runs a witness path search for a given target edge key.
-
Constructor Details
-
EdgeBasedWitnessPathSearcher
-
-
Method Details
-
initSearch
public void initSearch(int sourceEdgeKey, int sourceNode, int centerNode, com.graphhopper.routing.ch.EdgeBasedWitnessPathSearcher.Stats stats) Deletes the shortest path tree that has been found so far and initializes a new witness path search for a given node to be contracted and source edge key.- Parameters:
sourceEdgeKey
- the key of the original edge incoming to s from which the search startssourceNode
- the neighbor node from which the search starts (s)centerNode
- the node to be contracted (x)
-
runSearch
public double runSearch(int targetNode, int targetEdgeKey, double acceptedWeight, int maxPolls) Runs a witness path search for a given target edge key. Results of previous searches (the shortest path tree) are reused and the previous search is extended if necessary. Note that you need to callinitSearch(int, int, int, Stats)
before calling this method to initialize the search.- Parameters:
targetNode
- the neighbor node that should be reached by the path (t)targetEdgeKey
- the original edge key outgoing from t where the search endsacceptedWeight
- Once we find a path with a weight smaller or equal to this we return the weight. The returned weight might be larger than the weight of the real shortest path. If there is no path with weight smaller than or equal to this we stop the search and return the weight of the best path found so far.- Returns:
- the weight of the found path or
Double.POSITIVE_INFINITY
if no path was found
-
finishSearch
public void finishSearch() -
close
public void close()
-