N - Type of nodepublic class HierarchicalPathFinder<N> extends java.lang.Object implements PathFinder<N>
HierarchicalPathFinder can find a path in an arbitrary HierarchicalGraph using the given PathFinder,
known as level path finder, on each level of the hierarchy.
Pathfinding on a hierarchical graph applies the level path finder algorithm several times, starting at a high level of the hierarchy and working down. The results at high levels are used to limit the work it needs to do at lower levels.
Note that the hierarchical path finder calls the HierarchicalGraph.setLevel(int) method to switch the graph into a
particular level. All future calls to the getConnections method of the
hierarchical graph then act as if the graph was just a simple, non-hierarchical graph at that level. This way, the level path
finder has no way of telling that it is working with a hierarchical graph and it doesn't need to, meaning that you can use any
path finder implementation for the level path finder.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
| Constructor and Description |
|---|
HierarchicalPathFinder(HierarchicalGraph<N> graph,
PathFinder<N> levelPathFinder) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
search(PathFinderRequest<N> request,
long timeToRun)
Performs an interruptible search, trying to find a path made up of nodes from the start node to the goal node attempting to
honor costs provided by the graph.
|
boolean |
searchConnectionPath(N startNode,
N endNode,
Heuristic<N> heuristic,
GraphPath<Connection<N>> outPath)
Performs a non-interruptible search, trying to find a path made up of connections from the start node to the goal node
attempting to honor costs provided by the graph.
|
boolean |
searchNodePath(N startNode,
N endNode,
Heuristic<N> heuristic,
GraphPath<N> outPath)
Performs a non-interruptible search, trying to find a path made up of nodes from the start node to the goal node attempting
to honor costs provided by the graph.
|
public HierarchicalPathFinder(HierarchicalGraph<N> graph, PathFinder<N> levelPathFinder)
public boolean searchNodePath(N startNode, N endNode, Heuristic<N> heuristic, GraphPath<N> outPath)
PathFindersearchNodePath in interface PathFinder<N>startNode - the start nodeendNode - the end nodeheuristic - the heuristic functionoutPath - the output path that will only be filled if a path is found, otherwise it won't get touched.true if a path was found; false otherwise.public boolean searchConnectionPath(N startNode, N endNode, Heuristic<N> heuristic, GraphPath<Connection<N>> outPath)
PathFindersearchConnectionPath in interface PathFinder<N>startNode - the start nodeendNode - the end nodeheuristic - the heuristic functionoutPath - the output path that will only be filled if a path is found, otherwise it won't get touched.true if a path was found; false otherwise.public boolean search(PathFinderRequest<N> request, long timeToRun)
PathFindersearch in interface PathFinder<N>request - the pathfinding requesttimeToRun - the time in nanoseconds that can be used to advance the searchtrue if the search has finished; false otherwise.