periphery

Contents

periphery#

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

Return the periphery of the graph, i.e. the vertices of maximum eccentricity.

Parameters:
gGraph

Graph to be used.

weightsEdgePropertyMap (optional, default: None)

Edge weights (lengths).

Returns:
peripherynumpy.ndarray

The vertices whose eccentricity equals the diameter.

See also

center

Vertices of minimum eccentricity

eccentricity

Eccentricity of every vertex

diameter

Maximum eccentricity

Notes

The periphery is the set

\[\{v : \epsilon(v) = \max_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(), and those that differ by a relative amount of at most \(10^{-12}\) are considered equal.

Examples

>>> g = gt.collection.data["karate"]
>>> print(gt.periphery(g))
[14 15 16 18 20 22 23 26 29]

The periphery can be highlighted in a drawing of the network:

>>> vcolor = g.new_vp("string", val="#cccccc")
>>> for v in gt.periphery(g):
...     vcolor[v] = "#f28c8e"
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor,
...               edge_color="#999999", output="periphery-karate.pdf")
<...>
../_images/periphery-karate.png

Periphery of Zachary’s karate club network, with its vertices shown in red.#