org.graffiti.graph
Class AdjListEdge

java.lang.Object
  extended by org.graffiti.attributes.AbstractAttributable
      extended by org.graffiti.graph.AbstractGraphElement
          extended by org.graffiti.graph.AbstractEdge
              extended by org.graffiti.graph.AdjListEdge
All Implemented Interfaces:
Attributable, Edge, GraphElement

public class AdjListEdge
extends AbstractEdge
implements Edge, GraphElement

Implementation of the Edge interface for a Graph with adjacency list representation.

Version:
$Revision: 5779 $
See Also:
AdjListGraph, AdjListNode

Field Summary
 
Fields inherited from class org.graffiti.graph.AbstractGraphElement
graph
 
Fields inherited from class org.graffiti.attributes.AbstractAttributable
attributes
 
Fields inherited from interface org.graffiti.graph.Edge
DIRECTED, UNDIRECTED
 
Constructor Summary
protected AdjListEdge(Graph graph, Node source, Node target, boolean directed)
          Creates a new GraphEdge instance going from Node source to Node target being directed or not.
protected AdjListEdge(Graph graph, Node source, Node target, boolean directed, CollectionAttribute coll)
          Creates a new GraphEdge instance going from Node source to Node target being directed or not.
 
Method Summary
protected  void doReverse()
          Swaps source and target of the edge.
protected  void doSetDirected(boolean directed)
          Determines if an Edge is directed (true) or not.
protected  void doSetSource(Node source)
          Sets the source of the current Edge to source.
 void doSetTarget(Node target)
          Sets the target of the current Edge to target.
 Node getSource()
          Returns the source of the Edge.
 Node getTarget()
          Returns the target of the Edge.
 boolean isDirected()
          Returns true, if the Edge is directed, false otherwise.
 
Methods inherited from class org.graffiti.graph.AbstractEdge
reverse, setDirected, setSource, setTarget
 
Methods inherited from class org.graffiti.graph.AbstractGraphElement
getGraph, getListenerManager, remove, toString
 
Methods inherited from class org.graffiti.attributes.AbstractAttributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graffiti.graph.Edge
reverse, setDirected, setSource, setTarget
 
Methods inherited from interface org.graffiti.graph.GraphElement
getGraph, remove
 
Methods inherited from interface org.graffiti.attributes.Attributable
addAttribute, addBoolean, addByte, addDouble, addFloat, addInteger, addLong, addShort, addString, changeBoolean, changeByte, changeDouble, changeFloat, changeInteger, changeLong, changeShort, changeString, containsAttribute, getAttribute, getAttributes, getBoolean, getByte, getDouble, getFloat, getInteger, getListenerManager, getLong, getShort, getString, removeAttribute, setBoolean, setByte, setDouble, setFloat, setInteger, setLong, setShort, setString
 

Constructor Detail

AdjListEdge

protected AdjListEdge(Graph graph,
                      Node source,
                      Node target,
                      boolean directed)
               throws GraphElementNotFoundException
Creates a new GraphEdge instance going from Node source to Node target being directed or not.

Parameters:
graph - the Graph the Edge belongs to.
source - the source of the Edge.
target - the target of the Edge.
directed - indicating if the Edge is directed or not.
Throws:
GraphElementNotFoundException - of source or target cannot be found in the Graph.

AdjListEdge

protected AdjListEdge(Graph graph,
                      Node source,
                      Node target,
                      boolean directed,
                      CollectionAttribute coll)
               throws GraphElementNotFoundException
Creates a new GraphEdge instance going from Node source to Node target being directed or not.

Parameters:
graph - the Graph the Edge belongs to.
source - the source of the Edge.
target - the target of the Edge.
directed - indicating if the Edge is directed or not.
coll - the CollectionAttribute of the newly created AdjListNode.
Throws:
GraphElementNotFoundException - of source or target cannot be found in the Graph.
Method Detail

isDirected

public boolean isDirected()
Returns true, if the Edge is directed, false otherwise.

Specified by:
isDirected in interface Edge
Returns:
true, if the Edge is directed, false otherwise.

getSource

public Node getSource()
Returns the source of the Edge.

Specified by:
getSource in interface Edge
Returns:
the source of the Edge.

getTarget

public Node getTarget()
Returns the target of the Edge.

Specified by:
getTarget in interface Edge
Returns:
the target of the Edge.

doSetTarget

public void doSetTarget(Node target)
                 throws GraphElementNotFoundException,
                        IllegalArgumentException
Sets the target of the current Edge to target. Target must be contained in the same Graph as the Edge. Informs the ListenerManager about the change.

Specified by:
doSetTarget in class AbstractEdge
Parameters:
target - the target to be set.
Throws:
GraphElementNotFoundException - if the target cannot be found in the Graph.
IllegalArgumentException - if target is not of type AdjListNode.

doReverse

protected void doReverse()
Swaps source and target of the edge.

Specified by:
doReverse in class AbstractEdge

doSetDirected

protected void doSetDirected(boolean directed)
Determines if an Edge is directed (true) or not.

Specified by:
doSetDirected in class AbstractEdge
Parameters:
directed - true, if the Edge is destined to be directed, false otherwise.

doSetSource

protected void doSetSource(Node source)
                    throws GraphElementNotFoundException,
                           IllegalArgumentException
Sets the source of the current Edge to source. source must be contained in the same Graph as the current Edge.

Specified by:
doSetSource in class AbstractEdge
Parameters:
source - the source to be set.
Throws:
GraphElementNotFoundException - if source cannot be found in the Graph.
IllegalArgumentException - if source is not of type AdjListNode


Generated at 2012-05-30 11:00:36 PM CEST