org.graphstream.graph.implementations
Class AbstractEdge

java.lang.Object
  extended by org.graphstream.graph.implementations.AbstractElement
      extended by org.graphstream.graph.implementations.AbstractEdge
All Implemented Interfaces:
Edge, Element

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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
AbstractElement.AttributeChangeEvent
 
Method Summary
<T extends Node>
T
getNode0()
          First node of the edge.
<T extends Node>
T
getNode1()
          Second node of the edge.
<T extends Node>
T
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>
T
getSourceNode()
          Start node.
<T extends Node>
T
getTargetNode()
          End node.
 boolean isDirected()
          Is the edge directed ?.
 boolean isLoop()
          Does the source and target of this edge identify the same node ?.
 String toString()
          Override the Object method
 
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graphstream.graph.Element
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
 

Method Detail

toString

public String toString()
Description copied from class: AbstractElement
Override the Object method

Overrides:
toString in class AbstractElement

getNode0

public <T extends Node> T getNode0()
Description copied from interface: Edge
First node of the 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.

Specified by:
getNode0 in interface Edge
Returns:
The first node of the edge.
See Also:
Edge.getNode1(), Edge.getSourceNode()

getNode1

public <T extends Node> T getNode1()
Description copied from interface: Edge
Second node of the 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.

Specified by:
getNode1 in interface Edge
Returns:
The second node of the edge.
See Also:
Edge.getNode0(), Edge.getTargetNode()

getOpposite

public <T extends Node> T getOpposite(Node node)
Description copied from interface: Edge
When knowing one node and one edge of this node, this method return the node at the other end of the 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.

Specified by:
getOpposite in interface Edge
Parameters:
node - The node we search the opposite of.
Returns:
the opposite node of the given node.

getSourceNode

public <T extends Node> T getSourceNode()
Description copied from interface: Edge
Start node.

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.

Specified by:
getSourceNode in interface Edge
Returns:
The origin node of the edge.
See Also:
Edge.getNode0(), Edge.getTargetNode()

getTargetNode

public <T extends Node> T getTargetNode()
Description copied from interface: Edge
End node.

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.

Specified by:
getTargetNode in interface Edge
Returns:
The destination node of the edge.
See Also:
Edge.getNode1(), Edge.getSourceNode()

isDirected

public boolean isDirected()
Description copied from interface: Edge
Is the edge directed ?.

Specified by:
isDirected in interface Edge
Returns:
True if the edge is directed.

isLoop

public boolean isLoop()
Description copied from interface: Edge
Does the source and target of this edge identify the same node ?.

Specified by:
isLoop in interface Edge
Returns:
True if this edge is a loop.


Copyright © 2012. All Rights Reserved.