public static class Graph.GraphNode
extends java.lang.Object
GraphNode
objects as they are used in the Graph
class. A GraphNode
has a name, a
list of edges to other GraphNode
objects including their respective edge weights (often referred to as
edgeWeights or edgeWeight) and are either marked or not marked (controlled by the boolean marked).Constructor and Description |
---|
GraphNode(java.lang.String nodeName)
Creates a new
GraphNode object with name nodeName. |
Modifier and Type | Method and Description |
---|---|
void |
addEdge(Graph.GraphNode graphNode,
double weight)
Adds a new edge from the calling to the specified
GraphNode objects with the specified weight to the
List of known edges of the GraphNode . |
double |
getEdgeWeight(Graph.GraphNode graphNode)
Returns the edgeWeight of the calling and the specified
GraphNode objects if there is any, otherwise
Double.NaN. |
java.lang.String |
getName()
Returns the name of the
GraphNode object. |
List |
getNeighbors()
Returns a List object of all neighbors.
|
boolean |
isMarked()
Returns whether the
GraphNode object's "marked" flag is set. |
void |
mark()
Sets "marked" to true.
|
void |
removeEdge(Graph.GraphNode graphNode)
Removes any edges between the calling and the specified
GraphNode objects if graphNode ! |
void |
removeMark()
Sets "marked" to false.
|
public GraphNode(java.lang.String nodeName)
GraphNode
object with name nodeName. It is unmarked.nodeName
- the name of the new GraphNode
object.public void mark()
public void removeMark()
public boolean isMarked()
GraphNode
object's "marked" flag is set.public java.lang.String getName()
GraphNode
object.GraphNode
object.public void addEdge(Graph.GraphNode graphNode, double weight)
GraphNode
objects with the specified weight to the
List
of known edges of the GraphNode
.graphNode
- the GraphNode
object to create a new edge to.weight
- the weight of the new edge from "this" to graphNode.public double getEdgeWeight(Graph.GraphNode graphNode)
GraphNode
objects if there is any, otherwise
Double.NaN.graphNode
- the GraphNode
object to find the weight to.public void removeEdge(Graph.GraphNode graphNode)
GraphNode
objects if graphNode != null.
If there were none, nothing happens.graphNode
- the GraphNode
object to remove the edge to.public List getNeighbors()