Description Usage Arguments Details Value Author(s) References Examples

Compute Local and Global (average) Clustering Coefficients for Directed/Undirected and Unweighted/Weighted Networks.

Formulas are based on Barrat et al. (2004) coefficient when the network is undirected, while it is based on Clemente and Grassi (2018) proposal when the network is directed.

In the directed case, different components of directed clustering coefficient are also provided.

1 |

`mat` |
A Weighted Adjacency Matrix |

`type` |
The type of the clustering coefficient to calculate. Possible values are: "undirected" (default) or "undirected". |

`isolates` |
Character scalar, defines how to treat vertices with degree zero and one. If it is 'NaN' then their local transitivity is reported as NaN and they are not included in the averaging. If it is 'zero', then we report 0 transitivity for them, and they are included in the averaging. Default value is 'zero'. |

The function `ClustBCG`

computes Barrat et al. coefficient when a weighted and undirected network is considered.

For directed network Clemente and Grassi formula is computed.

In case of unweighted and undirected graphs, it provides classical local clustering coefficient (Watts and Strogatz).

In all cases, local clustering coefficients are obtained for each node, the global coefficient is the average of local coefficients.

These clustering coefficients do not work for graphs with multiple and/or loop edges. Hence, loops are removed.

In the directed case, different components of directed clustering coefficient are also considered.

For 'undirected case':

`LocalCC` |
Local clustering coefficients |

`GlobalCC` |
Global clustering coefficient |

For 'directed case':

`cycleCC` |
Local Cycle clustering coefficients |

`middlemanCC` |
Local Middleman clustering coefficients |

`inCC` |
Local In clustering coefficients |

`outCC` |
Local Out clustering coefficients |

`totalCC` |
Local Total clustering coefficients |

`GlobalcycleCC` |
Global Cycle clustering coefficient |

`GlobalmiddlemanCC` |
Global Middleman clustering coefficient |

`GlobalinCC` |
Global In clustering coefficient |

`GlobaloutCC` |
Global Out clustering coefficient |

`GlobaltotalCC` |
Global Total clustering coefficient |

Gian Paolo Clemente, gianpaolo.clemente@unicatt.it

Barrat, A. and Barthelemy, M. and Pastor-Satorras, R. and Vespignani, A. (2004) The architecture of complex weighted networks, *Proc. Natl. Acad. Sci.*, USA **101**, 3747.

Clemente, G.P. and Grassi, R. (2018) Directed clustering in weighted networks: a new perspective, *Chaos, Solitons and Fractals*, **107**,26–38.

Watts, D.J. and Strogatz, S.H. (1998) Collective dynamics of 'small-world 'networks. *Nature*, **393**, 440-442.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ```
library(igraph)
#Generate a Weighted and Undirected graph with Erdos Renyi Model
gsim<-erdos.renyi.game(50, 0.5, type="gnp", directed = FALSE, loops = FALSE)
PESI<-runif(length(E(gsim)), 0, 1)
E(gsim)$weight<-PESI
#Get Adjacency
A<-get.adjacency(gsim, sparse=FALSE, attr="weight")
#Compute Barrat et al. (2004) coefficient
BarratClust<-ClustBCG(A, "undirected")
#The same results can be obtained with igraph::transitivity
check<-sum(BarratClust$LocalCC-transitivity(gsim, "weighted"))
#Generate a Weighted and Directed Graph with Erdos Renyi Model
gsim<-erdos.renyi.game(50, 0.5, type="gnp", directed = TRUE, loops = FALSE)
PESI<-runif(length(E(gsim)), 0, 1)
E(gsim)$weight<-PESI
#Get Adjacency
A<-get.adjacency(gsim, sparse=FALSE, attr="weight")
#Compute Clemente, Grassi (2018) coefficient
CGClust<-ClustBCG(A, "directed")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.