This measure is sometimes called clustering coefficient.
References
Wasserman, S. and Faust, K. (1994). Social network analysis: Methods and applications. Cambridge University Press.
Examples
A <- matrix(c(
0, 1, 0, 1, 0,
1, 0, 1, 1, 0,
0, 1, 0, 0, 0,
1, 1, 0, 0, 1,
0, 0, 0, 1, 0
), byrow = TRUE, ncol = 5)
rownames(A) <- letters[1:ncol(A)]
colnames(A) <- rownames(A)
trans_coef(A, method = "local")
#> $a
#> [1] 1
#>
#> $b
#> [1] 0.3333333
#>
#> $c
#> [1] NaN
#>
#> $d
#> [1] 0.3333333
#>
#> $e
#> [1] NaN
#>