Class DistanceCentralityScorer<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.scoring.DistanceCentralityScorer<V,E>
-
- All Implemented Interfaces:
VertexScorer<V,java.lang.Double>
- Direct Known Subclasses:
BarycenterScorer
,ClosenessCentrality
public class DistanceCentralityScorer<V,E> extends java.lang.Object implements VertexScorer<V,java.lang.Double>
Assigns scores to vertices based on their distances to each other vertex in the graph. This class optionally normalizes its results based on the value of its 'averaging' constructor parameter. If it istrue
, then the value returned for vertex v is 1 / (_average_ distance from v to all other vertices); this is sometimes called closeness centrality. If it isfalse
, then the value returned is 1 / (_total_ distance from v to all other vertices); this is sometimes referred to as barycenter centrality. (If the average/total distance is 0, the value returned isDouble.POSITIVE_INFINITY
.)- See Also:
BarycenterScorer
,ClosenessCentrality
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
averaging
Specifies whether the values returned are the sum of the v-distances or the mean v-distance.protected Distance<V>
distance
The metric to use for specifying the distance between pairs of vertices.protected Hypergraph<V,E>
graph
The graph on which the vertex scores are to be calculated.protected boolean
ignore_missing
Specifies whether, for a vertexv
with missing (null) distances,v
's score should ignore the missing values or be set to 'null'.protected boolean
ignore_self_distances
Specifies whether the values returned should ignore self-distances (distances fromv
to itself).protected java.util.Map<V,java.lang.Double>
output
The cache for the output results.
-
Constructor Summary
Constructors Constructor Description DistanceCentralityScorer(Hypergraph<V,E> graph, boolean averaging)
Equivalent tothis(graph, averaging, true, true)
.DistanceCentralityScorer(Hypergraph<V,E> graph, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph and averaging behavior whose vertex distances are calculated on the unweighted graph.DistanceCentralityScorer(Hypergraph<V,E> graph, com.google.common.base.Function<E,? extends java.lang.Number> edge_weights, boolean averaging)
Equivalent tothis(graph, edge_weights, averaging, true, true)
.DistanceCentralityScorer(Hypergraph<V,E> graph, com.google.common.base.Function<E,? extends java.lang.Number> edge_weights, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph and averaging behavior whose vertex distances are calculated based on the specified edge weights.DistanceCentralityScorer(Hypergraph<V,E> graph, Distance<V> distance, boolean averaging)
Equivalent tothis(graph, distance, averaging, true, true)
.DistanceCentralityScorer(Hypergraph<V,E> graph, Distance<V> distance, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph, distance metric, and averaging behavior.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Double
getVertexScore(V v)
Calculates the score for the specified vertex.
-
-
-
Field Detail
-
graph
protected Hypergraph<V,E> graph
The graph on which the vertex scores are to be calculated.
-
distance
protected Distance<V> distance
The metric to use for specifying the distance between pairs of vertices.
-
output
protected java.util.Map<V,java.lang.Double> output
The cache for the output results. Null encodes "not yet calculated", < 0 encodes "no such distance exists".
-
averaging
protected boolean averaging
Specifies whether the values returned are the sum of the v-distances or the mean v-distance.
-
ignore_missing
protected boolean ignore_missing
Specifies whether, for a vertexv
with missing (null) distances,v
's score should ignore the missing values or be set to 'null'. Defaults to 'true'.
-
ignore_self_distances
protected boolean ignore_self_distances
Specifies whether the values returned should ignore self-distances (distances fromv
to itself). Defaults to 'true'.
-
-
Constructor Detail
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, Distance<V> distance, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph, distance metric, and averaging behavior.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.distance
- The metric to use for specifying the distance between pairs of vertices.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.ignore_missing
- Specifies whether scores for missing distances are to ignore missing distances or be set to null.ignore_self_distances
- Specifies whether distances from a vertex to itself should be included in its score.
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, Distance<V> distance, boolean averaging)
Equivalent tothis(graph, distance, averaging, true, true)
.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.distance
- The metric to use for specifying the distance between pairs of vertices.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, com.google.common.base.Function<E,? extends java.lang.Number> edge_weights, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph and averaging behavior whose vertex distances are calculated based on the specified edge weights.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.edge_weights
- The edge weights to use for specifying the distance between pairs of vertices.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.ignore_missing
- Specifies whether scores for missing distances are to ignore missing distances or be set to null.ignore_self_distances
- Specifies whether distances from a vertex to itself should be included in its score.
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, com.google.common.base.Function<E,? extends java.lang.Number> edge_weights, boolean averaging)
Equivalent tothis(graph, edge_weights, averaging, true, true)
.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.edge_weights
- The edge weights to use for specifying the distance between pairs of vertices.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, boolean averaging, boolean ignore_missing, boolean ignore_self_distances)
Creates an instance with the specified graph and averaging behavior whose vertex distances are calculated on the unweighted graph.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.ignore_missing
- Specifies whether scores for missing distances are to ignore missing distances or be set to null.ignore_self_distances
- Specifies whether distances from a vertex to itself should be included in its score.
-
DistanceCentralityScorer
public DistanceCentralityScorer(Hypergraph<V,E> graph, boolean averaging)
Equivalent tothis(graph, averaging, true, true)
.- Parameters:
graph
- The graph on which the vertex scores are to be calculated.averaging
- Specifies whether the values returned is the sum of all v-distances or the mean v-distance.
-
-
Method Detail
-
getVertexScore
public java.lang.Double getVertexScore(V v)
Calculates the score for the specified vertex. Returnsnull
if there are missing distances and such are not ignored by this instance.- Specified by:
getVertexScore
in interfaceVertexScorer<V,E>
- Parameters:
v
- the vertex whose score is requested- Returns:
- the algorithm's score for this vertex
-
-