Last chance! 50% off unlimited learning
Sale ends in
Calculates a measure of diversity for all vertices.
diversity(graph, weights = NULL, vids = V(graph))
A numeric vector, its length is the number of vertices.
The input graph. Edge directions are ignored.
NULL
, or the vector of edge weights to use for the
computation. If NULL
, then the ‘weight’ attibute is used. Note
that this measure is not defined for unweighted graphs.
The vertex ids for which to calculate the measure.
Gabor Csardi csardi.gabor@gmail.com
The diversity of a vertex is defined as the (scaled) Shannon entropy of the
weights of its incident edges:
For vertices with degree less than two the function returns NaN
.
Nathan Eagle, Michael Macy and Rob Claxton: Network Diversity and Economic Development, Science 328, 1029--1031, 2010.
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)
Run the code above in your browser using DataLab