Package com.graphhopper.routing
Class AStar
java.lang.Object
com.graphhopper.routing.AbstractRoutingAlgorithm
com.graphhopper.routing.AStar
- All Implemented Interfaces:
EdgeToEdgeRoutingAlgorithm
,RoutingAlgorithm
This class implements the A* algorithm according to
http://en.wikipedia.org/wiki/A*_search_algorithm
Different distance calculations can be used via setApproximation.
- Author:
- Peter Karich
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.graphhopper.routing.AbstractRoutingAlgorithm
edgeExplorer, graph, maxVisitedNodes, nodeAccess, timeoutMillis, traversalMode, weighting
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalcPath
(int from, int to) Calculates the best path between the specified nodes.calcPath
(int from, int to, int fromOutEdge, int toInEdge) likeRoutingAlgorithm.calcPath(int, int)
, but this method also allows to strictly restrict the edge the path will begin with and the edge it will end with.protected Path
getName()
int
Returns the visited nodes after searching.protected void
initCollections
(int size) setApproximation
(WeightApproximator approx) protected void
updateBestPath
(EdgeIteratorState edgeState, SPTEntry bestSPTEntry, int traversalId) Methods inherited from class com.graphhopper.routing.AbstractRoutingAlgorithm
accept, calcPaths, checkAlreadyRun, createEmptyPath, isMaxVisitedNodesExceeded, isTimeoutExceeded, setMaxVisitedNodes, setTimeoutMillis, setupFinishTime, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.graphhopper.routing.RoutingAlgorithm
calcPaths, setMaxVisitedNodes, setTimeoutMillis
-
Constructor Details
-
AStar
-
-
Method Details
-
setApproximation
- Parameters:
approx
- defines how distance to goal Node is approximated
-
initCollections
protected void initCollections(int size) -
calcPath
Description copied from interface:RoutingAlgorithm
Calculates the best path between the specified nodes.- Specified by:
calcPath
in interfaceRoutingAlgorithm
- Returns:
- the path. Call the method found() to make sure that the path is valid.
-
calcPath
Description copied from interface:EdgeToEdgeRoutingAlgorithm
likeRoutingAlgorithm.calcPath(int, int)
, but this method also allows to strictly restrict the edge the path will begin with and the edge it will end with.- Specified by:
calcPath
in interfaceEdgeToEdgeRoutingAlgorithm
fromOutEdge
- the edge id of the first edge of the path. usingEdgeIterator.ANY_EDGE
means not enforcing the first edge of the pathtoInEdge
- the edge id of the last edge of the path. usingEdgeIterator.ANY_EDGE
means not enforcing the last edge of the path
-
extractPath
-
getVisitedNodes
public int getVisitedNodes()Description copied from interface:RoutingAlgorithm
Returns the visited nodes after searching. Useful for debugging.- Specified by:
getVisitedNodes
in interfaceRoutingAlgorithm
-
updateBestPath
-
getName
- Specified by:
getName
in interfaceRoutingAlgorithm
- Overrides:
getName
in classAbstractRoutingAlgorithm
- Returns:
- name of this algorithm
-