Class EdgeBasedWitnessPathSearcher

java.lang.Object
com.graphhopper.routing.ch.EdgeBasedWitnessPathSearcher

public class EdgeBasedWitnessPathSearcher extends Object
Helper class used to perform local witness path searches for graph preparation in edge-based Contraction Hierarchies.

(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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EdgeBasedWitnessPathSearcher

      public EdgeBasedWitnessPathSearcher(CHPreparationGraph prepareGraph)
  • 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 starts
      sourceNode - 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 call initSearch(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 ends
      acceptedWeight - 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()