com.tensegrity.graph.model
Interface Edge

All Superinterfaces:
Attributable, AttributableOnSet, GraphObject

public interface Edge
extends GraphObject

A graph Edge (link, arc, connection, association) in the abstract. Edges are defined by the nodes to which they are connected (source and target). In an undirected graph, edges do not distinguish these nodes.

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

An Edge can be queried for its incoming and outgoing nodes. This information is stored in the Edge itself as well as in the nodes it is connected to. This redundant data storage results in better performance when retrieving connection information. On the other hand, redundant data can become inconsistent if not synchronized properly. This is the reason why updates to all connection information is only allowed through the GraphObjectContainer interface and not by manipulating nodes and edges themselves.

Edge objects that are dereferenced will be garbage collected.

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

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.

Functionality that is common to both the Edge and Node interfaces is defined in the base interface GraphObject.

Version:
$Id: Edge.java,v 1.41 2005/04/15 10:34:39 AndreasEbbert Exp $
Author:
Stepan Rutz
See Also:
Graph, Subgraph, Node, GraphObject, GraphObjectContainer, EdgeListener

Field Summary
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Method Summary
 void addEdgeListener(EdgeListener listener)
          Adds a EdgeListener to this Edge.
 Edge createIsolatedCopy(Node source, Node target)
          Copies the attributes of the edge and constructs a new object.
 Edge deepCopy(Node source, Node target)
          Returns a deep copy of the Edge.
 EdgeInfo getEdgeInfo()
          Returns the EdgeInfo associated with this Edge.
 Node getOpposite(Node node)
          Returns the node of the Edge that is not the given Node.
 Node getSource()
          Gets the Node at the source end of this Edge.
 Node getTarget()
          Gets the Node at the target end of this Edge.
 int getWeight()
          Returns the weight of the Edge.
 void invert()
          Swaps source and target pointers, effectively inverting the direction of this edge
 void removeEdgeListener(EdgeListener listener)
          Removes a EdgeListener from this Edge.
 void setEdgeInfo(EdgeInfo edgeInfo)
          Sets the EdgeInfo associated with this Edge.
 void setID(long id)
          NOTE:
This method is for API internal use only.
 void setSourceInternal(Node source)
          NOTE:
This method is for internal use only and should never be invoked by the client.
 void setTargetInternal(Node target)
          NOTE:
This method is for internal use only and should never be invoked by the client.
 void setWeight(int weight)
          Sets the weight of the Edge.
 
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

addEdgeListener

public void addEdgeListener(EdgeListener listener)
Adds a EdgeListener to this Edge.

Parameters:
listener - the EdgeListener to add to this Edge.

removeEdgeListener

public void removeEdgeListener(EdgeListener listener)
Removes a EdgeListener from this Edge.

Parameters:
listener - the EdgeListener to remove from this Edge.

createIsolatedCopy

public Edge createIsolatedCopy(Node source,
                               Node target)
Copies the attributes of the edge and constructs a new object. Next the source and target pointers of the newly constructed object are initialized with the source,target nodes given as parameters. The purpose of this method is to be able to ask a node to copy itself in an isolated way maintaining attributes.

Parameters:
source - source Node to associate the copy with.
target - target Node to associate the copy with.
Returns:
the copied Edge instance.

getWeight

public int getWeight()
Returns the weight of the Edge.

Returns:
weight of the Edge.

setWeight

public void setWeight(int weight)
Sets the weight of the Edge.

Parameters:
weight - the new weight of the Edge.

setID

public void setID(long id)
NOTE:
This method is for API internal use only. Client code must never invoke this method.

Parameters:
id - the id to set (internal use only).

getSource

public Node getSource()
Gets the Node at the source end of this Edge.

Returns:
the Node at the start of this Edge.

Find more information in the class documentation


setSourceInternal

public void setSourceInternal(Node source)
NOTE:
This method is for internal use only and should never be invoked by the client.

Parameters:
source - the new source to set for this Edge.

setTargetInternal

public void setTargetInternal(Node target)
NOTE:
This method is for internal use only and should never be invoked by the client.

Parameters:
target - the new target to set for this Edge.

getTarget

public Node getTarget()
Gets the Node at the target end of this Edge.

Returns:
the Node at the end of this Edge.

Find more information in the class documentation


getEdgeInfo

public EdgeInfo getEdgeInfo()
Returns the EdgeInfo associated with this Edge.

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

Find more information in the class documentation


setEdgeInfo

public void setEdgeInfo(EdgeInfo edgeInfo)
Sets the EdgeInfo associated with this Edge.

Parameters:
edgeInfo - the EdgeInfo to associate with this Edge.

invert

public void invert()
Swaps source and target pointers, effectively inverting the direction of this edge


deepCopy

public Edge deepCopy(Node source,
                     Node target)
Returns a deep copy of the Edge.

Parameters:
source - the source Node to associate the copy with.
target - the target Node to associate the copy with.
Returns:
deep copy of the Edge.

getOpposite

public Node getOpposite(Node node)
Returns the node of the Edge that is not the given Node. This method is only meaningful in the context of undirected graphs.

Parameters:
node - the Node that is the opposite Node of the returned Node.
Returns:
the opposite of the passed Node.

Find more information in the class documentation



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