V
- the graph vertex typeE
- the graph edge typepublic class ConnectivityInspector<V,E> extends Object implements GraphListener<V,E>
KosarajuStrongConnectivityInspector
instead.
The inspector methods work in a lazy fashion: no computation is performed unless immediately necessary. Computation are done once and results and cached within this class for future need.
The inspector is also a GraphListener
. If added as a listener to the
inspected graph, the inspector will amend internal cached results instead of recomputing them. It
is efficient when a few modifications are applied to a large graph. If many modifications are
expected it will not be efficient due to added overhead on graph update operations. If inspector
is added as listener to a graph other than the one it inspects, results are undefined.
Constructor and Description |
---|
ConnectivityInspector(Graph<V,E> g)
Creates a connectivity inspector for the specified graph.
|
Modifier and Type | Method and Description |
---|---|
Set<V> |
connectedSetOf(V vertex)
Returns a set of all vertices that are in the maximally connected component together with the
specified vertex.
|
List<Set<V>> |
connectedSets()
Returns a list of
Set s, where each set contains all vertices that are in the
same maximally connected component. |
void |
edgeAdded(GraphEdgeChangeEvent<V,E> e)
Notifies that an edge has been added to the graph.
|
void |
edgeRemoved(GraphEdgeChangeEvent<V,E> e)
Notifies that an edge has been removed from the graph.
|
boolean |
isConnected()
Test if the inspected graph is connected.
|
boolean |
isGraphConnected()
Deprecated.
for consistency, this method is renamed to
isConnected() |
boolean |
pathExists(V sourceVertex,
V targetVertex)
Tests whether two vertices lay respectively in the same connected component (undirected
graph), or in the same weakly connected component (directed graph).
|
void |
vertexAdded(GraphVertexChangeEvent<V> e)
Notifies that a vertex has been added to the graph.
|
void |
vertexRemoved(GraphVertexChangeEvent<V> e)
Notifies that a vertex has been removed from the graph.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
edgeWeightUpdated
@Deprecated public boolean isGraphConnected()
isConnected()
true
if and only if inspected graph is connected.public boolean isConnected()
true
if and only if inspected graph is connected.public Set<V> connectedSetOf(V vertex)
vertex
- the vertex for which the connected set to be returned.public List<Set<V>> connectedSets()
Set
s, where each set contains all vertices that are in the
same maximally connected component. All graph vertices occur in exactly one set. For more on
maximally connected component, see
http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html.Set
s, where each set contains all vertices that are
in the same maximally connected component.public void edgeAdded(GraphEdgeChangeEvent<V,E> e)
GraphListener
edgeAdded
in interface GraphListener<V,E>
e
- the edge event.GraphListener.edgeAdded(GraphEdgeChangeEvent)
public void edgeRemoved(GraphEdgeChangeEvent<V,E> e)
GraphListener
edgeRemoved
in interface GraphListener<V,E>
e
- the edge event.GraphListener.edgeRemoved(GraphEdgeChangeEvent)
public boolean pathExists(V sourceVertex, V targetVertex)
sourceVertex
- one end of the path.targetVertex
- another end of the path.true
if and only if the source and target vertex are in the same
connected component (undirected graph), or in the same weakly connected component
(directed graph).public void vertexAdded(GraphVertexChangeEvent<V> e)
VertexSetListener
vertexAdded
in interface VertexSetListener<V>
e
- the vertex event.VertexSetListener.vertexAdded(GraphVertexChangeEvent)
public void vertexRemoved(GraphVertexChangeEvent<V> e)
VertexSetListener
vertexRemoved
in interface VertexSetListener<V>
e
- the vertex event.VertexSetListener.vertexRemoved(GraphVertexChangeEvent)
Copyright © 2018. All rights reserved.