Global Positioning System Reference
In-Depth Information
getAllNeighbors(origin)andgetNeighbors(origin,feature) .
These two methods can be seen as platonic routing functions that are
implicitly used by higher-level algorithms. From the programmer's per-
spective, these methods abstract the direct access to a (special type of)
graph and restrict the routing to node IDs. Both methods return a Set of
Integer s. The methods are private, since the results can also be retrieved
with higher-level methods.
getDestinations(origin,nrMoves) . The method getDestinations is
the higher-level method to determine all reachable nodes with a given
number of moves (edges) without duplicates. The usage getDestinations
(nodeID,1) is analogous to getNeighbors(nodeID) .
Note that the method getDestinations() of the navigable map returns
the destination \database." The destination list with nodeIDs is provided
as a two-dimensional string array with five columns, the first row holding
the column headings and the first column (starting with the second row)
holding the integer node IDs.
getMinimumMoves(origin,destination) . Before finding a route from
O to D, it is helpful to find the minimum number of edges (moves) between
them. This can be achieved by exploring the graph over the full breadth of
each node's neighbors starting from one origin and ending at one destina-
tion. Both game-map methods getDestinations and getMinimumMoves have
the same structure with different return values. The pseudocode looks like
this:
1. collect all neighbors of the origin (from node)
2. check if any neighbor matches the destination
if destination is not found:
3. move all neighborNodes into the fromNodes and
4. remove all visitedNodes, then go to point 2.
if destination is found:
5. return the minimum number of edges
Note that the minimum number of edges does not necessarily reflect the
minimum distance of the shortest route (as shown in Figures 8.2 and 8.3)!
getPaths(Integerorigin,Integerdestination) . This method
implicitly applies getMinimumMoves (which implicitly applies the method
getAllNeighbors ) as the route length (not distance!) to determine one or
more paths with exactly this number of moves.
The implementation introduces another collection, java.util.Queue a
collection designed for holding elements prior to processing.
The main reason for this construct is that elements can be removed
without specifying an object or index (order is irrelevant in this context).
The idea is to fill one queue for each move from the previous node and loop
 
Search WWH ::




Custom Search