public class Neighbor extends java.lang.Object implements java.lang.Comparable<Neighbor>
Constructor and Description |
---|
Neighbor(int cost,
GraphNode neighbor)
A neighbor is added to an existing GraphNode by creating an instance of Neighbor
that stores the neighbor and the cost to reach that neighbor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Neighbor otherNode)
Compares the node names of this node and the otherNode.
|
int |
getCost()
Returns the cost of travelling this edge to get to the
Neighbor at the other end of this edge.
|
GraphNode |
getNeighborNode()
Returns the Neighbor (node) that is at the other
end of "this" node's edge.
|
java.lang.String |
toString()
Returns a String representation of this Neighbor.
|
public Neighbor(int cost, GraphNode neighbor)
cost
- The cost to reach this neighbor.neighbor
- The neighbor node being reached by this edge.public int getCost()
public GraphNode getNeighborNode()
public int compareTo(Neighbor otherNode)
compareTo
in interface java.lang.Comparable<Neighbor>
otherNode
- neighbor to be comparedpublic java.lang.String toString()
--1--> bindicates a cost of 1 to get to node b
toString
in class java.lang.Object