Class BasicOrderedMultiGraph<T>

  • Type Parameters:
    T - type of node in the graph
    All Implemented Interfaces:
    EdgeManager<T>, Graph<T>, NodeManager<T>, OrderedMultiGraph<T>, java.lang.Iterable<T>

    public class BasicOrderedMultiGraph<T>
    extends java.lang.Object
    implements OrderedMultiGraph<T>
    Inefficient implementation of OrderedMultiGraph. UNDER CONSTRUCTION.
    • Constructor Detail

      • BasicOrderedMultiGraph

        public BasicOrderedMultiGraph()
    • Method Detail

      • addEdge

        public void addEdge​(T src,
                            T dst)
                     throws java.lang.IllegalArgumentException
        Add this edge, unconditionally setting it as the next successor.
        Specified by:
        addEdge in interface EdgeManager<T>
        Throws:
        java.lang.IllegalArgumentException
      • addEdge

        public void addEdge​(int i,
                            T src,
                            T dst)
                     throws java.lang.IllegalArgumentException
        Description copied from interface: OrderedMultiGraph
        add an edge and record it so dst is the ith successor of src
        Specified by:
        addEdge in interface OrderedMultiGraph<T>
        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>
      • containsNode

        public boolean containsNode​(T N)
        Specified by:
        containsNode in interface NodeManager<T>
        Returns:
        true iff the graph contains the specified node
      • 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
        For now, this returns nodes in no particular order! Fix this when needed.
        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
      • hasEdge

        public boolean hasEdge​(T src,
                               T dst)
        Specified by:
        hasEdge in interface EdgeManager<T>
      • 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
      • getSuccessor

        public T getSuccessor​(T node,
                              int i)
                       throws java.lang.IllegalArgumentException
        Description copied from interface: OrderedMultiGraph
        get the ith successor of a node
        Specified by:
        getSuccessor in interface OrderedMultiGraph<T>
        Throws:
        java.lang.IllegalArgumentException