Learn R Programming

wdnet (version 1.2.3)

clustcoef: Directed clustering coefficient

Description

Compute the clustering coefficient of a weighted and directed network.

Usage

clustcoef(
  netwk,
  edgelist,
  edgeweight,
  adj,
  directed = TRUE,
  method = c("Clemente", "Fagiolo"),
  isolates = 0
)

Value

Lists of local clustering coefficients (in terms of a vector), global clustering coefficient (in terms of a scalar) and number of weighted directed triangles (in terms of a vector) based on total, in,

out, middleman (middle), or cycle triplets.

Arguments

netwk

A wdnet object that represents the network. If NULL, the function will compute the coefficient using either edgelist, edgeweight, or adj.

edgelist

A two-column matrix, each row represents a directed edge of the network.

edgeweight

A vector representing the weight of edges.

adj

An adjacency matrix of a weighted and directed network.

directed

Logical. Indicates whether the edges in edgelist or adj are directed.

method

Which method used to compute clustering coefficients: Clemente and Grassi (2018) or Fagiolo (2007).

isolates

Binary, defines how to treat vertices with degree zero and one. If 0, then their clustering coefficient is returned as 0 and are included in the averaging. Otherwise, their clustering coefficient is NaN and are excluded in the averaging. Default value is 0.

References

  • Barrat, A., Barthelemy, M., Pastor-Satorras, R. and Vespignani, A. (2004). The architecture of complex weighted networks. Proceedings of National Academy of Sciences of the United States of America, 101(11), 3747--3752.

  • Clemente, G.P. and Grassi, R. (2018). Directed clustering in weighted networks: A new perspective. Chaos, Solitons & Fractals, 107, 26--38.

  • Fagiolo, G. (2007). Clustering in complex directed networks. Physical Review E, 76, 026107.

Examples

Run this code
## Generate a network according to the Erd\"{o}s-Renyi model of order 20
## and parameter p = 0.3
edge_ER <- rbinom(400, 1, 0.3)
weight_ER <- sapply(edge_ER, function(x) x * sample(3, 1))
adj_ER <- matrix(weight_ER, 20, 20)
mycc <- clustcoef(adj = adj_ER, method = "Clemente")
system.time(mycc)

Run the code above in your browser using DataLab