ClustF | R Documentation |
This function computes both Local and Global (average) Clustering Coefficients for either Directed/Undirected and Unweighted/Weighted Networks. The formulas are based on Onnela et al. (2005) for undirected networks, and on Fagiolo (2007) for directed networks.
ClustF(mat, type = "undirected", isolates = "zero", norm = 1)
mat |
A weighted adjacency matrix. If weights are greater than one, a normalization is provided by dividing each weight by the maximum weight observed. |
type |
The type of clustering coefficient to calculate.
Possible values are: |
isolates |
Character scalar, defines how to treat vertices with degree zero and one.
If |
norm |
If it is 1 (default), the link's weights are normalized by dividing by the maximum observed weight (as proposed by Fagiolo). If it is 0, weights are not normalized. Weights are always normalized when the maximum weight is greater than zero, ensuring that the clustering coefficient ranges between 0 and 1. |
In the directed case, different components of the directed clustering coefficient are also considered.
The function computes Onnela et al.'s (2005) formula for weighted and undirected networks. For directed networks, Fagiolo's (2007) formula is used. In the case of unweighted and undirected graphs, the classical local clustering coefficient (Watts and Strogatz) is provided. Local coefficients are computed for each node, and the global coefficient is the average of these local coefficients. These coefficients do not work for graphs with multiple or loop edges, so loops are removed.
A list with the following components:
LocalCC |
Local clustering coefficients for undirected networks |
GlobalCC |
Global clustering coefficient for undirected networks |
cycleCC |
Local Cycle clustering coefficients for directed networks |
middlemanCC |
Local Middleman clustering coefficients for directed networks |
inCC |
Local In clustering coefficients for directed networks |
outCC |
Local Out clustering coefficients for directed networks |
totalCC |
Local Total clustering coefficients for directed networks |
GlobalcycleCC |
Global Cycle clustering coefficient for directed networks |
GlobalmiddlemanCC |
Global Middleman clustering coefficient for directed networks |
GlobalinCC |
Global In clustering coefficient for directed networks |
GlobaloutCC |
Global Out clustering coefficient for directed networks |
GlobaltotalCC |
Global Total clustering coefficient for directed networks |
Gian Paolo Clemente, gianpaolo.clemente@unicatt.it
Fagiolo, G. (2007). Clustering in complex directed networks. Physical Review E, 76(2).
Onnela, J.P., Saramaki, J., Kertsz, J., & Kaski, K. (2005). Intensity and coherence of motifs in weighted complex networks. Physical Review E, 71(6).
Watts, D.J., & Strogatz, S.H. (1998). Collective dynamics of 'small-world' networks. Nature, 393, 440-442.
if (requireNamespace("igraph", quietly = TRUE)) {
library(igraph)
# Generate a weighted and undirected graph
gsim <- sample_gnp(50, 0.5, directed = FALSE, loops = FALSE)
PESI <- runif(length(E(gsim)), 0, 1)
E(gsim)$weight <- PESI
A <- as_adjacency_matrix(gsim, sparse = FALSE, attr = "weight")
OnnelaClust <- ClustF(A, "undirected")
# Generate a weighted and directed graph
gsim <- sample_gnp(50, 0.5, directed = TRUE, loops = FALSE)
PESI <- runif(length(E(gsim)), 0, 1)
E(gsim)$weight <- PESI
A <- as_adjacency_matrix(gsim, sparse = FALSE, attr = "weight")
FagioloClust <- ClustF(A, "directed")
} else {
cat("Please install the 'igraph' package to run this example.\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.