- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.algorithms.SCCs<G,N,E>
-
- Type Parameters:
G
- the type of the targetGraph
sN
- the type ofNode
s in the target graphsE
- the type ofEdge
s in the target graphs
public class SCCs<G extends Graph<G,N,E>,N extends Node<G,N,E>,E extends Edge<G,N,E>> extends java.lang.Object
An algorithms that evaluates the strongly connected components a graph. A strongly connected component is a set of nodes of the graph that is strongly connected, that is, where there exist a path in both directions between any two nodes of the set. This is implemented Tarjan's algorithm, computing maximal non-trivial SCCs (i.e., containing at least one edge and such that no other node could be added without breaking strong connectivity).
-
-
Constructor Summary
Constructors Constructor Description SCCs()
Builds the SCCs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.util.Collection<N>>
build(G graph)
Builds the strongly connected components for the given graph.java.util.Collection<java.util.Collection<N>>
buildNonTrivial(G graph)
Builds the strongly connected components for the given graph.java.util.Collection<java.util.Collection<N>>
getSCCs()
Yields the last computed strongly connected components throughbuild(Graph)
.
-
-
-
Constructor Detail
-
SCCs
public SCCs()
Builds the SCCs. To run the algorithm, usebuild(Graph)
.
-
-
Method Detail
-
getSCCs
public java.util.Collection<java.util.Collection<N>> getSCCs()
Yields the last computed strongly connected components throughbuild(Graph)
. Note that, depending on the method used for computing them, the returned value might contain all components, including trivial single-node ones.- Returns:
- a set containing all the strongly connected components
-
buildNonTrivial
public java.util.Collection<java.util.Collection<N>> buildNonTrivial(G graph)
Builds the strongly connected components for the given graph. The returned value can also be accessed later throughgetSCCs()
. Note that the returned value does not contain trivial single-node components. This also holds for the value returned bygetSCCs()
.- Parameters:
graph
- the graph whose sccs are to be computed- Returns:
- the set of non trivial sccs
-
build
public java.util.Collection<java.util.Collection<N>> build(G graph)
Builds the strongly connected components for the given graph. The returned value can also be accessed later throughgetSCCs()
. Note that the returned value contains all components, including trivial single-node ones. This also holds for the value returned bygetSCCs()
.- Parameters:
graph
- the graph whose sccs are to be computed- Returns:
- the set of all sccs
-
-