Package org.geotools.graph.path
Class AStarShortestPathFinder
Object
AStarShortestPathFinder
- All Implemented Interfaces:
GraphWalker
Calculates the shortest path between two nodes using the A Star algorithm (for details see
http://en.wikipedia.org/wiki/A_star)
- Author:
- Germán E. Trouillet, Francisco G. Malbrán. Universidad Nacional de Córdoba (UNC)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAStarShortestPathFinder
(Graph graph, Node source, Node target, AStarIterator.AStarFunctions afuncs) Constructs a new path finder -
Method Summary
Modifier and TypeMethodDescriptionvoid
Performs the graph traversal and calculates the shortest path from the source node to destiny node in the graph.void
finish()
Does nothing.getPath()
Returns a path from the target to the source.int
visit
(Graphable element, GraphTraversal traversal) Visits a graph component.
-
Constructor Details
-
AStarShortestPathFinder
public AStarShortestPathFinder(Graph graph, Node source, Node target, AStarIterator.AStarFunctions afuncs) Constructs a new path finder- Parameters:
graph
- Graph where we will perform the search.source
- Node to calculate path from.target
- Node to calculate path to.
-
-
Method Details
-
calculate
public void calculate()Performs the graph traversal and calculates the shortest path from the source node to destiny node in the graph. -
visit
Description copied from interface:GraphWalker
Visits a graph component.- Specified by:
visit
in interfaceGraphWalker
- Parameters:
element
- The component being visited.traversal
- The traversal controlling the sequence of graph component visits.- Returns:
- GraphTraversal#CONTINUE to signal that the traversal should continue.
GraphTraversal#CONTINUE to signal that the traversal should suspend.
GraphTraversal#KILL_BRANCH to signal that the traversal should kill its current branch.
GraphTraversal#STOP to signal that the traversal should stop. - See Also:
-
getPath
Returns a path from the target to the source. If the desired path is the opposite (from the source to the target), the reverse or the riterator methods from the Path class can be used.- Returns:
- A path from the target to the source.
- Throws:
WrongPathException
- See Also:
-
finish
public void finish()Does nothing.- Specified by:
finish
in interfaceGraphWalker
- See Also:
-