harmonic_diameter

harmonic_diameter#

graph_tool.structure.harmonic_diameter(g, weights=None)[git][source]#

Return the harmonic diameter of the graph.

Parameters:
gGraph

Graph to be used.

weightsEdgePropertyMap (optional, default: None)

Edge weights (lengths).

Returns:
Dfloat

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].

See also

diameter

Maximum distance

global_efficiency

Average inverse distance

average_shortest_path_length

Average 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...