clustering_w

The clustering coefficient proposed by Tore Opsahl and Pietro Panzarasa (2009) (“Clustering in weighted networks” in Social Networks 31 (2), 155-163, doi: 10.1016/j.socnet.2009.02.002) is implimented in the function clustering_w().

This function can calculate the coefficient when the triplet value is the arithmetic mean, geometric mean, the minimum (default), and the maximum. Specify clustering_w(edgelist, measure=c("am","gm","mi","ma")) if you want all of them (hardly extra time needed).

Example 1: The clustering coefficient using random data created by rg_w()

## Load tnet
library(tnet) 
## Generate a directed random graph with 100 nodes, 300 edges (density: 0.030303).
rg <- rg_w(nodes=100, arcs=300, directed=TRUE)
## Run clustering programme
clustering_w(rg)

The average outcome of random samples should be the density of the random network: 0.03030303

Example 2: Sample data

## Load tnet
library(tnet) 
Image## Sample data
sample <- rbind(
c(1,2,4),
c(1,3,2),
c(2,1,4),
c(2,3,4),
c(2,4,1),
c(2,5,2),
c(3,1,2),
c(3,2,4),
c(4,2,1),
c(5,2,2),
c(5,6,1),
c(6,5,1))
## Run clustering programme
clustering_w(sample)

The outcome should be 0.50000

 

Last Updated ( Friday, 19 June 2009 )