java.lang.Object
org.jgrapht.alg.connectivity.ConnectivityInspector<V,E>
 Type Parameters:
V
 the graph vertex typeE
 the graph edge type
 All Implemented Interfaces:
EventListener
,GraphListener<V,
,E> VertexSetListener<V>
Allows obtaining various connectivity aspects of a graph. The inspected graph is specified
at construction time and cannot be modified. Currently, the inspector supports connected
components for an undirected graph and weakly connected components for a directed graph. To find
strongly connected components, use
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.
 Author:
 Barak Naveh, John V. Sichi

Constructor Summary
ConstructorDescriptionConnectivityInspector
(Graph<V, E> g) Creates a connectivity inspector for the specified graph. 
Method Summary
Modifier and TypeMethodDescriptionconnectedSetOf
(V vertex) Returns a set of all vertices that are in the maximally connected component together with the specified vertex.Returns a list ofSet
s, where each set contains all vertices that are in the same maximally connected component.void
Notifies that an edge has been added to the graph.void
Notifies that an edge has been removed from the graph.boolean
Test if the inspected graph is connected.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
Notifies that a vertex has been added to the graph.void
Notifies that a vertex has been removed from the graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jgrapht.event.GraphListener
edgeWeightUpdated

Constructor Details

ConnectivityInspector
Creates a connectivity inspector for the specified graph. Parameters:
g
 the graph for which a connectivity inspector to be created.


Method Details

isConnected
public boolean isConnected()Test if the inspected graph is connected. A graph is connected when there is a path between every pair of vertices. In a connected graph, there are no unreachable vertices. When the inspected graph is a directed graph, this method returns true if and only if the inspected graph is weakly connected. An empty graph is not considered connected. Returns:
true
if and only if inspected graph is connected.

connectedSetOf
Returns a set of all vertices that are in the maximally connected component together with the specified vertex. For more on maximally connected component, see http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html. Parameters:
vertex
 the vertex for which the connected set to be returned. Returns:
 a set of all vertices that are in the maximally connected component together with the specified vertex.

connectedSets
Returns a list ofSet
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. Returns:
 Returns a list of
Set
s, where each set contains all vertices that are in the same maximally connected component.

edgeAdded
Description copied from interface:GraphListener
Notifies that an edge has been added to the graph. Specified by:
edgeAdded
in interfaceGraphListener<V,
E>  Parameters:
e
 the edge event. See Also:

edgeRemoved
Description copied from interface:GraphListener
Notifies that an edge has been removed from the graph. Specified by:
edgeRemoved
in interfaceGraphListener<V,
E>  Parameters:
e
 the edge event. See Also:

pathExists
Tests whether two vertices lay respectively in the same connected component (undirected graph), or in the same weakly connected component (directed graph). Parameters:
sourceVertex
 one end of the path.targetVertex
 another end of the path. Returns:
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).

vertexAdded
Description copied from interface:VertexSetListener
Notifies that a vertex has been added to the graph. Specified by:
vertexAdded
in interfaceVertexSetListener<V>
 Parameters:
e
 the vertex event. See Also:

vertexRemoved
Description copied from interface:VertexSetListener
Notifies that a vertex has been removed from the graph. Specified by:
vertexRemoved
in interfaceVertexSetListener<V>
 Parameters:
e
 the vertex event. See Also:
