Class DistanceStatistics
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics
-
public class DistanceStatistics extends java.lang.Object
Statistics relating to vertex-vertex distances in a graph.Formerly known as
GraphStatistics
in JUNG 1.x.
-
-
Constructor Summary
Constructors Constructor Description DistanceStatistics()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V,E>
org.apache.commons.collections4.Transformer<V,java.lang.Double>averageDistances(edu.uci.ics.jung.graph.Hypergraph<V,E> g)
For each vertexv
ing
, calculates the average shortest path length fromv
to all other vertices ing
, ignoring edge weights.static <V,E>
org.apache.commons.collections4.Transformer<V,java.lang.Double>averageDistances(edu.uci.ics.jung.graph.Hypergraph<V,E> graph, Distance<V> d)
For each vertexv
ingraph
, calculates the average shortest path length fromv
to all other vertices ingraph
using the metric specified byd
, and returns the results in aMap
from vertices toDouble
values.static <V,E>
doublediameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g)
Returns the diameter ofg
, ignoring edge weights.static <V,E>
doublediameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g, Distance<V> d)
Returns the diameter ofg
using the metric specified byd
.static <V,E>
doublediameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g, Distance<V> d, boolean use_max)
Returns the diameter ofg
using the metric specified byd
.
-
-
-
Method Detail
-
averageDistances
public static <V,E> org.apache.commons.collections4.Transformer<V,java.lang.Double> averageDistances(edu.uci.ics.jung.graph.Hypergraph<V,E> graph, Distance<V> d)
For each vertexv
ingraph
, calculates the average shortest path length fromv
to all other vertices ingraph
using the metric specified byd
, and returns the results in aMap
from vertices toDouble
values. If there exists an ordered pair<u,v>
for whichd.getDistance(u,v)
returnsnull
, then the average distance value foru
will be stored asDouble.POSITIVE_INFINITY
).Does not include self-distances (path lengths from
v
tov
).To calculate the average distances, ignoring edge weights if any:
Map distances = DistanceStatistics.averageDistances(g, new UnweightedShortestPath(g));
To calculate the average distances respecting edge weights:DijkstraShortestPath dsp = new DijkstraShortestPath(g, nev); Map distances = DistanceStatistics.averageDistances(g, dsp);
wherenev
is an instance ofTransformer
that is used to fetch the weight for each edge.- See Also:
UnweightedShortestPath
,DijkstraDistance
-
averageDistances
public static <V,E> org.apache.commons.collections4.Transformer<V,java.lang.Double> averageDistances(edu.uci.ics.jung.graph.Hypergraph<V,E> g)
For each vertexv
ing
, calculates the average shortest path length fromv
to all other vertices ing
, ignoring edge weights.- See Also:
diameter(Hypergraph)
,ClosenessCentrality
-
diameter
public static <V,E> double diameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g, Distance<V> d, boolean use_max)
Returns the diameter ofg
using the metric specified byd
. The diameter is defined to be the maximum, over all pairs of verticesu,v
, of the length of the shortest path fromu
tov
. If the graph is disconnected (that is, not all pairs of vertices are reachable from one another), the value returned will depend onuse_max
: ifuse_max == true
, the value returned will be the the maximum shortest path length over all pairs of connected vertices; otherwise it will beDouble.POSITIVE_INFINITY
.
-
diameter
public static <V,E> double diameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g, Distance<V> d)
Returns the diameter ofg
using the metric specified byd
. The diameter is defined to be the maximum, over all pairs of verticesu,v
, of the length of the shortest path fromu
tov
, orDouble.POSITIVE_INFINITY
if any of these distances do not exist.- See Also:
diameter(Hypergraph, Distance, boolean)
-
diameter
public static <V,E> double diameter(edu.uci.ics.jung.graph.Hypergraph<V,E> g)
Returns the diameter ofg
, ignoring edge weights.- See Also:
diameter(Hypergraph, Distance, boolean)
-
-