harmonic_diameter#
- graph_tool.structure.harmonic_diameter(g, weights=None)[git][source]#
Return the harmonic diameter of the graph.
- Parameters:
- g
Graph Graph to be used.
- weights
EdgePropertyMap(optional, default:None) Edge weights (lengths).
- g
- Returns:
- D
float The harmonic mean of the distances over all ordered pairs of distinct vertices, \(V(V-1)/\sum_{u\ne v}1/d(u,v)\), with \(1/d = 0\) for unreachable pairs [marchiori-harmony-2000].
- D
See also
diameterMaximum distance
global_efficiencyAverage inverse distance
average_shortest_path_lengthAverage distance between pairs of vertices
Notes
It is the inverse of the
global_efficiency(). The algorithm runs in time \(O(VE)\) without weights, in parallel.Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[marchiori-harmony-2000]Massimo Marchiori and Vito Latora, “Harmony in the small-world”, Physica A 285, 539-546 (2000), DOI: 10.1016/S0378-4371(00)00311-3 [sci-hub, @tor], arXiv: cond-mat/0008357
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.harmonic_diameter(g)) 2.0324859...