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

    • Field Detail

      • graphBuilder

        protected final GraphBuilder<V extends Vertex,​E extends Edge> graphBuilder
        Graph builder responsible for constructing all graph related (derived) instances
      • edges

        protected final Edges<E extends Edge> edges
        class instance containing all edges
      • vertices

        protected final Vertices<V extends Vertex> vertices
        class instance containing all vertices
    • Constructor Detail

      • GraphImpl

        public GraphImpl​(IdGroupingToken groupId,
                         GraphBuilder<V,​E> graphBuilder)
        Graph Constructor
        Parameters:
        groupId - contiguous id generation within this group for instances of this class
        graphBuilder - the builder to be used to create this network
    • Method Detail

      • processSubNetworkVertex

        protected Set<V> processSubNetworkVertex​(V referenceVertex)
                                          throws PlanItException
        helper function for subnetwork identification (deliberately NOT recursive to avoid stack overflow on large networks)
        Parameters:
        referenceVertex - to process
        Returns:
        all vertices in the subnetwork connected to passed in reference vertex
        Throws:
        PlanItException - thrown if parameters are null
      • getId

        public long getId()
        collect the id of this graph
        Specified by:
        getId in interface Graph<V extends Vertex,​E extends Edge>
        Returns:
        graph id
      • getEdges

        public Edges<E> getEdges()
        collect edges of graph
        Specified by:
        getEdges in interface Graph<V extends Vertex,​E extends Edge>
        Returns:
        edges
      • getGraphIdGroupingToken

        public IdGroupingToken getGraphIdGroupingToken()
        Collect the id grouping token used for all entities registered on the graph, i.e., this network's specific identifier for generating ids unique and contiguous within this network and this network only
        Returns:
        the graph id grouping token
      • 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<V extends Vertex,​E extends Edge>
        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
      • removeSubGraph

        public void removeSubGraph​(Set<? extends V> subGraphToRemove,
                                   boolean recreateIds)
        remove the subgraph identified by the passed in vertices
        Specified by:
        removeSubGraph in interface GraphModifier<V extends Vertex,​E extends Edge>
        Parameters:
        subGraphToRemove - the one to remove
        recreateIds - indicate if the ids of the graph entities are to be recreated, if false gaps will occur so it is expected to be handled by the user afterwards in this case
      • removeSubGraphOf

        public void removeSubGraphOf​(V referenceVertex,
                                     boolean recreateIds)
                              throws PlanItException
        remove the (sub)graph in which the passed in vertex resides. Apply reordering of internal ids of remaining network.
        Specified by:
        removeSubGraphOf in interface GraphModifier<V extends Vertex,​E extends Edge>
        Parameters:
        referenceVertex - to identify subnetwork by
        recreateIds - indicate if the ids of the graph entities are to be recreated, if false gaps will occur so it is expected to be handled by the user afterwards in this case
        Throws:
        PlanItException - thrown if error
      • breakEdgesAt

        public Map<Long,​Set<E>> breakEdgesAt​(List<? extends E> edgesToBreak,
                                                   V vertexToBreakAt)
                                            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<V extends Vertex,​E extends Edge>
        Parameters:
        edgesToBreak - the links to break
        vertexToBreakAt - the node to break at
        Returns:
        affectedEdges the list of all result edges of the breaking of links by their original link id
        Throws:
        PlanItException - thrown if error
      • recreateIds

        public void recreateIds()
        this method will recreate all ids of the graph's main components, e.g., vertices, edges, and potentially other eligible components of derived graph implementations. Can be used in conjunctions with the removal of subgraphs in case the recreation of ids was switched off manually for some reason.
        Specified by:
        recreateIds in interface GraphModifier<V extends Vertex,​E extends Edge>