Class GraphNode


  • public class GraphNode
    extends java.lang.Object
    Interface for a generic node in a graph.
    See Also:
    Graph
    • Field Detail

      • element

        protected java.lang.Object element
      • successors

        protected java.util.ArrayList<GraphNode> successors
      • predecessors

        protected java.util.ArrayList<GraphNode> predecessors
    • Constructor Detail

      • GraphNode

        public GraphNode​(java.lang.Object element)
    • Method Detail

      • getElement

        public java.lang.Object getElement()
        Get the element contained in the node.
        Returns:
        The object contained in the node.
      • setElement

        public void setElement​(java.lang.Object element)
        Set the element in the node.
        Parameters:
        element - The element.
      • getNbrSucc

        public int getNbrSucc()
        Get the number of successor node.
        Returns:
        The number of successor nodes.
      • getSuccessor

        public GraphNode getSuccessor​(int i)
        Get a specific successor node. As usual, the count is 0-based.
        Parameters:
        i - The number of the successor to be retrieved.
        Returns:
        The successor node.
      • addSuccessor

        public void addSuccessor​(GraphNode succ)
        Add a new successor node.
        Parameters:
        succ - The node to be added.
      • getNbrPred

        public int getNbrPred()
        Get the number of predecessor node.
        Returns:
        The number of predecessor nodes.
      • getPredecessor

        public GraphNode getPredecessor​(int i)
        Get a specific predecessor node. As usual, the count is 0-based.
        Parameters:
        i - The number of the predecessor to be retrieved.
        Returns:
        The predecessor node.
      • addPredecessor

        public void addPredecessor​(GraphNode pred)
        Add a new predecessor node.
        Parameters:
        pred - The node to be added.
      • connect

        public void connect​(GraphNode node)
        Connect this node to a new node.
        Parameters:
        node - The node to be connected to.