com.tensegrity.graph.model
Interface Node

All Superinterfaces:
Attributable, AttributableOnSet, GraphObject
All Known Subinterfaces:
Subgraph

public interface Node
extends GraphObject

This interface represents the functionality of any potential vertex in a graph. We call this vertex a Node because it tends to confuse fewer non-technical people who come into contact with graph theory and this framework.

Constructing a Node (and its related objects) is done by means of a GraphModelFactory, which will hide the particular implementation classes from client code.

Implementations should not be coupled to any kind of visualization.

Node objects that are dereferenced will be garbage collected.

Two types of event listeners are available for notification. Instances of NodeListener listen to events coming from one Node object, while GraphEventMediator instances listen to events coming from an entire Graph tree. Any number of event listeners may be added to a Node.

Additionally, there are corresponding vetoable listeners and mediators defined in the event package of the API. These listeners and mediators contain methods that are invoked prior to a specific event. By throwing an exception, code can indicate that it would like to prevent a specific event from happening, thereby sending a veto for the event. These special listeners are VetoableGraphListener and VetoableGraphEventMediatorListener.

Version:
$Id: Node.java,v 1.53 2005/10/26 08:46:59 MichaelKegel Exp $
Author:
Stepan Rutz
See Also:
Graph, Edge, GraphObject, NodeListener

Field Summary
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 void addNodeListener(NodeListener listener)
          Adds a NodeListener to this Node.
 Node deepCopy()
          Returns a deep copy of the node.
 java.util.List getAdjacentEdges()
          Returns a list containing all adjacent edges of this node.
 java.util.List getAdjacentNodes()
          Returns a list containing all adjacent nodes.
 int getDegree()
          Returns the number of edges leaving this node added to the number of edges entering this node.
 java.util.List getInboundEdges()
          Returns a list containing the incoming edges of this node.
 java.util.List getInboundNodes()
          Returns a list containing the nodes connected via incoming edges.
 int getIndegree()
          Returns the number of edges entering this node.
 NodeInfo getNodeInfo()
          Returns the NodeInfo associated with this Node.
 java.util.List getOutboundEdges()
          Returns a list containing the outgoing edges of this node.
 java.util.List getOutboundNodes()
          Returns a list containing the nodes connected via outgoing edges.
 int getOutdegree()
          Returns the number of edges leaving this node.
 Port getPortByID(long id)
          Returns the Port with the given id.
 java.util.List getPorts()
          Returns a list of the ports of this node.
 void internalResetPortNumbers()
          Resets the ids of the ports.
 Edge isConnectedFromNode(Node node)
          Determines whether this node is connected from the given node.
 Edge isConnectedToNode(Node node)
          Determines whether this node is connected to the given node.
 void removeNodeListener(NodeListener listener)
          Removes a NodeListener from this Node.
 void setID(long id)
          NOTE: This method is for internal use only and should never be invoked by the client.
 void setNodeInfo(NodeInfo nodeInfo)
          Sets the NodeInfo associated with this Node.
 void setPorts(java.util.List ports)
          Sets the List of ports given by ports as the new ports of this node.
 
Methods inherited from interface com.tensegrity.graph.model.GraphObject
addCustomAttribute, assertCustomAttribute, assertCustomAttribute, fillInDump, getCustomAttributes, getDescription, getID, getLabel, getParentContainer, getUniqueID, registerEventMediator, registerEventMediatorInternal, registerVetoableEventMediator, removeCustomAttribute, setCustomAttributes, setDescription, setLabel
 
Methods inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
addAttributableOnSetListener, areAttributableEventsEnabled, disableAttributableEvents, enableAttributableEvents, getAttributes, getAttributesTree, removeAttributableOnSetListener, setAttributes, setAttributesTree
 
Methods inherited from interface com.tensegrity.generic.attribute.Attributable
getAttribute, getAttributeType, getAttributeValue, setAttribute, setAttributeValue
 

Method Detail

getDegree

public int getDegree()
Returns the number of edges leaving this node added to the number of edges entering this node. Incoming edges do not contribute to the degree in the case of directed edges.

Returns:
the degree of this node.

Find more information in the class documentation


getIndegree

public int getIndegree()
Returns the number of edges entering this node. You must not invoke this method on an undirected graph.

Returns:
the number of edges entering this node.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


getOutdegree

public int getOutdegree()
Returns the number of edges leaving this node. You must not invoke this method on an undirected graph.

Returns:
the number of edges leaving this node.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


