Package squidpony.squidai.graph
Class Node<V>
java.lang.Object
squidpony.squidmath.BinaryHeap.Node
squidpony.squidai.graph.Node<V>
- Type Parameters:
V- the vertex type; oftenCoord
- All Implemented Interfaces:
Serializable
public class Node<V> extends BinaryHeap.Node implements Serializable
An extended version of
BinaryHeap.Node that also stores a reference to the parent Graph,
a vertex object of type V, a Map of neighbor Nodes to the appropriate Connection per Node, an extra
List of those same Connections for faster iteration, and a lot of internal data used by algorithms in this package.- Author:
- earlygrey
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected doubledistanceInternal; confirmed distance so far to get to this Node from the start.protected doubleestimateInternal; estimated distance to get from this Node to the goal.protected Graph<V>graphprotected intiInternal; a utility field used to store depth in some algorithms.protected intidHashprotected intlastRunIDInternal; a utility field used to distinguish which algorithm last used this Node.protected HashMap<Node<V>,Connection<V>>neighborsprotected Vobjectprotected ArrayList<Connection<V>>outEdgesprotected Node<V>prevInternal; a reference to the previous Node in a BinaryHeap.protected booleanseenInternal; tracking bit for whether this Node has been checked during the current algorithm.protected booleanvisitedInternal; tracking bit for whether this Node has already been visited during the current algorithm. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description protected Connection<V>addEdge(Node<V> v, float weight)protected voiddisconnect()booleanequals(Object o)Collection<Connection<V>>getConnections()protected Connection<V>getEdge(Node<V> v)VgetObject()inthashCode()protected Connection<V>removeEdge(Node<V> v)protected booleanresetAlgorithmAttributes(int runID)StringtoString()
-
Field Details
-
graph
-
idHash
-
object
-
neighbors
-
outEdges
-
visited
Internal; tracking bit for whether this Node has already been visited during the current algorithm. -
seen
Internal; tracking bit for whether this Node has been checked during the current algorithm. -
distance
Internal; confirmed distance so far to get to this Node from the start. -
estimate
Internal; estimated distance to get from this Node to the goal. -
prev
Internal; a reference to the previous Node in a BinaryHeap. -
i
Internal; a utility field used to store depth in some algorithms. -
lastRunID
Internal; a utility field used to distinguish which algorithm last used this Node.
-
-
Constructor Details
-
Method Details
-
getEdge
-
addEdge
-
removeEdge
-
disconnect
-
getConnections
-
getObject
-
resetAlgorithmAttributes
IfrunIDis not equal tolastRunID, this resets the internal fieldsvisited,seen,distance,estimate,prev, andi, then setslastRunIDtorunID.- Parameters:
runID- an int that identifies which run of an algorithm is currently active- Returns:
- true if anything was reset, or false if
runIDis equal tolastRunID
-
equals
-
hashCode
-
toString
- Overrides:
toStringin classBinaryHeap.Node
-