vanetsim.routing.A_Star
Class A_Star_Node

java.lang.Object
  extended by vanetsim.routing.A_Star.A_Star_Node
All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>

public final class A_Star_Node
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>

A node specific for the computation in an A*-algorithm.


Constructor Summary
A_Star_Node(Node realNode, double f, int counter)
          Instantiates a new A_Star_Node from a node existing on the map.
A_Star_Node(Node realNode, int counter)
          Instantiates a new A_Star_Node from a node existing on the map.
 
Method Summary
 int compareTo(java.lang.Object other)
          Function needed to implement the Comparable interface.
 int getCounter()
          Returns the current value for the counter
 double getF()
          Gets the f value (=approximated distance/time/penalty... from this point to the target).
 double getG()
          Gets the g value (=distance/time/penalty... from this point to the beginning).
 A_Star_Node getPredecessor()
          Gets the predecessor of this node.
 Node getRealNode()
          Gets the "real" node in the map associated with this A*-specific node.
 boolean isInClosedList()
          Returns if this node is in the ClosedList.
 boolean isInOpenList()
          Returns if this node is in the OpenList.
 void reset(int counter)
          Resets the values of the node to the default values so that it can be reused.
 void setF(double f)
          Sets the f value (=approximated distance/time/penalty... from this point to the target).
 void setG(double g)
          Sets the g value (=distance/time/penalty... from this point to the beginning).
 void setInClosedList(boolean state)
          Sets if this node is in the ClosedList or not.
 void setInOpenList(boolean state)
          Sets if this node is in the OpenList or not.
 void setPredecessor(A_Star_Node predecessor)
          Sets the predecessor of this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

A_Star_Node

public A_Star_Node(Node realNode,
                   double f,
                   int counter)
Instantiates a new A_Star_Node from a node existing on the map.

Parameters:
realNode - the real node from the map associated with this A*-specific node
f - the initial value for the approximate distance/time/penalty... to the target
counter - a value to determine if this node is valid for the current routing calculation

A_Star_Node

public A_Star_Node(Node realNode,
                   int counter)
Instantiates a new A_Star_Node from a node existing on the map. The f value is set to 0.

Parameters:
realNode - the real node from the map associated with this A*-specific node
counter - a value to determine if this node is valid for the current routing calculation
Method Detail

reset

public void reset(int counter)
Resets the values of the node to the default values so that it can be reused. If the node is already valid for the current routing run, nothing is done.

Parameters:
counter - a value to determine if this node is valid for the current routing calculation

getCounter

public int getCounter()
Returns the current value for the counter

Returns:
the counter value

isInClosedList

public boolean isInClosedList()
Returns if this node is in the ClosedList.

Returns:
true if node is already in ClosedList, else false

setInClosedList

public void setInClosedList(boolean state)
Sets if this node is in the ClosedList or not.

Parameters:
state - true if this node shall be in the ClosedList, else false

isInOpenList

public boolean isInOpenList()
Returns if this node is in the OpenList.

Returns:
true if node is already in OpenList, else false

setInOpenList

public void setInOpenList(boolean state)
Sets if this node is in the OpenList or not.

Parameters:
state - true if this node shall be in the OpenList, else false

getF

public double getF()
Gets the f value (=approximated distance/time/penalty... from this point to the target).

Returns:
the f value

setF

public void setF(double f)
Sets the f value (=approximated distance/time/penalty... from this point to the target).

Parameters:
f - the new f value

getG

public double getG()
Gets the g value (=distance/time/penalty... from this point to the beginning).

Returns:
the g value

setG

public void setG(double g)
Sets the g value (=distance/time/penalty... from this point to the beginning).

Parameters:
g - the new g value

getPredecessor

public A_Star_Node getPredecessor()
Gets the predecessor of this node.

Returns:
the predecessor

setPredecessor

public void setPredecessor(A_Star_Node predecessor)
Sets the predecessor of this node.

Parameters:
predecessor - the new predecessor

getRealNode

public Node getRealNode()
Gets the "real" node in the map associated with this A*-specific node.

Returns:
the real node

compareTo

public int compareTo(java.lang.Object other)
Function needed to implement the Comparable interface. This allows automatic sorting of this node in a SortedSet like a TreeSet based on it's f-value.

Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>
Parameters:
other - object to compare this node with
Returns:
0 if other is the same, 1 if this is greater than other and -1 if this is less than other