Closeness centrality measures how many steps is required to access every other vertex from a given vertex.
Arguments
- graph
The graph to analyze.
- vids
The vertices for which closeness will be calculated.
- mode
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.
- weights
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.- normalized
Logical scalar, whether to calculate the normalized closeness, i.e. the inverse average distance to all reachable vertices. The non-normalized closeness is the inverse of the sum of distances to all reachable vertices.
- cutoff
The maximum path length to consider when calculating the closeness. If zero or negative then there is no such limit.
Details
The closeness centrality of a vertex is defined as the inverse of the sum of distances to 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
i
is omitted from the calculation. If no other vertices are reachable
from v
, then its closeness is returned as NaN.
cutoff
or smaller. This can be run for larger graphs, as the running
time is not quadratic (if cutoff
is small). If cutoff
is
negative (which is the default), then the function calculates the exact
closeness scores. Since igraph 1.6.0, a cutoff
value of zero is treated
literally, i.e. path with a length greater than zero are ignored.
Closeness centrality is meaningful only for connected graphs. In disconnected
graphs, consider using the harmonic centrality with
harmonic_centrality()
References
Freeman, L.C. (1979). Centrality in Social Networks I: Conceptual Clarification. Social Networks, 1, 215-239.
See also
Centrality measures
alpha_centrality()
,
authority_score()
,
betweenness()
,
diversity()
,
eigen_centrality()
,
harmonic_centrality()
,
hits_scores()
,
page_rank()
,
power_centrality()
,
spectrum()
,
strength()
,
subgraph_centrality()
Author
Gabor Csardi csardi.gabor@gmail.com
Examples
g <- make_ring(10)
g2 <- make_star(10)
closeness(g)
#> [1] 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04
closeness(g2, mode = "in")
#> [1] 0.1111111 NaN NaN NaN NaN NaN NaN
#> [8] NaN NaN NaN
closeness(g2, mode = "out")
#> [1] NaN 1 1 1 1 1 1 1 1 1
closeness(g2, mode = "all")
#> [1] 0.11111111 0.05882353 0.05882353 0.05882353 0.05882353 0.05882353
#> [7] 0.05882353 0.05882353 0.05882353 0.05882353