diversity | R Documentation |
Calculates a measure of diversity for all vertices.
diversity(graph, weights = NULL, vids = V(graph))
graph |
The input graph. Edge directions are ignored. |
weights |
|
vids |
The vertex ids for which to calculate the measure. |
The diversity of a vertex is defined as the (scaled) Shannon entropy of the weights of its incident edges:
D(i)=\frac{H(i)}{\log k_i}
and
H(i)=-\sum_{j=1}^{k_i} p_{ij}\log p_{ij},
where
p_{ij}=\frac{w_{ij}}{\sum_{l=1}^{k_i}}V_{il},
and k_i
is the (total) degree of vertex
i
, w_{ij}
is the weight of the edge(s) between vertices
i
and j
.
For vertices with degree less than two the function returns NaN
.
A numeric vector, its length is the number of vertices.
Gabor Csardi csardi.gabor@gmail.com
Nathan Eagle, Michael Macy and Rob Claxton: Network Diversity and Economic Development, Science 328, 1029–1031, 2010.
Centrality measures
alpha_centrality()
,
authority_score()
,
betweenness()
,
closeness()
,
eigen_centrality()
,
harmonic_centrality()
,
hits_scores()
,
page_rank()
,
power_centrality()
,
spectrum()
,
strength()
,
subgraph_centrality()
g1 <- sample_gnp(20, 2 / 20)
g2 <- sample_gnp(20, 2 / 20)
g3 <- sample_gnp(20, 5 / 20)
E(g1)$weight <- 1
E(g2)$weight <- runif(ecount(g2))
E(g3)$weight <- runif(ecount(g3))
diversity(g1)
diversity(g2)
diversity(g3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.