Class GeometricCentralities
Note that usually one is interested in the negative version of a centrality measure, that is, the version that depends on the incoming arcs. This class can compute only positive centralities: if you are interested (as it usually happens) in the negative version, you must pass to this class the transpose of the graph.
Every visit is independent and is carried out by a separate thread. The only contention point is the update of the array accumulating the betweenness score, which is negligible. The downside is that running on k cores requires approximately k times the memory of the sequential algorithm, as only the graph and the betweenness array will be shared.
To use this class you first create an instance, and then invoke compute()
.
After that, you can peek at the fields closeness
, lin
, harmonic
, exponential
and reachable
.
-
Field Summary
FieldsModifier and TypeFieldDescriptiondouble
final double[]
Closeness centrality.static final double
The default value foralpha
.final double[]
Exponential centrality.final double[]
Harmonic centrality.final double[]
Lin's centrality.protected final AtomicInteger
The next node to be visited.final long[]
Number of reachable nodes.protected boolean
Whether to stop abruptly the visiting process. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new class for computing positive geometric centralities and the number of reachable nodes, using as many threads as the number of available processors.GeometricCentralities
(ImmutableGraph graph, int requestedThreads) Creates a new class for computing positive geometric centralities and the number of reachable nodes.GeometricCentralities
(ImmutableGraph graph, int requestedThreads, it.unimi.dsi.logging.ProgressLogger pl) Creates a new class for computing positive geometric centralities and the number reachable nodes.GeometricCentralities
(ImmutableGraph graph, it.unimi.dsi.logging.ProgressLogger pl) Creates a new class for computing positive geometric centralities and the number of reachable nodes, using as many threads as the number of available processors. -
Method Summary
-
Field Details
-
DEFAULT_ALPHA
public static final double DEFAULT_ALPHAThe default value foralpha
.- See Also:
-
harmonic
public final double[] harmonicHarmonic centrality. -
closeness
public final double[] closenessCloseness centrality. -
lin
public final double[] linLin's centrality. -
exponential
public final double[] exponentialExponential centrality. -
alpha
public double alpha -
reachable
public final long[] reachableNumber of reachable nodes. -
nextNode
The next node to be visited. -
stop
protected volatile boolean stopWhether to stop abruptly the visiting process.
-
-
Constructor Details
-
GeometricCentralities
public GeometricCentralities(ImmutableGraph graph, int requestedThreads, it.unimi.dsi.logging.ProgressLogger pl) Creates a new class for computing positive geometric centralities and the number reachable nodes.- Parameters:
graph
- a graph.requestedThreads
- the requested number of threads (0 forRuntime.availableProcessors()
).pl
- a progress logger, ornull
.
-
GeometricCentralities
Creates a new class for computing positive geometric centralities and the number of reachable nodes, using as many threads as the number of available processors.- Parameters:
graph
- a graph.pl
- a progress logger, ornull
.
-
GeometricCentralities
Creates a new class for computing positive geometric centralities and the number of reachable nodes.- Parameters:
graph
- a graph.requestedThreads
- the requested number of threads (0 forRuntime.availableProcessors()
).
-
GeometricCentralities
Creates a new class for computing positive geometric centralities and the number of reachable nodes, using as many threads as the number of available processors.- Parameters:
graph
- a graph.
-
-
Method Details
-
compute
Computes geometric centralities and the number of reachable nodes. Results can be found incloseness
,lin
,harmonic
,exponential
andreachable
.- Throws:
InterruptedException
-
main
public static void main(String[] arg) throws IOException, com.martiansoftware.jsap.JSAPException, InterruptedException - Throws:
IOException
com.martiansoftware.jsap.JSAPException
InterruptedException
-