File: diversity.Rd

package info (click to toggle)
r-cran-igraph 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,044 kB
  • sloc: ansic: 204,981; cpp: 21,711; fortran: 4,090; yacc: 1,229; lex: 519; sh: 52; makefile: 8
file content (75 lines) | stat: -rw-r--r-- 2,324 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/centrality.R
\name{diversity}
\alias{diversity}
\title{Graph diversity}
\usage{
diversity(graph, weights = NULL, vids = V(graph))
}
\arguments{
\item{graph}{The input graph. Edge directions are ignored.}

\item{weights}{\code{NULL}, or the vector of edge weights to use for the
computation. If \code{NULL}, then the \sQuote{weight} attibute is used. Note
that this measure is not defined for unweighted graphs.}

\item{vids}{The vertex ids for which to calculate the measure.}
}
\value{
A numeric vector, its length is the number of vertices.
}
\description{
Calculates a measure of diversity for all vertices.
}
\details{
The diversity of a vertex is defined as the (scaled) Shannon entropy of the
weights of its incident edges:
\deqn{D(i)=\frac{H(i)}{\log k_i}}{D(i)=H(i)/log(k[i])}
and
\deqn{H(i)=-\sum_{j=1}^{k_i} p_{ij}\log p_{ij},}{H(i) =
  -sum(p[i,j] log(p[i,j]), j=1..k[i]),} where
\deqn{p_{ij}=\frac{w_{ij}}{\sum_{l=1}^{k_i}}V_{il},}{p[i,j] = w[i,j] /
sum(w[i,l], l=1..k[i]),} and \eqn{k_i}{k[i]} is the (total) degree of vertex
\eqn{i}, \eqn{w_{ij}}{w[i,j]} is the weight of the edge(s) between vertices
\eqn{i} and \eqn{j}.

For vertices with degree less than two the function returns \code{NaN}.
}
\examples{

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)
}
\references{
Nathan Eagle, Michael Macy and Rob Claxton: Network Diversity
and Economic Development, \emph{Science} \strong{328}, 1029--1031, 2010.
}
\seealso{
Centrality measures
\code{\link{alpha_centrality}()},
\code{\link{authority_score}()},
\code{\link{betweenness}()},
\code{\link{closeness}()},
\code{\link{eigen_centrality}()},
\code{\link{harmonic_centrality}()},
\code{\link{hits_scores}()},
\code{\link{page_rank}()},
\code{\link{power_centrality}()},
\code{\link{spectrum}()},
\code{\link{strength}()},
\code{\link{subgraph_centrality}()}
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\concept{centrality}
\keyword{graphs}
\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_diversity}{\code{igraph_diversity()}}.}