Fixed the path finding algos a bit
This commit is contained in:
parent
0f85e1b4dd
commit
c161e4bdd8
11 changed files with 240 additions and 205 deletions
|
|
@ -1,17 +1,36 @@
|
|||
package zutil.algo.path;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
public interface PathNode {
|
||||
|
||||
public void setVisited(boolean b);
|
||||
|
||||
public boolean visited();
|
||||
|
||||
/**
|
||||
* @return an Iterator with all its neighbors
|
||||
*/
|
||||
public Iterable<PathNode> getNeighbors();
|
||||
|
||||
/**
|
||||
* @param neighbor is the neighbor
|
||||
* @return the cost to the neighbor
|
||||
*/
|
||||
public int getNeighborCost(PathNode neighbor);
|
||||
|
||||
public void setSourceNeighbor(PathNode neighbor);
|
||||
/**
|
||||
* Sets the parent node to this one
|
||||
*/
|
||||
public void setParentNeighbor(PathNode parent);
|
||||
|
||||
public PathNode getSourceNeighbor();
|
||||
/**
|
||||
* @return the parent node
|
||||
*/
|
||||
public PathNode getParentNeighbor();
|
||||
|
||||
/**
|
||||
* Traverses the parent tree and returns the path.
|
||||
*
|
||||
* @param goal is the node to reach
|
||||
* @return the path to the goal, empty list if there is no goal
|
||||
*/
|
||||
public LinkedList<PathNode> traversTo(PathNode goal);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue