ClustBCG | R Documentation |
Compute Local and Global (average) Clustering Coefficients for Directed/Undirected and Unweighted/Weighted Networks.
ClustBCG(mat, type = "undirected", isolates = "zero")
mat |
A weighted adjacency matrix. |
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 |
Formulas are based on Barrat et al. (2004) for undirected networks, and on Clemente and Grassi (2018) for directed networks.
In the directed case, different components of the directed clustering coefficient are also provided.
The function computes the Barrat et al. (2004) coefficient for a weighted and undirected network. For a directed network, the Clemente and Grassi (2018) formula is used. In case of unweighted and undirected graphs, the classical local clustering coefficient (Watts and Strogatz) is provided. Local clustering 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, hence 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
Barrat, A., Barthelemy, M., Pastor-Satorras, R., & Vespignani, A. (2004). The architecture of complex weighted networks. Proceedings of the National Academy of Sciences, USA, 101, 3747.
Clemente, G.P., & Grassi, R. (2018). Directed clustering in weighted networks: a new perspective. Chaos, Solitons and Fractals, 107, 26–38.
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")
BarratClust <- ClustBCG(A, "undirected")
check <- sum(BarratClust$LocalCC - transitivity(gsim, "weighted"))
# 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")
CGClust <- ClustBCG(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.