igraph (version 0.6-2)

graph.diversity: Graph diversity

Description

Calculates a measure of diversity for all vertices.

Usage

graph.diversity(graph, weights = NULL, vids = V(graph))

Arguments

graph
The input graph. Edge directions are ignored.
weights
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.
vids
The vertex ids for which to calculate the measure.

Value

  • A numeric vector, its length is the number of vertices.

concept

Entropy

Details

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.

References

Nathan Eagle, Michael Macy and Rob Claxton: Network Diversity and Economic Development, Science 328, 1029--1031, 2010.

Examples

Run this code
g1 <- erdos.renyi.game(20, 2/20)
g2 <- erdos.renyi.game(20, 2/20)
g3 <- erdos.renyi.game(20, 5/20)
E(g1)$weight <- 1
E(g2)$weight <- runif(ecount(g2))
E(g3)$weight <- runif(ecount(g3))
graph.diversity(g1)
graph.diversity(g2)
graph.diversity(g3)

Run the code above in your browser using DataCamp Workspace