public class AbstractEdge extends AbstractElement implements Edge
This class provides a basic implementation of Edge
interface, to
minimize the effort required to implement this interface.
Although this class is abstract it implements all the methods of
Edge
and
AbstractElement
. It has a low
memory overhead (3 references and a boolean as fields). All Edge
methods are executed in O(1) time.
AbstractElement.AttributeChangeEvent
Modifier and Type | Field and Description |
---|---|
protected boolean |
directed
Is this edge directed ?
|
protected AbstractGraph |
graph
The graph to which this edge belongs
|
protected AbstractNode |
source
The source node
|
protected AbstractNode |
target
The target node
|
attributes, attributesBeingRemoved, id
Modifier | Constructor and Description |
---|---|
protected |
AbstractEdge(String id,
AbstractNode source,
AbstractNode target,
boolean directed)
Constructs a new edge.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attributeChanged(AbstractElement.AttributeChangeEvent event,
String attribute,
Object oldValue,
Object newValue)
Called for each change in the attribute set.
|
<T extends Node> |
getNode0()
First node of the edge.
|
<T extends Node> |
getNode1()
Second node of the edge.
|
<T extends Node> |
getOpposite(Node node)
When knowing one node and one edge of this node, this method return the
node at the other end of the edge.
|
<T extends Node> |
getSourceNode()
Start node.
|
<T extends Node> |
getTargetNode()
End node.
|
boolean |
isDirected()
Is the edge directed ?.
|
boolean |
isLoop()
Does the source and target of this edge identify the same node ?.
|
protected boolean |
nullAttributesAreErrors()
This implementation calls the corresponding method of the parent graph
|
String |
toString()
Override the Object method
|
addAttribute, addAttributes, changeAttribute, clearAttributes, clearAttributesWithNoEvent, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, setIndex
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
protected AbstractNode source
protected AbstractNode target
protected boolean directed
protected AbstractGraph graph
protected AbstractEdge(String id, AbstractNode source, AbstractNode target, boolean directed)
id
- Unique identifier of this edge.source
- Source node.target
- Target node.directed
- Indicates if the edge is directed.protected void attributeChanged(AbstractElement.AttributeChangeEvent event, String attribute, Object oldValue, Object newValue)
AbstractElement
attributeChanged
in class AbstractElement
event
- The type of event among ADD, CHANGE and REMOVE.attribute
- The attribute name that changed.oldValue
- The old value of the attribute, null if the attribute was
added.newValue
- The new value of the attribute, null if the attribute is about
to be removed.protected boolean nullAttributesAreErrors()
nullAttributesAreErrors
in class AbstractElement
AbstractElement.nullAttributesAreErrors()
public String toString()
AbstractElement
toString
in class AbstractElement
public <T extends Node> T getNode0()
Edge
This is equivalent to the Edge.getSourceNode()
method, but may be
clearer in the source code if the graph you are using is not directed.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getNode0();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getNode0
in interface Edge
Edge.getNode1()
,
Edge.getSourceNode()
public <T extends Node> T getNode1()
Edge
This is equivalent to the Edge.getTargetNode()
method, but may be
clearer in the source code if the graph you are using is not directed.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getNode1();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getNode1
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public <T extends Node> T getOpposite(Node node)
Edge
Return null if the given node is not at any end of the edge.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getOppositeNode((ExtendedNode) m);the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getOpposite
in interface Edge
node
- The node we search the opposite of.public <T extends Node> T getSourceNode()
Edge
When the edge is directed this is the source node, in this case you can
get the opposite node using Edge.getTargetNode()
. This is equivalent
to the Edge.getNode0()
method but may be clearer in the source code
if the graph you are using is directed.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getSourceNode();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getSourceNode
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public <T extends Node> T getTargetNode()
Edge
When the edge is directed this is the target node, in this case you can
get the opposite node using Edge.getSourceNode()
. This is equivalent
to the Edge.getNode1()
method but may be clearer in the source code
if the graph you are using is directed.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getTargetNode();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getTargetNode
in interface Edge
Edge.getNode1()
,
Edge.getSourceNode()
public boolean isDirected()
Edge
isDirected
in interface Edge
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses