Use this if you are using igraph from R
Transitivity measures the probability that the adjacent vertices of a vertex are connected. This is sometimes also called the clustering coefficient.
transitivity(graph, type = c("undirected", "global", "globalundirected", "localundirected", "local", "average", "localaverage", "localaverageundirected", "barrat", "weighted"), vids = NULL, weights = NULL, isolates = c("NaN", "zero"))
The graph to analyze.
The type of the transitivity to calculate. Possible values:
The vertex ids for the local transitivity will be calculated.
This will be ignored for global transitivity types. The default value is
Optional weights for weighted transitivity. It is ignored for
other transitivity measures. If it is
Character scalar, defines how to treat vertices with degree
zero and one. If it is ‘
Note that there are essentially two classes of transitivity measures, one is a vertex-level, the other a graph level property.
There are several generalizations of transitivity to weighted graphs, here we use the definition by A. Barrat, this is a local vertex-level quantity, its formula is
weighted C_i = 1/s_i 1/(k_i-1) sum( (w_ij+w_ih)/2 a_ij a_ih a_jh, j, h)
s_i is the strength of vertex i, see
strength, a_ij are elements of the
adjacency matrix, k_i is the vertex degree, w_ij
are the weights.
This formula gives back the normal not-weighted local transitivity if all the edge weights are the same.
barrat type of transitivity does not work for graphs with
multiple and/or loop edges. If you want to calculate it for a directed
as.undirected with the
collapse mode first.
global’ a single number, or
NaN if there
are no connected triples in the graph.
local’ a vector of transitivity scores, one for each
vertex in ‘
Gabor Csardi email@example.com
Wasserman, S., and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.
Alain Barrat, Marc Barthelemy, Romualdo Pastor-Satorras, Alessandro Vespignani: The architecture of complex weighted networks, Proc. Natl. Acad. Sci. USA 101, 3747 (2004)
g <- make_ring(10) transitivity(g) g2 <- sample_gnp(1000, 10/1000) transitivity(g2) # this is about 10/1000 # Weighted version, the figure from the Barrat paper gw <- graph_from_literal(A-B:C:D:E, B-C:D, C-D) E(gw)$weight <- 1 E(gw)[ V(gw)[name == "A"] %--% V(gw)[name == "E" ] ]$weight <- 5 transitivity(gw, vids="A", type="local") transitivity(gw, vids="A", type="weighted") # Weighted reduces to "local" if weights are the same gw2 <- sample_gnp(1000, 10/1000) E(gw2)$weight <- 1 t1 <- transitivity(gw2, type="local") t2 <- transitivity(gw2, type="weighted") all(is.na(t1) == is.na(t2)) all(na.omit(t1 == t2))