001 package dk.deepthought.sidious.planner.graph;
002 
003 import dk.deepthought.sidious.supportsystem.State;
004 import dk.deepthought.sidious.supportsystem.Step;
005 
006 /**
007  * This interface represents a vertex in a graph.
008  
009  @author Deepthought
010  
011  */
012 public interface Vertex {
013 
014     /**
015      * At any given time, this method returns the cost of the shortest path to
016      * this vertex, with respect to the set of vertices the algorithm has
017      * evaluated at that time.
018      
019      @return the shortest path cost candidate
020      */
021     public double g();
022 
023     /**
024      * Updates this vertex' information about its predecessor and cost
025      * candidate.
026      <p>
027      * This vertex' values will be updated if and only if a lower cost path to
028      * this vertex has been found.
029      
030      @param edgeToPredecessor
031      *            the edge to the previous vertex
032      @param cost
033      *            the cost of getting to this vertex
034      */
035     public void update(Edge edgeToPredecessor, double cost);
036 
037     /**
038      * Gets the predecessor <code>Vertex</code> from the edge.
039      
040      @return the predecessor vertex
041      */
042     public Vertex getPredecessorVertex();
043 
044     /**
045      * Gets the <code>Step</code> leading to this <code>Vertex</code>.
046      
047      @return the <code>Step</code>
048      */
049     public Step getStepToThis();
050 
051     /**
052      * Gets the <code>State</code> represented by this <code>Vertex</code>.
053      
054      @return the state
055      */
056     public State getState();
057 
058     /**
059      * Returns <code>true</code> if this <code>Vertex</code> is the goal
060      * vertex. The goal vertex is defined as the end of a path.
061      
062      @return <code>true</code> if this is the goal vertex.
063      */
064     public boolean isGoal();
065 
066     /**
067      * Returns <code>true</code> if this <code>Vertex</code> is the source
068      * vertex. The source vertex is defined as the start of a path.
069      
070      @return <code>true</code> if this is the source vertex.
071      */
072     public boolean isSource();
073 
074     /**
075      * Creates a source vertex from the specified initial setpoints.
076      
077      @param initialStep
078      *            the initial step
079      
080      @return the source <code>Vertex</code>
081      */
082     public Vertex toSourceVertex(Step initialStep);
083 
084     /**
085      * Creates a goal vertex.
086      
087      @return the goal <code>Vertex</code>
088      */
089     public Vertex toGoalVertex();
090 
091     /**
092      * Checks whether this vertex is contains all the state descriptors of the
093      * input vertex. The input vertex does not have to contain all the state
094      * descriptors of this vertex.
095      
096      @param vertex
097      *            the input vertex
098      @return true if all state descriptors are contained in this vertex
099      */
100     public boolean partiallyEquals(Vertex vertex);
101 
102 }