com.tensegrity.graph.model
Interface Graph

All Superinterfaces:
Attributable, AttributableOnSet, GraphObjectContainer

public interface Graph
extends GraphObjectContainer, AttributableOnSet

This interface defines an abstract Graph without any notion of a visualization. This class can be used on its own for applying graph algorithms and for deriving specialized graph classes.
Both directed and undirected graphs are supported.
A Graph consists of Node and Edge objects. These are the parts of the graph model that can be accessed through the Graph interface and whose abstraction is commonly defined in the base interface GraphObject. This component interface defines the functionality common to both nodes and edges, as illustrated in the following class diagram.

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

Upon adding, the ID of any GraphObject is automatically assigned. Before adding, however, the ID should be set to -1.
Each GraphObject may only be added to at most one Graph instance. Adding it to a Graph instance while still managed by another will produce an exception.
Removing a GraphObject will reset its ID to -1.

Graph objects that are dereferenced will be garbage collected.

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

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.

A Graph contains and manages objects of type Node and Edge. Instances of these classes may be added to and removed from a Graph. Both types are derived from the superclass GraphObject.

Many methods in this interface specification may be found in the the parent interface GraphObjectContainer, which allows generic handling of both Graph and Subgraph instances.

Version:
$Id: Graph.java,v 1.71 2006/04/25 07:10:27 MichaelKegel Exp $
Author:
Stepan Rutz
See Also:
Node, Edge, Subgraph, Port, GraphObject

Field Summary
static int EVENT_MASK_CASCADE_NODE_DELETE
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_ADDED
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_ATTACH_REJECTED
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_PRE_ADD
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_PRE_REMOVE
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_PRE_SPLIT
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_REMOVED
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_EDGE_SPLIT
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_NODE_ADDED
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_NODE_PRE_ADD
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_NODE_PRE_REMOVE
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_NODE_REMOVED
          Enumeration for setting event masks for the different type of events.
static int EVENT_MASK_PRE_CASCADE_NODE_DELETE
          Enumeration for setting event masks for the different type of events.
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 void addCustomAttribute(Attribute attribute)
          Adds the Attribute given by attribute to the custom attributes of the Graph.
 void addEventMediatorListener(GraphEventMediatorListener listener)
          Adds the GraphEventMediatorListener given by listener to the list of GraphEventMediatorListeners that will be informed of all events related to graph objects that occur.
 void addEventMediatorListenerInternal(GraphEventMediatorListener listenerInternal)
          Adds the GraphEventMediatorListener given by listener to the list of GraphEventMediatorListeners that will be informed of all events related to graph objects that occur.
 void addGraphListener(GraphListener listener)
          Adds a graph listener to the graphs internal structure.
 void addVetoableEventMediatorListener(VetoableGraphEventMediatorListener listener)
          Adds the VetoableGraphEventMediatorListener given by listener to the list of VetoableGraphEventMediatorListeners that will be informed of all vetoable events related to graph objects that occur.
 void addVetoableGraphListener(VetoableGraphListener listener)
          Adds a graph listener to the graph's internal structure.
 Graph deepCopy()
          Returns a deep independent copy of the Graph.
 Graph deepCopyWithoutEdges()
          Copies this Graph and its type to a new empty Graph and omitting the edges.
 Graph deepCopyWithoutNodesAndEdges()
          Copies this Graph and its type to a new empty Graph and omitting the nodes and edges.
 void disableVerify()
          Disables internal invariant verifications.
 void enableVerify()
          Enables internal invariant verifications.
 void enableVetosFromStack()
          This method is API internal and should not be invoked by clients.
 void enableVetosWithStack(boolean enable)
          This method is API internal and should not be invoked by clients.
 AttributeSet getCustomAttributes()
          Returns an AttributeSet that contains all custom attributes currently assigned to the Graph or null if no custom attribute is assigned to the Graph.
 Subgraph getSubgraph()
          Returns a reference to the Subgraph this Graph is a part of.
 int getVersionID()
          Gets the version-id of the Graph.
 void removeCustomAttribute(java.lang.String attributename)
          Removes the custom Attribute with the name given by attributename from the Graphs custom attributes.
 void removeEventMediatorListener(GraphEventMediatorListener listener)
          Removes the GraphEventMediatorListener given by listener from the list of GraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.
 void removeEventMediatorListenerInternal(GraphEventMediatorListener listenerInternal)
          Removes the GraphEventMediatorListener given by listener from the list of GraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.
 void removeGraphListener(GraphListener listener)
          Removes a graph listener.
 void removeVetoableEventMediatorListener(VetoableGraphEventMediatorListener listener)
          Removes the VetoableGraphEventMediatorListener given by listener from the list of VetoableGraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.
 void removeVetoableGraphListener(VetoableGraphListener listener)
          Removes a graph listener.
 void setCustomAttributes(AttributeSet customAttributes)
          Sets the Attributes within the AttributeSet given by customAttributes to the custom attributes currently added to the Graph.
 void visitSubgraphs(GraphVisitor visitor)
          Traverse the sub graphs of this graph by means of the given GraphVisitor.
 
Methods inherited from interface com.tensegrity.graph.model.GraphObjectContainer
addEdge, addEdges, addNode, addNodes, buildAdjacencyMatrix, disableGraphEvents, disableGraphEventsInternal, enableGraphEvents, enableGraphEventsInternal, findMultiEdge, fireCascadeNodeDeleteInternal, fireEdgeSplitInternal, fireNodePreRemove, fireNodeRemoved, firePreCascadeNodeDeleteInternal, firePreEdgeSplitInternal, getEdgeArray, getEdgeByID, getEdgeCount, getEdges, getEventmask, getEventmaskInternal, getNodeArray, getNodeByID, getNodeCount, getNodes, getObjectByID, getParentContainer, getRootContainer, isDirected, isMultiEdge, isMultiGraph, removeEdge, removeNode, setDirected, setMultiGraph
 
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
 

Field Detail

EVENT_MASK_NODE_ADDED

public static final int EVENT_MASK_NODE_ADDED
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_NODE_REMOVED

public static final int EVENT_MASK_NODE_REMOVED
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_ADDED

public static final int EVENT_MASK_EDGE_ADDED
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_REMOVED

public static final int EVENT_MASK_EDGE_REMOVED
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_ATTACH_REJECTED

public static final int EVENT_MASK_EDGE_ATTACH_REJECTED
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_SPLIT

public static final int EVENT_MASK_EDGE_SPLIT
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_NODE_PRE_ADD

public static final int EVENT_MASK_NODE_PRE_ADD
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_NODE_PRE_REMOVE

public static final int EVENT_MASK_NODE_PRE_REMOVE
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_PRE_ADD

public static final int EVENT_MASK_EDGE_PRE_ADD
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_PRE_REMOVE

public static final int EVENT_MASK_EDGE_PRE_REMOVE
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_EDGE_PRE_SPLIT

public static final int EVENT_MASK_EDGE_PRE_SPLIT
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_PRE_CASCADE_NODE_DELETE

public static final int EVENT_MASK_PRE_CASCADE_NODE_DELETE
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values

EVENT_MASK_CASCADE_NODE_DELETE

public static final int EVENT_MASK_CASCADE_NODE_DELETE
Enumeration for setting event masks for the different type of events.

See Also:
Constant Field Values
Method Detail

addCustomAttribute

public void addCustomAttribute(Attribute attribute)
Adds the Attribute given by attribute to the custom attributes of the Graph.

Parameters:
attribute - the custom Attribute to add

removeCustomAttribute

public void removeCustomAttribute(java.lang.String attributename)
Removes the custom Attribute with the name given by attributename from the Graphs custom attributes.

Parameters:
attributename - the name of the custom Attribute to remove

getCustomAttributes

public AttributeSet getCustomAttributes()
Returns an AttributeSet that contains all custom attributes currently assigned to the Graph or null if no custom attribute is assigned to the Graph.
NOTICE: The Attributes within the returned AttributeSet are copies of the custom attributes currently added to the Graph and no references. So that if you want to change them you have to call setCustomAttributes(AttributeSet) afterwards.

Returns:
AttributeSet a set with the custom attributes currently added to the Graph

setCustomAttributes

public void setCustomAttributes(AttributeSet customAttributes)
Sets the Attributes within the AttributeSet given by customAttributes to the custom attributes currently added to the Graph. This is done by a merge of the given Attributes and the custom attributes currently added. The merge is done by the following rules:

Parameters:
customAttributes - The AttributeSet with the Attributes to set

enableVerify

public void enableVerify()
Enables internal invariant verifications. This method should not be invoked by the client. Please keep in mind that enabling the verify-mode leads to dramatic loss of efficiency.


disableVerify

public void disableVerify()
Disables internal invariant verifications. This method should not be invoked by the client. Please keep in mind that disabling the verify-mode leads to a dramatic gain in efficiency.


enableVetosWithStack

public void enableVetosWithStack(boolean enable)
This method is API internal and should not be invoked by clients.

Depending on the given boolean this method enables or disables all vetoable events for this Graph object and nested Subgraph objects as well.
Additionally the old state is put onto a stack so that it can be easily restored afterwards.
Notice:When setting the state through this method one must call the method enableVetosFromStack() afterwards. Otherwise the internal stack gets demaged.

Parameters:
enable - flag indicating whether to raise vetoable events
See Also:
enableVetosFromStack()

enableVetosFromStack

