Interface DAGInterface<V extends Vertex,​E extends Edge<V>>

  • Type Parameters:
    V - the vertex type
    E - the edge type
    All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    DAG, IRDAG

    public interface DAGInterface<V extends Vertex,​E extends Edge<V>>
    extends Serializable
    Methods for querying a directed-acyclic graph (DAG). Implementations of the methods must not modify the topology of the DAG.
    • Method Detail

      • getVertexById

        V getVertexById​(String id)
        Retrieves the vertex given its ID.
        Parameters:
        id - of the vertex to retrieve.
        Returns:
        the vertex.
      • getEdgeById

        E getEdgeById​(String id)
        Retrieves the edge given its ID.
        Parameters:
        id - of the edge to retrieve.
        Returns:
        the edge.
      • getVertices

        List<V> getVertices()
        Retrieves the vertices of this DAG.
        Returns:
        the list of vertices. Note that the result is never null, ensured by DAGBuilder.
      • getEdges

        List<E> getEdges()
        Retrieves the edges of this DAG.
        Returns:
        the list of edges.
      • getRootVertices

        List<V> getRootVertices()
        Retrieves the root vertices of this DAG.
        Returns:
        the list of root vertices.
      • getIncomingEdgesOf

        List<E> getIncomingEdgesOf​(V v)
        Retrieves the incoming edges of the given vertex.
        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

        List<E> getIncomingEdgesOf​(String vertexId)
        Retrieves the incoming edges of the given vertex.
        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

        List<E> getOutgoingEdgesOf​(V v)
        Retrieves the outgoing edges of the given vertex.
        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

        List<E> getOutgoingEdgesOf​(String vertexId)
        Retrieves the outgoing edges of the given vertex.
        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

        List<V> getParents​(String vertexId)
        Retrieves the parent vertices of the given vertex.
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of parent vertices.
      • getChildren

        List<V> getChildren​(String vertexId)
        Retrieves the children vertices of the given vertex.
        Parameters:
        vertexId - the ID of the subject vertex.
        Returns:
        the list of children vertices.
      • getEdgeBetween

        E getEdgeBetween​(String srcVertexId,
                         String dstVertexId)
        Retrieves the edge between two vertices.
        Parameters:
        srcVertexId - the ID of the source vertex.
        dstVertexId - the ID of the destination vertex.
        Returns:
        the edge if exists.
      • getTopologicalSort

        List<V> getTopologicalSort()
        Gets the DAG's vertices in topologically sorted order. This function brings consistent results.
        Returns:
        the sorted list of vertices in topological order.
      • getAncestors

        List<V> getAncestors​(String vertexId)
        Retrieves the ancestors of a vertex.
        Parameters:
        vertexId - to find the ancestors for.
        Returns:
        the list of ancestors.
      • getDescendants

        List<V> getDescendants​(String vertexId)
        Retrieves the descendants of a vertex.
        Parameters:
        vertexId - to find the descendants for.
        Returns:
        the list of descendants.
      • filterVertices

        List<V> filterVertices​(Predicate<V> condition)
        Filters the vertices according to the given condition.
        Parameters:
        condition - that must be satisfied to be included in the filtered list.
        Returns:
        the list of vertices that meet the condition.
      • topologicalDo

        void topologicalDo​(Consumer<V> function)
        Applies the function to each node in the DAG in a topological order. This function brings consistent results.
        Parameters:
        function - to apply.
      • dfsTraverse

        void dfsTraverse​(Consumer<V> function,
                         DAGInterface.TraversalOrder traversalOrder)
        Traverses the DAG by DFS, applying the given function.
        Parameters:
        function - to apply.
        traversalOrder - which the DFS should be conducted.
      • pathExistsBetween

        Boolean pathExistsBetween​(V v1,
                                  V v2)
        Function checks whether there is a path between two vertices.
        Parameters:
        v1 - First vertex to check.
        v2 - Second vertex to check.
        Returns:
        Whether or not there is a path between two vertices.
      • isCompositeVertex

        Boolean isCompositeVertex​(V v)
        Checks whether the given vertex is assigned with a wrapping LoopVertex.
        Parameters:
        v - Vertex to check.
        Returns:
        whether or not it is wrapped by a LoopVertex
      • getLoopStackDepthOf

        Integer getLoopStackDepthOf​(V v)
        Retrieves the stack depth of the given vertex.
        Parameters:
        v - Vertex to check.
        Returns:
        The depth of the stack of LoopVertices for the vertex.
      • getAssignedLoopVertexOf

        LoopVertex getAssignedLoopVertexOf​(V v)
        Retrieves the wrapping LoopVertex of the vertex.
        Parameters:
        v - Vertex to check.
        Returns:
        The wrapping LoopVertex.
      • asJsonNode

        com.fasterxml.jackson.databind.node.ObjectNode asJsonNode()
        Returns:
        JsonNode for this DAG.
      • storeJSON

        void storeJSON​(String directory,
                       String name,
                       String description)
        Stores JSON representation of this DAG into a file.
        Parameters:
        directory - the directory which JSON representation is saved to
        name - name of this DAG
        description - description of this DAG