Class DirectedGraphModifierImpl

    • Constructor Detail

      • DirectedGraphModifierImpl

        public DirectedGraphModifierImpl​(UntypedDirectedGraph<?,​?,​?> theDirectedGraph)
        Constructor.
        Parameters:
        theDirectedGraph - to use
    • Method Detail

      • fireEvent

        protected void fireEvent​(EventListener eventListener,
                                 Event event)
        Depending on whether these are directed or undirected evens call the appropriate notification method
        Specified by:
        fireEvent in class EventProducerImpl
        Parameters:
        eventListener - to notify for the event
        event - to process for the listener
      • getUntypedDirectedGraph

        protected UntypedDirectedGraph<?,​?,​?> getUntypedDirectedGraph()
        Access to directed graph we are modifying
        Returns:
        directed graph
      • recreateManagedEntitiesIds

        public void recreateManagedEntitiesIds()
        This method will recreate all ids of the graph's components, e.g., vertices, edges, etc. but only when the containers used for them are the primary ManagedIdEntities containers, i.e., when the graph is responsible of uniquely tracking all entities by their managed id. If not, for example, if this is a subgraph reusing parts of the main graph, it will not recreate the ids.

        The reasoning is that if we would recreate ids of the container while the container does not contain all = let's say - vertices, their managedId is no longer guaranteed to be unique which can lead to issues

        Method can be used in conjunctions with the removal of parts of the graph and the result is required to have unique contiguous ids

        Specified by:
        recreateManagedEntitiesIds in interface GraphModifier<DirectedVertex,​DirectedEdge>
      • breakEdgeAt

        public <Ex extends DirectedEdge> Ex breakEdgeAt​(DirectedVertex vertexToBreakAt,
                                                        Ex edgeToBreak,
                                                        PlanitJtsCrsUtils geoUtils)
                                                 throws PlanItException
        Identical to the GraphImpl implementation except that we now also account for the edge segments present on the edge. Copies of the original edge segments are placed on (vertexToBreakAt,vertexB), while the original ones are retained at (vertexA,vertexToBreakAt)
        Specified by:
        breakEdgeAt in interface GraphModifier<DirectedVertex,​DirectedEdge>
        Type Parameters:
        Ex - edge type
        Parameters:
        edgeToBreak - edge to break
        vertexToBreakAt - the vertex to break at
        geoUtils - required to update edge lengths
        Returns:
        newly created edge due to breaking, null if not feasible
        Throws:
        PlanItException - thrown if error
      • breakEdgesAt

        public <Ex extends DirectedEdgeMap<Long,​Set<Ex>> breakEdgesAt​(List<Ex> edgesToBreak,
                                                                              DirectedVertex vertexToBreakAt,
                                                                              org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                                                                       throws PlanItException
        Break the passed in edges by inserting the passed in vertex in between. After completion the original edges remain as (VertexA,VertexToBreakAt), and new edges are inserted for (VertexToBreakAt,VertexB).
        Specified by:
        breakEdgesAt in interface GraphModifier<DirectedVertex,​DirectedEdge>
        Type Parameters:
        Ex - edge type
        Parameters:
        edgesToBreak - the links to break
        vertexToBreakAt - the node to break at
        crs - required to update edge lengths
        Returns:
        affectedEdges the list of all result edges of the breaking of links by their original link id
        Throws:
        PlanItException - thrown if error
      • removeDanglingSubGraphs

        public void removeDanglingSubGraphs​(Integer belowSize,
                                            Integer aboveSize,
                                            boolean alwaysKeepLargest)
                                     throws PlanItException
        remove any dangling subgraphs below a given size from the graph if they exist and subsequently reorder the internal ids if needed
        Specified by:
        removeDanglingSubGraphs in interface GraphModifier<DirectedVertex,​DirectedEdge>
        Parameters:
        belowSize - remove subgraphs below the given size
        aboveSize - remove subgraphs above the given size (typically set to maximum value)
        alwaysKeepLargest - indicate if the largest of the subgraphs is always to be kept even if it does not match the criteria
        Throws:
        PlanItException - thrown if error