public void enableVetosFromStack()
This method is API internal and should not be invoked by clients.

Restores the old state for raising of vetoable events from the internal stack. In order to do so the method enableVetosWithStack(boolean) must have been called beforehand.
The state is restored for this Graph and nested Subgraph objects as well.

See Also:
enableVetosWithStack(boolean)

visitSubgraphs

public void visitSubgraphs(GraphVisitor visitor)
Traverse the sub graphs of this graph by means of the given GraphVisitor.

Parameters:
visitor - object to use during traversal.

Find more information in the class documentation


addGraphListener

public void addGraphListener(GraphListener listener)
Adds a graph listener to the graphs internal structure.

Parameters:
listener - the graph listener instance to add to the internal list of graph listeners that is notified when an event occurs.

Find more information in the class documentation


removeGraphListener

public void removeGraphListener(GraphListener listener)
Removes a graph listener.

Parameters:
listener - the graph listener instance to remove.

addVetoableGraphListener

public void addVetoableGraphListener(VetoableGraphListener listener)
Adds a graph listener to the graph's internal structure.

Parameters:
listener - the graph listener instance to add to the internal list of graph listeners that is notified when an event occurs.

removeVetoableGraphListener

public void removeVetoableGraphListener(VetoableGraphListener listener)
Removes a graph listener.

Parameters:
listener - the graph listener instance to remove.

addEventMediatorListener

public void addEventMediatorListener(GraphEventMediatorListener listener)
Adds the GraphEventMediatorListener given by listener to the list of GraphEventMediatorListeners that will be informed of all events related to graph objects that occur.

Parameters:
listener - the GraphEventMediatorListener to add

Find more information in the class documentation


removeEventMediatorListener

public void removeEventMediatorListener(GraphEventMediatorListener listener)
Removes the GraphEventMediatorListener given by listener from the list of GraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.

Parameters:
listener - the GraphEventMediatorListener to remove

addEventMediatorListenerInternal

public void addEventMediatorListenerInternal(GraphEventMediatorListener listenerInternal)
Adds the GraphEventMediatorListener given by listener to the list of GraphEventMediatorListeners that will be informed of all events related to graph objects that occur.

This method is API internal and should not be invoked by clients

Parameters:
listenerInternal - the GraphEventMediatorListener to add

removeEventMediatorListenerInternal

public void removeEventMediatorListenerInternal(GraphEventMediatorListener listenerInternal)
Removes the GraphEventMediatorListener given by listener from the list of GraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.

This method is API internal and should not be invoked by clients

Parameters:
listenerInternal - the GraphEventMediatorListener to remove

addVetoableEventMediatorListener

public void addVetoableEventMediatorListener(VetoableGraphEventMediatorListener listener)
Adds the VetoableGraphEventMediatorListener given by listener to the list of VetoableGraphEventMediatorListeners that will be informed of all vetoable events related to graph objects that occur.

Parameters:
listener - the VetoableGraphEventMediatorListener to add

removeVetoableEventMediatorListener

public void removeVetoableEventMediatorListener(VetoableGraphEventMediatorListener listener)
Removes the VetoableGraphEventMediatorListener given by listener from the list of VetoableGraphEventMediatorListeners so that he will no longer be informed about events related to graph objects.

Parameters:
listener - the VetoableGraphEventMediatorListener to remove

getSubgraph

public Subgraph getSubgraph()
Returns a reference to the Subgraph this Graph is a part of. If this Graph is not part of a Subgraph then null is returned.

Returns:
a reference to the Subgraph or null.

Find more information in the class documentation


getVersionID

public int getVersionID()
Gets the version-id of the Graph. The versionid is incremented each time a modification of the Graph takes place.

Returns:
a versioning stampnumber of the current state of the Graph.

deepCopy

public Graph deepCopy()
Returns a deep independent copy of the Graph. All edges, nodes are deep-copied. This includes node- and edgeinfos.

Returns:
a new deep-copied Graph. all edges, nodes are deep-copied.

deepCopyWithoutNodesAndEdges

public Graph deepCopyWithoutNodesAndEdges()
                                   throws GraphException
Copies this Graph and its type to a new empty Graph and omitting the nodes and edges. This produces a new empty Graph.

Returns:
a Graph without nodes and edges. These copies are independent objects, but have cloned attributes of their originals.
Throws:
GraphException - is thrown if the cloning fails.

deepCopyWithoutEdges

public Graph deepCopyWithoutEdges()
                           throws GraphException
Copies this Graph and its type to a new empty Graph and omitting the edges. This produces a new Graph with just isolated nodes.

Returns:
a Graph without edges containing copies of the original nodes. These copies are independent objects, but have cloned attributes of their originals.
Throws:
GraphException - is thrown if the cloning fails.


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