radius

Contents

radius#

graph_tool.structure.radius(g, weights=None, epsilon=1e-08)[git][source]#

Compute the radius of the graph.

Parameters:
gGraph

Graph to be used.

weightsEdgePropertyMap (optional, default: None)

Non-negative edge weights. If not supplied, every edge has unit length.

epsilonfloat (optional, default: 1e-8)

Relative tolerance with which lower and upper bounds are considered equal, if the weights are floating-point numbers.

Returns:
radiusint or float

The radius of the graph.

centerVertex

A vertex with eccentricity equal to the radius.

See also

diameter

Maximum eccentricity

eccentricity

Eccentricity of every vertex

center

Vertices of minimum eccentricity

Notes

The radius is the smallest eccentricity of the vertices (see eccentricity()). Since the eccentricity considers only reachable vertices, the radius of a graph with an isolated vertex (or, if directed, with a vertex without out-neighbors) is zero; for the radius of the largest component, the function should be called on the output of extract_largest_component().

For undirected graphs, the eccentricities are bounded as in eccentricity() [takes-determining-2011], and the searches stop as soon as the smallest lower and upper bounds coincide. In the worst case, \(V\) searches are needed, each taking time \(O(V+E)\), or \(O((V+E)\log V)\) with weights. For directed graphs, a search is made from every vertex.

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

[takes-determining-2011]

Frank W. Takes and Walter A. Kosters, “Determining the diameter of small world networks”, Proceedings of the 20th ACM International Conference on Information and Knowledge Management (CIKM), 1191-1196 (2011), DOI: 10.1145/2063576.2063748 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["polblogs"]
>>> g = gt.extract_largest_component(g, directed=False, prune=True)
>>> g.set_directed(False)
>>> r, c = gt.radius(g)
>>> print(r)
4