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:
- g
Graph Graph to be used, which must be connected (strongly connected, if directed).
- weights
EdgePropertyMap(optional, default:None) Edge weights (lengths).
- g
- Returns:
- barycenter
numpy.ndarray The vertices that minimize \(\sum_u d(v, u)\).
- barycenter
See also
centerVertices of minimum eccentricity
wiener_indexSum of the distances between all pairs
graph_tool.centrality.closenessCloseness 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]