radius#
- graph_tool.structure.radius(g, weights=None, epsilon=1e-08)[git][source]#
Compute the radius of the graph.
- Parameters:
- g
Graph Graph to be used.
- weights
EdgePropertyMap(optional, default:None) Non-negative edge weights. If not supplied, every edge has unit length.
- epsilon
float(optional, default:1e-8) Relative tolerance with which lower and upper bounds are considered equal, if the weights are floating-point numbers.
- g
- Returns:
- radius
intorfloat The radius of the graph.
- center
Vertex A vertex with eccentricity equal to the radius.
- radius
See also
diameterMaximum eccentricity
eccentricityEccentricity of every vertex
centerVertices 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 ofextract_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