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

    • Constructor Detail

      • DAG

        public DAG​(Set<V> vertices,
                   Map<V,​Set<E>> incomingEdges,
                   Map<V,​Set<E>> outgoingEdges,
                   Map<V,​LoopVertex> assignedLoopVertexMap,
                   Map<V,​Integer> loopStackDepthMap)
        Constructor of DAG, called by the DAGBuilder.
        Parameters:
        vertices - set of vertices.
        incomingEdges - map of incoming edges for each vertex.
        outgoingEdges - map of outgoing edges for each vertex.
        assignedLoopVertexMap - map of assignedLoopVertex info.
        loopStackDepthMap - map of stack depth of LoopVertices.
    • Method Detail

      • getVertexById

        public V getVertexById​(String id)
        Description copied from interface: DAGInterface
        Retrieves the vertex given its ID.
        Specified by:
        getVertexById in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        id - of the vertex to retrieve.
        Returns:
        the vertex.
      • getEdgeById

        public E getEdgeById​(String id)
        Description copied from interface: DAGInterface
        Retrieves the edge given its ID.
        Specified by:
        getEdgeById in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        id - of the edge to retrieve.
        Returns:
        the edge.
      • getIncomingEdgesOf

        public List<E> getIncomingEdgesOf​(V v)
        Description copied from interface: DAGInterface
        Retrieves the incoming edges of the given vertex.
        Specified by:
        getIncomingEdgesOf in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        v - the subject vertex.
        Returns:
        the list of incoming edges to the vertex. Note that the result is never null, ensured by DAGBuilder.
      • getIncomingEdgesOf

        public List<E> getIncomingEdgesOf​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the incoming edges of the given vertex.
        Specified by:
        getIncomingEdgesOf in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of incoming edges to the vertex. Note that the result is never null, ensured by DAGBuilder.
      • getOutgoingEdgesOf

        public List<E> getOutgoingEdgesOf​(V v)
        Description copied from interface: DAGInterface
        Retrieves the outgoing edges of the given vertex.
        Specified by:
        getOutgoingEdgesOf in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        v - the subject vertex.
        Returns:
        the list of outgoing edges to the vertex. Note that the result is never null, ensured by DAGBuilder.
      • getOutgoingEdgesOf

        public List<E> getOutgoingEdgesOf​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the outgoing edges of the given vertex.
        Specified by:
        getOutgoingEdgesOf in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of outgoing edges to the vertex. Note that the result is never null, ensured by DAGBuilder.
      • getParents

        public List<V> getParents​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the parent vertices of the given vertex.
        Specified by:
        getParents in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of parent vertices.
      • getChildren

        public List<V> getChildren​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the children vertices of the given vertex.
        Specified by:
        getChildren in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of children vertices.
      • getEdgeBetween

        public E getEdgeBetween​(String srcVertexId,
                                String dstVertexId)
        Description copied from interface: DAGInterface
        Retrieves the edge between two vertices.
        Specified by:
        getEdgeBetween in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        srcVertexId - the ID of the source vertex.
        dstVertexId - the ID of the destination vertex.
        Returns:
        the edge if exists.
      • getTopologicalSort

        public List<V> getTopologicalSort()
        Description copied from interface: DAGInterface
        Gets the DAG's vertices in topologically sorted order. This function brings consistent results.
        Specified by:
        getTopologicalSort in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Returns:
        the sorted list of vertices in topological order.
      • getAncestors

        public List<V> getAncestors​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the ancestors of a vertex.
        Specified by:
        getAncestors in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - to find the ancestors for.
        Returns:
        the list of ancestors.
      • getDescendants

        public List<V> getDescendants​(String vertexId)
        Description copied from interface: DAGInterface
        Retrieves the descendants of a vertex.
        Specified by:
        getDescendants in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        vertexId - to find the descendants for.
        Returns:
        the list of descendants.
      • filterVertices

        public List<V> filterVertices​(Predicate<V> condition)
        Description copied from interface: DAGInterface
        Filters the vertices according to the given condition.
        Specified by:
        filterVertices in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        condition - that must be satisfied to be included in the filtered list.
        Returns:
        the list of vertices that meet the condition.
      • topologicalDo

        public void topologicalDo​(Consumer<V> function)
        Description copied from interface: DAGInterface
        Applies the function to each node in the DAG in a topological order. This function brings consistent results.
        Specified by:
        topologicalDo in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        function - to apply.
      • pathExistsBetween

        public Boolean pathExistsBetween​(V v1,
                                         V v2)
        Description copied from interface: DAGInterface
        Function checks whether there is a path between two vertices.
        Specified by:
        pathExistsBetween in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        v1 - First vertex to check.
        v2 - Second vertex to check.
        Returns:
        Whether or not there is a path between two vertices.
      • isCompositeVertex

        public Boolean isCompositeVertex​(V v)
        Description copied from interface: DAGInterface
        Checks whether the given vertex is assigned with a wrapping LoopVertex.
        Specified by:
        isCompositeVertex in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        v - Vertex to check.
        Returns:
        whether or not it is wrapped by a LoopVertex
      • getLoopStackDepthOf

        public Integer getLoopStackDepthOf​(V v)
        Description copied from interface: DAGInterface
        Retrieves the stack depth of the given vertex.
        Specified by:
        getLoopStackDepthOf in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        v - Vertex to check.
        Returns:
        The depth of the stack of LoopVertices for the vertex.
      • asJsonNode

        public com.fasterxml.jackson.databind.node.ObjectNode asJsonNode()
        Specified by:
        asJsonNode in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Returns:
        JsonNode for this DAG.
      • storeJSON

        public void storeJSON​(String directory,
                              String name,
                              String description)
        Description copied from interface: DAGInterface
        Stores JSON representation of this DAG into a file.
        Specified by:
        storeJSON in interface DAGInterface<V extends Vertex,​E extends Edge<V>>
        Parameters:
        directory - the directory which JSON representation is saved to
        name - name of this DAG
        description - description of this DAG