Package com.powsybl.openloadflow.graph
Class AbstractGraphConnectivity<V,E>
- java.lang.Object
-
- com.powsybl.openloadflow.graph.AbstractGraphConnectivity<V,E>
-
- All Implemented Interfaces:
GraphConnectivity<V,E>
- Direct Known Subclasses:
EvenShiloachGraphDecrementalConnectivity
,MinimumSpanningTreeGraphConnectivity
,NaiveGraphConnectivity
public abstract class AbstractGraphConnectivity<V,E> extends Object implements GraphConnectivity<V,E>
- Author:
- Florian Dupuy
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Set<V>>
componentSets
-
Constructor Summary
Constructors Constructor Description AbstractGraphConnectivity()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addEdge(V vertex1, V vertex2, E edge)
void
addVertex(V vertex)
protected void
checkSaved()
protected void
checkVertex(V vertex)
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.Set<V>
getConnectedComponent(V vertex)
Return the connected component set of given vertexSet<E>
getEdgesAddedToMainComponent()
Return the edges which were added to main component by last temporary changes.Set<E>
getEdgesRemovedFromMainComponent()
Return the edges which were removed from main component by last temporary changes.org.jgrapht.Graph<V,E>
getGraph()
protected Deque<ModificationsContext<V,E>>
getModificationsContexts()
int
getNbConnectedComponents()
Return the number of connected componentsprotected Set<V>
getNonConnectedVertices(V vertex)
protected abstract int
getQuickComponentNumber(V vertex)
protected Collection<Set<V>>
getSmallComponents()
Set<V>
getVerticesAddedToMainComponent()
Return the vertices which were added to main component by last temporary changes.Set<V>
getVerticesRemovedFromMainComponent()
Return the vertices which were removed from main component by last temporary changes.void
removeEdge(E edge)
protected abstract void
resetConnectivity(Deque<GraphModification<V,E>> m)
void
setMainComponentVertex(V mainComponentVertex)
Set the main component with given vertex.void
startTemporaryChanges()
Start recording topological changes to undo them later by aGraphConnectivity.undoTemporaryChanges()
call.void
undoTemporaryChanges()
Undo all the connectivity changes (possibly none) since last call toGraphConnectivity.startTemporaryChanges()
.protected abstract void
updateComponents()
protected abstract void
updateConnectivity(EdgeAdd<V,E> edgeAdd)
protected abstract void
updateConnectivity(EdgeRemove<V,E> edgeRemove)
protected abstract void
updateConnectivity(VertexAdd<V,E> vertexAdd)
-
-
-
Method Detail
-
updateConnectivity
protected abstract void updateConnectivity(EdgeRemove<V,E> edgeRemove)
-
resetConnectivity
protected abstract void resetConnectivity(Deque<GraphModification<V,E>> m)
-
updateComponents
protected abstract void updateComponents()
-
addVertex
public void addVertex(V vertex)
- Specified by:
addVertex
in interfaceGraphConnectivity<V,E>
-
addEdge
public void addEdge(V vertex1, V vertex2, E edge)
- Specified by:
addEdge
in interfaceGraphConnectivity<V,E>
-
removeEdge
public void removeEdge(E edge)
- Specified by:
removeEdge
in interfaceGraphConnectivity<V,E>
-
startTemporaryChanges
public void startTemporaryChanges()
Description copied from interface:GraphConnectivity
Start recording topological changes to undo them later by aGraphConnectivity.undoTemporaryChanges()
call.- Specified by:
startTemporaryChanges
in interfaceGraphConnectivity<V,E>
-
undoTemporaryChanges
public void undoTemporaryChanges()
Description copied from interface:GraphConnectivity
Undo all the connectivity changes (possibly none) since last call toGraphConnectivity.startTemporaryChanges()
.- Specified by:
undoTemporaryChanges
in interfaceGraphConnectivity<V,E>
-
getComponentNumber
public int getComponentNumber(V vertex)
Description copied from interface:GraphConnectivity
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.- Specified by:
getComponentNumber
in interfaceGraphConnectivity<V,E>
- Parameters:
vertex
- the vertex whose connected component number is looked for- Returns:
- the number of the related connected component
-
getQuickComponentNumber
protected abstract int getQuickComponentNumber(V vertex)
-
getNbConnectedComponents
public int getNbConnectedComponents()
Description copied from interface:GraphConnectivity
Return the number of connected components- Specified by:
getNbConnectedComponents
in interfaceGraphConnectivity<V,E>
-
getSmallComponents
protected Collection<Set<V>> getSmallComponents()
-
getConnectedComponent
public Set<V> getConnectedComponent(V vertex)
Description copied from interface:GraphConnectivity
Return the connected component set of given vertex- Specified by:
getConnectedComponent
in interfaceGraphConnectivity<V,E>
-
getModificationsContexts
protected Deque<ModificationsContext<V,E>> getModificationsContexts()
-
checkSaved
protected void checkSaved()
-
checkVertex
protected void checkVertex(V vertex)
-
getVerticesAddedToMainComponent
public Set<V> getVerticesAddedToMainComponent()
Description copied from interface:GraphConnectivity
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.- Specified by:
getVerticesAddedToMainComponent
in interfaceGraphConnectivity<V,E>
-
getEdgesAddedToMainComponent
public Set<E> getEdgesAddedToMainComponent()
Description copied from interface:GraphConnectivity
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.- Specified by:
getEdgesAddedToMainComponent
in interfaceGraphConnectivity<V,E>
-
getVerticesRemovedFromMainComponent
public Set<V> getVerticesRemovedFromMainComponent()
Description copied from interface:GraphConnectivity
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.- Specified by:
getVerticesRemovedFromMainComponent
in interfaceGraphConnectivity<V,E>
-
getEdgesRemovedFromMainComponent
public Set<E> getEdgesRemovedFromMainComponent()
Description copied from interface:GraphConnectivity
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.- Specified by:
getEdgesRemovedFromMainComponent
in interfaceGraphConnectivity<V,E>
-
setMainComponentVertex
public void setMainComponentVertex(V mainComponentVertex)
Description copied from interface:GraphConnectivity
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.- Specified by:
setMainComponentVertex
in interfaceGraphConnectivity<V,E>
- Parameters:
mainComponentVertex
- vertex defining main component
-
-