Eccentricity of the vertices in a graphSource:
The eccentricity of a vertex is its shortest path distance from the farthest other node in the graph.
The input graph, it can be directed or undirected.
The vertices for which the eccentricity is calculated.
Character constant, gives whether the shortest paths to or from the given vertices should be calculated for directed graphs. If
outthen the shortest paths from the vertex, if
inthen to it will be considered. If
all, the default, then the corresponding undirected graph will be used, edge directions will be ignored. This argument is ignored for undirected graphs.
eccentricity() returns a numeric vector, containing the
eccentricity score of each given vertex.
The eccentricity of a vertex is calculated by measuring the shortest distance from (or to) the vertex, to (or from) all vertices in the graph, and taking the maximum.
This implementation ignores vertex pairs that are in different components. Isolate vertices have eccentricity zero.
radius() for a related concept,
distances() for general shortest path calculations.
g <- make_star(10, mode = "undirected") eccentricity(g) #>  1 2 2 2 2 2 2 2 2 2