|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnetkit.graph.Node
public final class Node
This class represents a node in the Graph object. It holds it's identifier name and the Attributes container for all its fields. Nodes keep track of their Edge's and Node neighbors and all the values for its Attributes.
Graph
,
Attributes
,
Edge
,
EdgeType
Constructor Summary | |
---|---|
Node(java.lang.String name,
Attributes attributes,
int index)
The constructor must be provided with a name, an Attributes container and an index. |
Method Summary | |
---|---|
void |
addEdge(Edge newEdge)
Adds the supplied edge to this node; the Edge must not already exist. |
void |
addValues()
If the Attributes container (AKA nodeType) has been increased in size by adding one or more Attribute fields to it, this method will resize the internal values array to match. |
int |
compareTo(Node n)
Specifies a natural ordering for Nodes; compare node types first, then node names. |
Node |
copy(int index)
The constructor must be provided with a name, an Attributes container and an index. |
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one; Nodes are equal if they share the same name and type. |
int |
getAttributeIndex(java.lang.String attribute)
Get the integer index of a single value Attribute within this container. |
Attributes |
getAttributes()
Get the Attributes container detailing the attributes contained within this node. |
Edge |
getEdge(java.lang.String edgeTypeName,
Node neighbor)
Gets the edge connecting this node to a neighbor node. |
Edge[] |
getEdges()
Get all the edges of this Node irrespective of EdgeType; the order is unspecified. |
Edge[] |
getEdgesByType(java.lang.String edgeTypeName)
Get the Edges of this Node whose EdgeType name is the supplied parameter; the order is unspecified. |
Edge[] |
getEdgesByType(java.lang.String edgeTypeName,
NodeFilter nf)
Get the Edges of this Node whose EdgeType name is the supplied parameter and whose destination Nodes match the supplied NodeFilter; the order is unspecified. |
Edge[] |
getEdgesToNeighbor(Node destinationNode)
Get all the edges of this Node whose destination Node is the supplied node; the order is unspecified. |
Edge[] |
getEdgesToNeighbor(java.lang.String destinationNodeType)
Get all the edges of this Node whose destination Node is of the supplied type; the order is unspecified. |
Edge[] |
getEdgesToNeighbor(java.lang.String destinationNodeType,
NodeFilter nf)
Get all the edges of this Node whose destination Node is of the supplied type and which matches the supplied NodeFilter; the order is unspecified. |
int |
getIndex()
Get the index of this node. |
java.lang.String |
getName()
Get the name of this node. |
Node[] |
getNeighbors()
Gets the adjacent nodes connected to this node irrespective of the EdgeType; the order is unspecified. |
java.util.List<Edge> |
getNeighbors(java.util.List<EdgeType> edgeTypePath)
Same as getNeighbors(List,NodeFilter) except that the
NodeFilter always accepts Nodes, nothing is filtered out. |
java.util.List<Edge> |
getNeighbors(java.util.List<EdgeType> edgeTypePath,
NodeFilter nf)
Gets a List of Edges to neighboring Nodes based on the supplied EdgeType path. |
Node[] |
getNeighbors(java.lang.String edgeTypeName)
Gets the adjacent nodes connected to this node through an Edge with the supplied EdgeType name; the order is unspecified. |
java.lang.String |
getType()
Get the type name of this node. |
int |
getUnweightedDegree()
Get the number of outgoing Edges. |
int |
getUnweightedDegree(EdgeType edgeType)
Get the number of outbound Edges of the supplied EdgeType. |
int |
getUnweightedDegree(java.lang.String nodeType)
Get the number of Edges which connect to a destination Node of the supplied node type. |
double |
getValue(int index)
Get the value associated with the attribute field at the supplied index. |
double |
getValue(java.lang.String fieldName)
Get the value associated with the named attribute field. |
double[] |
getValues()
Gets all of the values associated with this node. |
double |
getWeightedDegree()
Get the sum of all weights of outgoing Edges. |
double |
getWeightedDegree(EdgeType edgeType)
Get the sum of all weights of outbound Edges of the supplied EdgeType. |
double |
getWeightedDegree(java.lang.String nodeType)
Get the sum of all weights of Edges which connect to a destination Node of the supplied node type. |
int |
hashCode()
Returns a hash code value for this object. |
boolean |
isMissing(int index)
Return whether the value associated with the attribute field at the supplied index is missing. |
boolean |
isMissing(java.lang.String attribute)
Get whether the value associated with the named attribute field is "missing". |
int |
numEdges()
Gets the total number of edges for this node. |
int |
numEdges(java.lang.String edgeTypeName)
Gets the number of Edges to neighboring Nodes with the supplied EdgeType name. |
Edge |
removeEdge(java.lang.String edgeTypeName,
Node destNode)
Removes the Edge to the supplied destination Node via the supplied EdgeType name. |
void |
removeValue(int index)
Removes the value from the values array at the specified index and shrinks the values array accordingly. |
void |
setValue(int index,
double v)
Sets the value associated with the attribute field at the supplied index. |
void |
setValue(java.lang.String attribute,
double v)
Sets the value associated with the named attribute field. |
void |
setValues(double[] v)
Sets all of the values for this node. |
java.lang.String |
toString()
Returns a String representation for this object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Node(java.lang.String name, Attributes attributes, int index)
name
- a string value which, in combination with the Attributes, uniquely identifies this node.attributes
- an attribute container which, in combination with the name, uniquely identifies this node.index
- an index counter providing an offset into the
Graph Node array for quick lookups. Set by the Graph class
when creating new Nodes and adding them to it's own containers.
Note, each new Node type should get a separate zero-based
index.Method Detail |
---|
public Node copy(int index)
name
- a string value which, in combination with the Attributes, uniquely identifies this node.attributes
- an attribute container which, in combination with the name, uniquely identifies this node.index
- an index counter providing an offset into the
Graph Node array for quick lookups. Set by the Graph class
when creating new Nodes and adding them to it's own containers.
Note, each new Node type should get a separate zero-based
index.public java.lang.String getName()
public int getIndex()
public java.lang.String getType()
public Attributes getAttributes()
public void addValues()
java.lang.RuntimeException
- if the Attributes container holds less
Attribute fields than the current values array size.public void removeValue(int index)
index
- an integer specifying which element of the values array to remove.
java.lang.RuntimeException
- if the user attemps to remove other
than exactly one element, this could happen if the Attributes
container is not exactly one element smaller than the values
array. Also throws if the index is out of bounds.public int getAttributeIndex(java.lang.String attribute)
attribute
- the attribute name to lookup in this container.
java.lang.RuntimeException
- if the attribute isn't contained
within this node.public double getValue(int index)
index
- the integer index representing the attribute field
to lookup.
public boolean isMissing(int index)
index
- the integer index representing the attribute field
to lookup.
public double getValue(java.lang.String fieldName)
fieldName
- the String name representing the attribute
field to lookup.
java.lang.NullPointerException
- if the attribute isn't contained
within this node.public boolean isMissing(java.lang.String attribute)
attribute
- the String name representing the attribute
field to lookup.
java.lang.RuntimeException
- if the attribute isn't contained
within this node.public double[] getValues()
public void setValue(int index, double v)
index
- the integer index of the attribute field.v
- the double value to set.
java.lang.ArrayIndexOutOfBoundsException
- if the index is not
within the value array bounds.
java.lang.RuntimeException
- if the index is the key index and the
key field is not unknown, i.e. NaN.public void setValue(java.lang.String attribute, double v)
attribute
- the name of the attribute field being set.v
- the double value to set.
java.lang.RuntimeException
- if the attribute isn't contained within this node.
java.lang.RuntimeException
- if the index is the key index and the
key field is not unknown, i.e. NaN.public void setValues(double[] v)
v
- an array of double to be copied into this node's
values; the supplied array's size must match the number of
attributes in this node (not including the key attribute.)
java.lang.RuntimeException
- if the key field differs and the old
key field is not unknown, i.e. NaN.public void addEdge(Edge newEdge)
newEdge
- the Edge to be added to this node.
java.lang.RuntimeException
- if the Edge already exists.
java.lang.RuntimeException
- if the Edge's source Node does not
equal this.public Edge removeEdge(java.lang.String edgeTypeName, Node destNode)
edgeTypeName
- a String representing the EdgeType of the connection.destNode
- the destination Node for the Edge to be removed.
java.lang.RuntimeException
- if the Edge does not exist.public Edge[] getEdges()
public Edge[] getEdgesToNeighbor(Node destinationNode)
destinationNode
- the destination Node.
public Edge[] getEdgesToNeighbor(java.lang.String destinationNodeType)
destinationNodeType
- a String representation of the
destination Node type.
public Edge[] getEdgesToNeighbor(java.lang.String destinationNodeType, NodeFilter nf)
destinationNodeType
- a String representation of the
destination Node type.nf
- a NodeFilter to match against.
public Edge[] getEdgesByType(java.lang.String edgeTypeName)
edgeTypeName
- a String representing the Edge's EdgeType name.
public Edge[] getEdgesByType(java.lang.String edgeTypeName, NodeFilter nf)
edgeTypeName
- a String representing the Edge's EdgeType name.
public int getUnweightedDegree()
public int getUnweightedDegree(java.lang.String nodeType)
nodeType
- the String type name of the matching destination Nodes.
public int getUnweightedDegree(EdgeType edgeType)
edgeType
- an EdgeType to match against.
public double getWeightedDegree()
public double getWeightedDegree(java.lang.String nodeType)
nodeType
- the String type name of the matching destination Nodes.
public double getWeightedDegree(EdgeType edgeType)
edgeType
- an EdgeType to match against.
public Node[] getNeighbors()
public Node[] getNeighbors(java.lang.String edgeTypeName)
edgeTypeName
- the name of the EdgeType connecting
neighbor Nodes.
public Edge getEdge(java.lang.String edgeTypeName, Node neighbor)
edgeTypeName
- the String name of the EdgeType to consider.neighbor
- the destination node for the connecting edge.
public int numEdges()
public int numEdges(java.lang.String edgeTypeName)
edgeTypeName
- the EdgeType name Edges must have to be
included in this count.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the reference object with which to compare.
true
if this object is the same as the
argument; false
otherwise.public int compareTo(Node n)
compareTo
in interface java.lang.Comparable<Node>
n
- the Node to compare this object to.
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<Edge> getNeighbors(java.util.List<EdgeType> edgeTypePath, NodeFilter nf)
edgeTypePath
- a Listnf
- a NodeFilter which is applied against the final Node
(or neighbor); this Node must be accepted by the NodeFilter
before the neighbor is accepted into the returned list.
java.lang.RuntimeException
- if the supplied EdgeType path's first
element's source nodetype does not match the nodetype of this
Node.public java.util.List<Edge> getNeighbors(java.util.List<EdgeType> edgeTypePath)
getNeighbors(List,NodeFilter)
except that the
NodeFilter always accepts Nodes, nothing is filtered out.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |