1 package cz.cuni.amis.pathfinding.alg.astar; 2 3 import java.util.List; 4 5 /** 6 * This interface is returned by {@link AStar#AStar.findPath(cz.cuni.amis.pathfinding.map.IPFGoal, long)}. 7 * It contains results from the search as well as method for finding the path from the startNode to the goalNode. 8 */ 9 public interface IAStarResult<NODE> { 10 11 /** 12 * Previous node in the path to the goal node. 13 * @param node 14 * @return previous node of supplied node | null 15 */ 16 public NODE getPreviousNode(NODE node); 17 18 /** 19 * Returns cost of the path from startNode to node if the node was touched 20 * by A* algorithm (if A* was successful, then this always contains the goalNode 21 * and every node on the path at least). 22 * <p><p> 23 * If node wasn't touched by A* algorithm, then it returns -1. 24 * 25 * @param node 26 * @return cost of the path from startNode to node 27 */ 28 public int getCostToNode(NODE node); 29 30 /** 31 * Returns estimated cost of the path from startNode to goal through node. 32 * If the node was touched by A* algorithm then it has this value stored here 33 * (if A* was successful, then this always contains the goalNode and every node on the path at least). 34 * <p><p> 35 * If node wasn't touched by A* algorithm, then it returns -1. 36 * 37 * @param node 38 * @return cost of the path from startNode to node 39 */ 40 public int getEstimatedCostToNode(NODE node); 41 42 /** 43 * Returns the path from startNode to goalNode. (Don't change it as it's cached, 44 * if you want to alter it - then copy it :-) 45 * <p><p> 46 * First item is startNode and the last item is goalNode. 47 * If startNode == goalNode then it contains only one item. 48 * For each index ... path[index] has neighbor path[index+1]. 49 * <p><p> 50 * If the path doesn't exist - returns null. 51 * 52 * @return path 53 */ 54 public List<NODE> getPath(); 55 56 /** 57 * If the AStar succeeded then it returns the distance to the goal from the start node. 58 * <p><p> 59 * Returns -1 otherwise. 60 * 61 * @return distance | -1 62 */ 63 public int getDistanceToGoal(); 64 65 /** 66 * Whether this result represents the success, i.e., path from start to goal node has been found. 67 * @return 68 */ 69 public boolean isSuccess(); 70 71 }