getAdjacentEdges

public java.util.List getAdjacentEdges()
Returns a list containing all adjacent edges of this node. The list reflects the current state and is not updated after its creation.

Returns:
a list containing all adjacent edges of this node.

Find more information in the class documentation


getAdjacentNodes

public java.util.List getAdjacentNodes()
Returns a list containing all adjacent nodes.

Returns:
a list containing all adjacent nodes.

Find more information in the class documentation


getInboundEdges

public java.util.List getInboundEdges()
Returns a list containing the incoming edges of this node. The number of edges in this list is equal to the value returned by method getIndegree().

Returns:
a list containing the incoming edges of this node.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


getOutboundEdges

public java.util.List getOutboundEdges()
Returns a list containing the outgoing edges of this node. The number of edges in this list is equal to the value returned by method getOutdegree().

Returns:
a list containing the outgoing edges of this node.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


getInboundNodes

public java.util.List getInboundNodes()
Returns a list containing the nodes connected via incoming edges. The number of nodes in this list is equal to the value returned by getIndegree(). All nodes in this operator are also indirectly available by invoking the getInboundEdges method and then invoking getTarget() on the obtained edges.

Returns:
a list containing the nodes connected via incoming edges.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


getOutboundNodes

public java.util.List getOutboundNodes()
Returns a list containing the nodes connected via outgoing edges. The number of nodes in this list is equal to the value returned by getOutdegree(). All nodes in this operator are also indirectly available by invoking the getOutboundEdges method and then invoking getSource() on the obtained edges.

Returns:
a list containing the nodes connected via outgoing edges.
Throws:
GraphTypeException - thrown if the method is invoked on an undirected graph.

Find more information in the class documentation


isConnectedFromNode

public Edge isConnectedFromNode(Node node)
Determines whether this node is connected from the given node. This means this node is the target of the edge and the given node is the source of the edge.

Parameters:
node - the node which is checked for connectivity.
Returns:
the edge that represents the connection or null if no such connection exists.

Find more information in the class documentation


isConnectedToNode

public Edge isConnectedToNode(Node node)
Determines whether this node is connected to the given node. This means this node is the source of the edge and the given node is the target of the edge.

Parameters:
node - the node which is checked for connectivity.
Returns:
the edge that represents the connection or null if no such connection exists.

Find more information in the class documentation


getNodeInfo

public NodeInfo getNodeInfo()
Returns the NodeInfo associated with this Node.

Returns:
the NodeInfo associated with this Node. The returned value may be null if no info is associated with this Node.

setNodeInfo

public void setNodeInfo(NodeInfo nodeInfo)
Sets the NodeInfo associated with this Node.

Parameters:
nodeInfo - the NodeInfo to associate with this Node.

getPortByID

public Port getPortByID(long id)
Returns the Port with the given id. If the Node has no Port with the given id null is returned.

Parameters:
id - the id of the Port to return
Returns:
Port the Port specified through the given id or null

Find more information in the class documentation


getPorts

public java.util.List getPorts()
Returns a list of the ports of this node. The returned list is read-only and may not be modified.

Returns:
list of the ports of this node.

Find more information in the class documentation


setPorts

public void setPorts(java.util.List ports)
Sets the List of ports given by ports as the new ports of this node.
NOTE: This method is for internal use only and it is strongly recommended to not use it on client side.

If this method is used preconditions must be maintained on the model and on the view. Therefore after invoking this method on the model all associated views must be adjusted accordingly. In the case of this instance being of the type Subgraph, ports of nested nodes must be recursively adjusted on each nested level.

However clients are not required to use this method. There are other ways of adjusting/changing ports. Refer to the Graph manual for further information.

Parameters:
ports - the list of ports to use with this node

addNodeListener

public void addNodeListener(NodeListener listener)
Adds a NodeListener to this Node.

Parameters:
listener - the NodeListener to add to this Node.

removeNodeListener

public void removeNodeListener(NodeListener listener)
Removes a NodeListener from this Node.

Parameters:
listener - the NodeListener to remove from this Node.

deepCopy

public Node deepCopy()
Returns a deep copy of the node. Recursively deep copies all internal fields of the node.

Returns:
a deep copy of the node.

setID

public void setID(long id)
NOTE: This method is for internal use only and should never be invoked by the client.

Parameters:
id - the new id for this Node

internalResetPortNumbers

public void internalResetPortNumbers()
Resets the ids of the ports. NOTE: This method is for internal use only.



Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.