barycenter

Contents

barycenter#

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

Return the barycenter of the graph, i.e. the vertices with the smallest sum of distances to all others.

Parameters:
gGraph

Graph to be used, which must be connected (strongly connected, if directed).

weightsEdgePropertyMap (optional, default: None)

Edge weights (lengths).

Returns:
barycenternumpy.ndarray

The vertices that minimize \(\sum_u d(v, u)\).

See also

center

Vertices of minimum eccentricity

wiener_index

Sum of the distances between all pairs

graph_tool.centrality.closeness

Closeness centrality

Notes

The sums of distances are obtained from closeness(), with a search from every vertex in parallel, in time \(O(VE)\) without weights.

Examples

>>> g = gt.collection.data["karate"]
>>> print(gt.barycenter(g))
[0]