|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.webgraph.algo.StronglyConnectedComponents
public class StronglyConnectedComponents
Computes the strongly connected components (and optionally the buckets) of an immutable graph.
The compute(ImmutableGraph, boolean, ProgressLogger)
method of this class will return
an instance that contains the data computed by running a variant of Tarjan's algorithm on an immutable graph.
Besides the usually strongly connected components, it is possible to compute the buckets of the
graph, that is, nodes belonging to components that are terminal, but not dangling, in the component DAG.
After getting an instance, it is possible to run the computeSizes()
and sortBySize(int[])
methods to obtain further information. This scheme has been devised to exploit the available memory as much
as possible—after the components have been computed, the returned instance keeps no track of
the graph, and the related memory can be freed by the garbage collector.
The method compute(ImmutableGraph, boolean, ProgressLogger)
might require a large stack size,
that should be set using suitable JVM options. Note, however,
that the stack size must be enlarged also on the operating-system side—for instance, using ulimit -s unlimited.
Field Summary | |
---|---|
BitSet |
buckets
The bit set for buckets, or null , in which case buckets have not been computed. |
int[] |
component
The component of each node. |
int |
numberOfComponents
The number of strongly connected components. |
Constructor Summary | |
---|---|
protected |
StronglyConnectedComponents(int numberOfComponents,
int[] component,
BitSet buckets)
|
Method Summary | |
---|---|
static StronglyConnectedComponents |
compute(ArcLabelledImmutableGraph graph,
Transform.LabelledArcFilter filter,
boolean computeBuckets,
ProgressLogger pl)
Computes the strongly connected components of a given arc-labelled graph, filtering its arcs. |
static StronglyConnectedComponents |
compute(ImmutableGraph graph,
boolean computeBuckets,
ProgressLogger pl)
Computes the strongly connected components of a given graph. |
int[] |
computeSizes()
Returns the size array for this set of strongly connected components. |
static void |
main(String[] arg)
|
void |
sortBySize(int[] size)
Renumbers by decreasing size the components of this set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int numberOfComponents
public final int[] component
public final BitSet buckets
null
, in which case buckets have not been computed.
Constructor Detail |
---|
protected StronglyConnectedComponents(int numberOfComponents, int[] component, BitSet buckets)
Method Detail |
---|
public static StronglyConnectedComponents compute(ImmutableGraph graph, boolean computeBuckets, ProgressLogger pl)
graph
- the graph whose strongly connected components are to be computed.computeBuckets
- if true, buckets will be computed.pl
- a progress logger, or null
.
public static StronglyConnectedComponents compute(ArcLabelledImmutableGraph graph, Transform.LabelledArcFilter filter, boolean computeBuckets, ProgressLogger pl)
graph
- the arc-labelled graph whose strongly connected components are to be computed.filter
- a filter selecting the arcs that must be taken into consideration.computeBuckets
- if true, buckets will be computed.pl
- a progress logger, or null
.
public int[] computeSizes()
public void sortBySize(int[] size)
After a call to this method, both the internal status of this class and the argument array are permuted so that the sizes of strongly connected components are decreasing in the component index.
size
- the components sizes, as returned by computeSizes()
.public static void main(String[] arg) throws IOException, JSAPException
IOException
JSAPException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |