V
- the graph vertex typeE
- the graph edge typepublic class ALTAdmissibleHeuristic<V,E> extends Object implements AStarAdmissibleHeuristic<V>
The heuristic requires a set of input nodes from the graph, which are used as landmarks. During a pre-processing phase, which requires two shortest path computations per landmark using Dijkstra's algorithm, all distances to and from these landmark nodes are computed and stored. Afterwards, the heuristic estimates the distance from a vertex to another vertex using the already computed distances to and from the landmarks and the fact that shortest path distances obey the triangle-inequality. The heuristic's space requirement is O(n) per landmark where n is the number of vertices of the graph. In case of undirected graphs only one Dijkstra's algorithm execution is performed per landmark.
The method generally abbreviated as ALT (from A*, Landmarks and Triangle inequality) is described in detail in the following paper which also contains a discussion on landmark selection strategies.
Note that using this heuristic does not require the edge weights to satisfy the triangle-inequality. The method depends on the triangle inequality with respect to the shortest path distances in the graph, not an embedding in Euclidean space or some other metric, which need not be present.
In general more landmarks will speed up A* but will need more space. Given an A* query with vertices source and target, a good landmark appears "before" source or "after" target where before and after are relative to the "direction" from source to target.
Constructor and Description |
---|
ALTAdmissibleHeuristic(Graph<V,E> graph,
Set<V> landmarks)
Constructs a new
AStarAdmissibleHeuristic using a set of landmarks. |
Modifier and Type | Method and Description |
---|---|
double |
getCostEstimate(V u,
V t)
An admissible heuristic estimate from a source vertex to a target vertex.
|
public ALTAdmissibleHeuristic(Graph<V,E> graph, Set<V> landmarks)
AStarAdmissibleHeuristic
using a set of landmarks.graph
- the graphlandmarks
- a set of vertices of the graph which will be used as landmarksIllegalArgumentException
- if no landmarks are providedIllegalArgumentException
- if the graph contains edges with negative weightspublic double getCostEstimate(V u, V t)
getCostEstimate
in interface AStarAdmissibleHeuristic<V>
u
- the source vertext
- the target vertexCopyright © 2017. All rights reserved.