Class DAGBuilder<V extends Vertex,​E extends Edge<V>>

  • Type Parameters:
    V - the vertex type.
    E - the edge type.
    All Implemented Interfaces:
    java.io.Serializable

    public final class DAGBuilder<V extends Vertex,​E extends Edge<V>>
    extends java.lang.Object
    implements java.io.Serializable
    DAG Builder.
    See Also:
    Serialized Form
    • Constructor Detail

      • DAGBuilder

        public DAGBuilder()
        Constructor of DAGBuilder: it initializes everything.
      • DAGBuilder

        public DAGBuilder​(DAG<V,​E> dag)
        Constructor of DAGBuilder with a DAG to start from.
        Parameters:
        dag - to start the builder from.
    • Method Detail

      • addVertex

        public DAGBuilder<V,​E> addVertex​(V v)
        Add vertex to the builder.
        Parameters:
        v - vertex to add.
        Returns:
        the builder.
      • addVertex

        public DAGBuilder<V,​E> addVertex​(V v,
                                               java.util.Stack<LoopVertex> loopVertexStack)
        Add vertex to the builder, using the LoopVertex stack.
        Parameters:
        v - vertex to add.
        loopVertexStack - LoopVertex stack to retrieve the information from.
        Returns:
        the builder.
      • addVertex

        public DAGBuilder<V,​E> addVertex​(V v,
                                               DAG<V,​E> dag)
        Add vertex to the builder, using the information from the given DAG.
        Parameters:
        v - vertex to add.
        dag - DAG to observe and get the LoopVertex-related information from.
        Returns:
        the builder.
      • removeVertex

        public DAGBuilder<V,​E> removeVertex​(V v)
        Remove the vertex from the list.
        Parameters:
        v - vertex to remove.
        Returns:
        the builder.
      • connectVertices

        public DAGBuilder<V,​E> connectVertices​(E edge)
        Connect vertices at the edge.
        Parameters:
        edge - edge to add. Note: the two vertices of the edge should already be added to the DAGBuilder.
        Returns:
        the builder.
      • connectSplitterVertexWithReplacing

        public DAGBuilder<V,​E> connectSplitterVertexWithReplacing​(E originalEdge,
                                                                        E edgeToInsert)
        This method replaces current SplitterVertex's LoopEdge - InternalEdge relationship with the new relationship and connects the Edge. The changes which invokes this method should not be caused by SplitterVertex itself. Therefore, this method should be used when there are changes in vertices before / after SplitterVertex. CAUTION: TaskSizeSplitterVertex must only appear in IRDAG. originalEdge and edgeToInsert should have same source and destination. Relation to be Erased: originalEdge - internalEdge Relation to insert: edgeToInsert - newInternalEdge
        Parameters:
        originalEdge - edge connected to SplitterVertex, and is to be replaced.
        edgeToInsert - edge connected to SplitterVertex, and is to be inserted.
        Returns:
        itself.
      • connectSplitterVertexWithoutReplacing

        public DAGBuilder<V,​E> connectSplitterVertexWithoutReplacing​(E edgeToReference,
                                                                           E edgeToInsert)
        This method adds a information in SplitterVertex's LoopEdge - InternalEdge relationship and connects the Edge without replacing existing mapping relationships. The changes which invokes this method should not be caused by SplitterVertex itself. Therefore, this method should be used when there are changes in vertices before / after SplitterVertex. Since edgeToInsert should also have a mapping relationship to originalVertices of SplitterVertex, we give edgeToReference together to copy the mapping information. Therefore, these two parameters must have at least one common source or destination. Relation to reference: edgeToReference - internalEdge Relation to add: edgeToInsert - newInternalEdge CAUTION: TaskSizeSplitterVertex must only appear in IRDAG. Use case example: when inserting trigger vertices before / after splitterVertex.
        Parameters:
        edgeToReference - edge connected to SplitterVertex, and to reference.
        edgeToInsert - edge connected to SplitterVertex, and to insert.
        Returns:
        itself.
      • isEmpty

        public boolean isEmpty()
        Checks whether the DAGBuilder is empty.
        Returns:
        whether the DAGBuilder is empty or not.
      • contains

        public boolean contains​(V vertex)
        check if the DAGBuilder contains the vertex.
        Parameters:
        vertex - vertex that it searches for.
        Returns:
        whether or not the builder contains it.
      • contains

        public boolean contains​(java.util.function.Predicate<V> predicate)
        check if the DAGBuilder contains any vertex that satisfies the predicate.
        Parameters:
        predicate - predicate to test each vertices with.
        Returns:
        whether or not the builder contains it.
      • buildWithoutSourceSinkCheck

        public DAG<V,​E> buildWithoutSourceSinkCheck()
        Build the DAG without source and sink check.
        Returns:
        the DAG contained by the builder.
      • buildWithoutSourceCheck

        public DAG<V,​E> buildWithoutSourceCheck()
        Build the DAG without source check.
        Returns:
        the DAG contained by the builder.
      • build

        public DAG<V,​E> build()
        Build the DAG.
        Returns:
        the DAG contained by the builder.