public class EdgeBasedWitnessPathSearcher extends Object
(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.
Constructor and Description |
---|
EdgeBasedWitnessPathSearcher(CHPreparationGraph prepareGraph) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
finishSearch() |
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.
|
public EdgeBasedWitnessPathSearcher(CHPreparationGraph prepareGraph)
public void initSearch(int sourceEdgeKey, int sourceNode, int centerNode, com.graphhopper.routing.ch.EdgeBasedWitnessPathSearcher.Stats stats)
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)public double runSearch(int targetNode, int targetEdgeKey, double acceptedWeight, int maxPolls)
initSearch(int, int, int, Stats)
before calling this method to initialize the search.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.Double.POSITIVE_INFINITY
if no path was foundpublic void finishSearch()
public void close()
Copyright © 2012–2022. All rights reserved.