Class AbstractNode

java.lang.Object
org.graphstream.graph.implementations.AbstractElement
org.graphstream.graph.implementations.AbstractNode
All Implemented Interfaces:
Iterable<Edge>, Element, Node
Direct Known Subclasses:
AdjacencyListNode

public abstract class AbstractNode
extends AbstractElement
implements Node

This class provides a basic implementation of Node interface, to minimize the effort required to implement this interface.

This class implements all the methods of AbstractElement and most of the methods of Node (there are "only" ten abstract methods). In addition to these, subclasses must provide implementations for addEdgeCallback(AbstractEdge) and removeEdgeCallback(AbstractEdge) which are called by the parent graph when an edge incident to this node is added to or removed from the graph. This class has a low memory overhead (one reference as field).

  • Method Details

    • getGraph

      public Graph getGraph()
      This implementation returns graph.
      Specified by:
      getGraph in interface Node
      Returns:
      The graph containing this node or null if unknown.
      See Also:
      Node.getGraph()
    • getEdgeToward

      public Edge getEdgeToward​(int index)
      This implementation uses Node.getEdgeToward(Node)
      Specified by:
      getEdgeToward in interface Node
      Parameters:
      index - Index of the target node.
      Returns:
      Directed edge going from this node to the parameter node, or undirected edge if it exists, else null.
      See Also:
      Node.getEdgeToward(int)
    • getEdgeToward

      public Edge getEdgeToward​(String id)
      This implementation uses Node.getEdgeToward(Node)
      Specified by:
      getEdgeToward in interface Node
      Parameters:
      id - Identifier of the target node.
      Returns:
      Directed edge going from this node to 'id', or undirected edge if it exists, else null.
      See Also:
      Node.getEdgeToward(java.lang.String)
    • getEdgeFrom

      public Edge getEdgeFrom​(int index)
      This implementation uses Node.getEdgeFrom(Node)
      Specified by:
      getEdgeFrom in interface Node
      Parameters:
      index - Index of the source node.
      Returns:
      Directed edge going from the parameter node to this node, or undirected edge if it exists, else null.
      See Also:
      Node.getEdgeFrom(int)
    • getEdgeFrom

      public Edge getEdgeFrom​(String id)
      This implementation uses Node.getEdgeFrom(Node)
      Specified by:
      getEdgeFrom in interface Node
      Parameters:
      id - Identifier of the source node.
      Returns:
      Directed edge going from node 'id' to this node, or undirected edge if it exists, else null.
      See Also:
      Node.getEdgeFrom(java.lang.String)
    • getEdgeBetween

      public Edge getEdgeBetween​(int index)
      This implementation uses Node.getEdgeBetween(Node)
      Specified by:
      getEdgeBetween in interface Node
      Parameters:
      index - The index of the opposite node.
      Returns:
      Edge between node with index i and this node if it exists, else null.
      See Also:
      Node.getEdgeBetween(int)
    • getEdgeBetween

      public Edge getEdgeBetween​(String id)
      This implementation uses Node.getEdgeBetween(Node)
      Specified by:
      getEdgeBetween in interface Node
      Parameters:
      id - Identifier of the opposite node.
      Returns:
      Edge between node 'id' and this node if it exists, else null.
      See Also:
      Node.getEdgeBetween(java.lang.String)
    • getBreadthFirstIterator

      public Iterator<Node> getBreadthFirstIterator()
      This implementation creates an instance of BreadthFirstIterator and returns it.
      Specified by:
      getBreadthFirstIterator in interface Node
      Returns:
      An iterator able to explore the graph in a breadth first way starting at this node.
      See Also:
      Node.getBreadthFirstIterator()
    • getBreadthFirstIterator

      public Iterator<Node> getBreadthFirstIterator​(boolean directed)
      This implementation creates an instance of BreadthFirstIterator and returns it.
      Specified by:
      getBreadthFirstIterator in interface Node
      Parameters:
      directed - If false, the iterator will ignore edge orientation (the default is "True").
      Returns:
      An iterator able to explore the graph in a breadth first way starting at this node.
      See Also:
      Node.getBreadthFirstIterator(boolean)
    • getDepthFirstIterator

      public Iterator<Node> getDepthFirstIterator()
      This implementation creates an instance of DepthFirstIterator and returns it.
      Specified by:
      getDepthFirstIterator in interface Node
      Returns:
      An iterator able to explore the graph in a depth first way starting at this node.
      See Also:
      Node.getDepthFirstIterator()
    • getDepthFirstIterator

      public Iterator<Node> getDepthFirstIterator​(boolean directed)
      This implementation creates an instance of DepthFirstIterator and returns it.
      Specified by:
      getDepthFirstIterator in interface Node
      Parameters:
      directed - If false, the iterator will ignore edge orientation (the default is "True").
      Returns:
      An iterator able to explore the graph in a depth first way starting at this node.
      See Also:
      Node.getDepthFirstIterator(boolean)
    • isEnteringEdge

      public boolean isEnteringEdge​(Edge e)
      Checks if an edge enters this node. Utility method that can be useful in subclasses.
      Parameters:
      e - an edge
      Returns:
      true if e is entering edge for this node.
    • isLeavingEdge

      public boolean isLeavingEdge​(Edge e)
      Checks if an edge leaves this node. Utility method that can be useful in subclasses.
      Parameters:
      e - an edge
      Returns:
      true if e is leaving edge for this node.
    • isIncidentEdge

      public boolean isIncidentEdge​(Edge e)
      Checks if an edge is incident to this node. Utility method that can be useful in subclasses.
      Parameters:
      e - an edge
      Returns:
      true if e is incident edge for this node.