Closeness centrality measures how many steps is required to access every other vertex from a given vertex.
closeness(
graph,
vids = V(graph),
mode = c("out", "in", "all", "total"),
weights = NULL,
normalized = FALSE,
cutoff = -1
)
The graph to analyze.
The vertices for which closeness will be calculated.
Character string, defined the types of the paths used for measuring the distance in directed graphs. “in” measures the paths to a vertex, “out” measures paths from a vertex, all uses undirected paths. This argument is ignored for undirected graphs.
Optional positive weight vector for calculating weighted
closeness. If the graph has a weight
edge attribute, then this is
used by default. Weights are used for calculating weighted shortest
paths, so they are interpreted as distances.
Logical scalar, whether to calculate the normalized closeness. Normalization is performed by multiplying the raw closeness by \(n-1\), where \(n\) is the number of vertices in the graph.
The maximum path length to consider when calculating the betweenness. If zero or negative then there is no such limit.
Numeric vector with the closeness values of all the vertices in
v
.
The closeness centrality of a vertex is defined by the inverse of the average length of the shortest paths to/from all the other vertices in the graph:
$$\frac{1}{\sum_{i\ne v} d_vi}$$
If there is no (directed) path between vertex v
and i
, then
the total number of vertices is used in the formula instead of the path
length.
cutoff
or smaller. this can be run for larger graphs, as the running
time is not quadratic (if cutoff
is small). If cutoff
is zero
or negative (which is the default), then the function calculates the exact
closeness scores. Using zero as a cutoff is deprecated and future
versions (from 1.4.0) will treat zero cutoff literally (i.e. no paths
considered at all). If you want no cutoff, use a negative number.
estimate_closeness
is an alias for closeness
with a different
argument order, for sake of compatibility with older versions of igraph.
Closeness centrality is meaningful only for connected graphs. In disconnected
graphs, consider using the harmonic centrality with
harmonic_centrality
Freeman, L.C. (1979). Centrality in Social Networks I: Conceptual Clarification. Social Networks, 1, 215-239.
# NOT RUN {
g <- make_ring(10)
g2 <- make_star(10)
closeness(g)
closeness(g2, mode="in")
closeness(g2, mode="out")
closeness(g2, mode="all")
# }
Run the code above in your browser using DataLab