Class UntypedACyclicSubGraphImpl<V extends DirectedVertex,​E extends EdgeSegment>

    • Constructor Detail

      • UntypedACyclicSubGraphImpl

        public UntypedACyclicSubGraphImpl​(IdGroupingToken groupId,
                                          V rootVertex,
                                          boolean invertedDirection,
                                          int numberOfParentEdgeSegments)
        Constructor
        Parameters:
        groupId - generate id based on the group it resides in
        rootVertex - of the dag
        invertedDirection - when true dag ends at root and all other vertices precede it, when false the root is the starting point and all other vertices succeed it
        numberOfParentEdgeSegments - number of directed edge segments of the parent this subgraph is a subset from
      • UntypedACyclicSubGraphImpl

        public UntypedACyclicSubGraphImpl​(IdGroupingToken groupId,
                                          Set<V> rootVertices,
                                          boolean invertedDirection,
                                          int numberOfParentEdgeSegments)
        Constructor
        Parameters:
        groupId - generate id based on the group it resides in
        rootVertices - the root vertices of the conjugate dag which can be the end or starting point depending whether or not direction is inverted.
        invertedDirection - when true dag ends at root and all other vertices precede it, when false the root is the starting point and all other vertices succeed it
        numberOfParentEdgeSegments - number of directed edge segments of the parent this subgraph is a subset from
      • UntypedACyclicSubGraphImpl

        public UntypedACyclicSubGraphImpl​(UntypedACyclicSubGraphImpl<V,​E> other,
                                          boolean deepCopy)
        Copy constructor
        Parameters:
        other - to copy
        deepCopy - when true, create a deep copy, shallow copy otherwise
    • Method Detail

      • postVisit

        protected void postVisit​(org.goplanit.graph.directed.acyclic.AcyclicVertexData vertexData,
                                 LongAdder counter)
        While traversing the graph recursively, postVisit is invoked AFTER exploring a vertex (successfully). In this implementation, the preVisit simply increments the counter and updates the postVisit variable on the vertex data. See also Gupta et al. 2008
        Parameters:
        vertexData - data of the vertex
        counter - track the progress of traversing the graph, increment by one
      • preVisit

        protected void preVisit​(org.goplanit.graph.directed.acyclic.AcyclicVertexData vertexData,
                                LongAdder counter)
        While traversing the graph recursively, preVisit is invoked BEFORE exploring a vertex further. In this implementation, the preVisit simply increments the counter and updates the preVisit variable on the vertex data. See also Gupta et al. 2008
        Parameters:
        vertexData - data of the vertex
        counter - track the progress of traversing the graph, increment by one
      • getVertexData

        protected org.goplanit.graph.directed.acyclic.AcyclicVertexData getVertexData​(DirectedVertex vertex)
        Collect vertex data for given vertex
        Parameters:
        vertex - to collect for
        Returns:
        vertex data
      • topologicalSort

        public Deque<V> topologicalSort​(boolean update)
        Perform topological sorting from root, based on Gupta et al. 2008.
        Specified by:
        topologicalSort in interface UntypedACyclicSubGraph<V extends DirectedVertex,​E extends EdgeSegment>
        Parameters:
        update - when true we force an update, when false we return the most recent result without performing an update (if any exist)
        Returns:
        Topologically sorted list of vertices, null when graph is not acyclic, or disconnected
      • getId

        public long getId()
        Collect id of the entity
        Specified by:
        getId in interface IdAble
        Returns:
        id found
      • getNumberOfVertices

        public long getNumberOfVertices()
        The number of registered vertices. This method provides the number of vertices corresponding to these registered edge segments
        Specified by:
        getNumberOfVertices in interface DirectedSubGraph<V extends DirectedVertex,​E extends EdgeSegment>
        Returns:
        number of vertices
      • isDirectionInverted

        public boolean isDirectionInverted()
        Indicates if the direction of the graph is inverted, i.e., when inverted the root vertex is the final vertex and all other vertices precede it, otherwise it is a starting point and all other vertices succeed it
        Specified by:
        isDirectionInverted in interface UntypedACyclicSubGraph<V extends DirectedVertex,​E extends EdgeSegment>
        Returns:
        true when inverted, false otherwise