Class AbstractGraph<T>

    • Constructor Detail

      • AbstractGraph

        public AbstractGraph()
    • Method Detail

      • getNodeManager

        protected abstract NodeManager<T> getNodeManager()
        Returns:
        the object which manages nodes in the graph
      • getEdgeManager

        protected abstract EdgeManager<T> getEdgeManager()
        Returns:
        the object which manages edges in the graph
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface NodeManager<T>
        Returns:
        an Iterator of the nodes in this graph
      • getNumberOfNodes

        public int getNumberOfNodes()
        Specified by:
        getNumberOfNodes in interface NodeManager<T>
        Returns:
        the number of nodes in this graph
      • getPredNodeCount

        public int getPredNodeCount​(T n)
                             throws java.lang.IllegalArgumentException
        Description copied from interface: EdgeManager
        Return the number of immediate predecessor nodes of n
        Specified by:
        getPredNodeCount in interface EdgeManager<T>
        Returns:
        the number of immediate predecessors of n.
        Throws:
        java.lang.IllegalArgumentException
      • getPredNodes

        public java.util.Iterator<T> getPredNodes​(T n)
                                           throws java.lang.IllegalArgumentException
        Description copied from interface: EdgeManager
        Return an Iterator over the immediate predecessor nodes of n This method never returns null.
        Specified by:
        getPredNodes in interface EdgeManager<T>
        Returns:
        an Iterator over the immediate predecessor nodes of this Node.
        Throws:
        java.lang.IllegalArgumentException
      • getSuccNodeCount

        public int getSuccNodeCount​(T n)
                             throws java.lang.IllegalArgumentException
        Description copied from interface: EdgeManager
        Return the number of immediate successor nodes of this Node in the Graph
        Specified by:
        getSuccNodeCount in interface EdgeManager<T>
        Returns:
        the number of immediate successor Nodes of this Node in the Graph.
        Throws:
        java.lang.IllegalArgumentException
      • getSuccNodes

        public java.util.Iterator<T> getSuccNodes​(T n)
                                           throws java.lang.IllegalArgumentException
        Description copied from interface: EdgeManager
        Return an Iterator over the immediate successor nodes of n

        This method never returns null.

        Specified by:
        getSuccNodes in interface EdgeManager<T>
        Returns:
        an Iterator over the immediate successor nodes of n
        Throws:
        java.lang.IllegalArgumentException
      • addNode

        public void addNode​(T n)
        Description copied from interface: NodeManager
        add a node to this graph
        Specified by:
        addNode in interface NodeManager<T>
      • addEdge

        public void addEdge​(T src,
                            T dst)
                     throws java.lang.IllegalArgumentException
        Specified by:
        addEdge in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • removeEdge

        public void removeEdge​(T src,
                               T dst)
                        throws java.lang.IllegalArgumentException
        Specified by:
        removeEdge in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • hasEdge

        public boolean hasEdge​(T src,
                               T dst)
        Specified by:
        hasEdge in interface EdgeManager<T>
      • removeAllIncidentEdges

        public void removeAllIncidentEdges​(T node)
                                    throws java.lang.IllegalArgumentException
        Specified by:
        removeAllIncidentEdges in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • removeIncomingEdges

        public void removeIncomingEdges​(T node)
                                 throws java.lang.IllegalArgumentException
        Specified by:
        removeIncomingEdges in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • removeOutgoingEdges

        public void removeOutgoingEdges​(T node)
                                 throws java.lang.IllegalArgumentException
        Specified by:
        removeOutgoingEdges in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • removeNodeAndEdges

        public void removeNodeAndEdges​(T N)
                                throws java.lang.IllegalArgumentException
        Description copied from interface: Graph
        remove a node and all its incident edges
        Specified by:
        removeNodeAndEdges in interface Graph<T>
        Throws:
        java.lang.IllegalArgumentException
      • removeNode

        public void removeNode​(T n)
                        throws java.lang.IllegalArgumentException
        Description copied from interface: NodeManager
        remove a node from this graph
        Specified by:
        removeNode in interface NodeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • edgeString

        protected java.lang.String edgeString​(T from,
                                              T to)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • containsNode

        public boolean containsNode​(T n)
        Specified by:
        containsNode in interface NodeManager<T>
        Returns:
        true iff the graph contains the specified node