Interface GraphConnectivity<V,E>

All Known Implementing Classes:
AbstractGraphConnectivity, EvenShiloachGraphDecrementalConnectivity, MinimumSpanningTreeGraphConnectivity, NaiveGraphConnectivity

public interface GraphConnectivity<V,E>
Interface for incremental and decremental connectivity computations, through a mechanism which records the topological changes which later need to be undone. To start recording topological changes, call startTemporaryChanges(). A call to undoTemporaryChanges() will then undo in reverse order all the graph modifications which occurred since last call to startTemporaryChanges(). This allows several levels of temporary changes - even if some implementations might not support it.
     connectivity.addVertex(v1);
     connectivity.addVertex(v2);
     connectivity.addEdge(v1, v2, e12);

     connectivity.startTemporaryChanges();
     connectivity.removeEdge(e12);

        connectivity.startTemporaryChanges();
        connectivity.addVertex(v3);
        connectivity.addEdge(v1, v3, e13);
        connectivity.undoTemporaryChanges();

     connectivity.undoTemporaryChanges();
 
Author:
Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>, Florian Dupuy <florian.dupuy at rte-france.com>
  • Method Details

    • addVertex

      void addVertex(V vertex)
    • addEdge

      void addEdge(V vertex1, V vertex2, E edge)
    • removeEdge

      void removeEdge(E edge)
    • supportTemporaryChangesNesting

      boolean supportTemporaryChangesNesting()
    • startTemporaryChanges

      void startTemporaryChanges()
      Start recording topological changes to undo them later by a undoTemporaryChanges() call.
    • undoTemporaryChanges

      void undoTemporaryChanges()
      Undo all the connectivity changes (possibly none) since last call to startTemporaryChanges().
    • getComponentNumber

      int getComponentNumber(V vertex)
      Return the number of the connected component containing the given vertex, knowing that the number represents the size ranking of the related connected component in the graph, 0 being the main connected component. Hence, the greater the component number is, the smaller the number of vertices in that component.
      Parameters:
      vertex - the vertex whose connected component number is looked for
      Returns:
      the number of the related connected component
    • setMainComponentVertex

      void setMainComponentVertex(V mainComponentVertex)
      Set the main component with given vertex. The connected component relative to this vertex is considered as being the main component. If not set, the main component is considered to be the biggest component. This main component cannot be changed if any temporary changes are ongoing.
      Parameters:
      mainComponentVertex - vertex defining main component
    • getNbConnectedComponents

      int getNbConnectedComponents()
      Return the number of connected components
    • getConnectedComponent

      Set<V> getConnectedComponent(V vertex)
      Return the connected component set of given vertex
    • getVerticesRemovedFromMainComponent

      Set<V> getVerticesRemovedFromMainComponent()
      Return the vertices which were removed from main component by last temporary changes. The main component is set by calling setMainComponentVertex, or if not set it is the biggest connected component.
    • getEdgesRemovedFromMainComponent

      Set<E> getEdgesRemovedFromMainComponent()
      Return the edges which were removed from main component by last temporary changes. The main component is set by calling setMainComponentVertex, or if not set it is the biggest connected component.
    • getVerticesAddedToMainComponent

      Set<V> getVerticesAddedToMainComponent()
      Return the vertices which were added to main component by last temporary changes. The main component is set by calling setMainComponentVertex, or if not set it is the biggest connected component.
    • getEdgesAddedToMainComponent

      Set<E> getEdgesAddedToMainComponent()
      Return the edges which were added to main component by last temporary changes. The main component is set by calling setMainComponentVertex, or if not set it is the biggest connected component.