center#
- graph_tool.structure.center(g, weights=None)[git][source]#
Return the center of the graph, i.e. the vertices of minimum eccentricity.
- Parameters:
- g
Graph Graph to be used.
- weights
EdgePropertyMap(optional, default:None) Edge weights (lengths).
- g
- Returns:
- center
numpy.ndarray The vertices whose eccentricity equals the radius.
- center
See also
peripheryVertices of maximum eccentricity
barycenterVertices of minimum total distance
eccentricityEccentricity of every vertex
radiusMinimum eccentricity
Notes
The center is the set
\[\{v : \epsilon(v) = \min_u \epsilon(u)\}, \qquad \epsilon(v) = \max_{u} d(v, u),\]where \(\epsilon(v)\) is the eccentricity of \(v\), and \(d(v, u)\) the length of a shortest path from \(v\) to \(u\) (directed, for directed graphs), with the maximum taken only over the vertices reachable from \(v\). The eccentricities are computed with
eccentricity(), so that for disconnected graphs the center is taken over all components (with isolated vertices having eccentricity zero). Eccentricities that differ by a relative amount of at most \(10^{-12}\) are considered equal.Examples
>>> g = gt.collection.data["karate"] >>> print(gt.center(g)) [ 0 1 2 3 8 13 19 31]
The center can be highlighted in a drawing of the network:
>>> vcolor = g.new_vp("string", val="#cccccc") >>> for v in gt.center(g): ... vcolor[v] = "#f28c8e" >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor, ... edge_color="#999999", output="center-karate.pdf") <...>
Center of Zachary’s karate club network, with its vertices shown in red.#