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 double
distance
Internal; confirmed distance so far to get to this Node from the start.protected double
estimate
Internal; estimated distance to get from this Node to the goal.protected Graph<V>
graph
protected int
i
Internal; a utility field used to store depth in some algorithms.protected int
idHash
protected int
lastRunID
Internal; a utility field used to distinguish which algorithm last used this Node.protected HashMap<Node<V>,Connection<V>>
neighbors
protected V
object
protected ArrayList<Connection<V>>
outEdges
protected Node<V>
prev
Internal; a reference to the previous Node in a BinaryHeap.protected boolean
seen
Internal; tracking bit for whether this Node has been checked during the current algorithm.protected boolean
visited
Internal; 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 void
disconnect()
boolean
equals(Object o)
Collection<Connection<V>>
getConnections()
protected Connection<V>
getEdge(Node<V> v)
V
getObject()
int
hashCode()
protected Connection<V>
removeEdge(Node<V> v)
protected boolean
resetAlgorithmAttributes(int runID)
String
toString()
-
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
IfrunID
is not equal tolastRunID
, this resets the internal fieldsvisited
,seen
,distance
,estimate
,prev
, andi
, then setslastRunID
torunID
.- Parameters:
runID
- an int that identifies which run of an algorithm is currently active- Returns:
- true if anything was reset, or false if
runID
is equal tolastRunID
-
equals
-
hashCode
-
toString
- Overrides:
toString
in classBinaryHeap.Node
-