clusteringCoef: Calculate clustering coefficient for an undirected graph

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/interfaces.R

Description

Calculate clustering coefficient for an undirected graph

Usage

1
clusteringCoef(g, Weighted=FALSE, vW=degree(g))

Arguments

g

an instance of the graph class

Weighted

calculate weighted clustering coefficient or not

vW

vertex weights to use when calculating weighted clustering coefficient

Details

For an undirected graph G, let delta(v) be the number of triangles with v as a node, let tau(v) be the number of triples, i.e., paths of length 2 with v as the center node.

Let V' be the set of nodes with degree at least 2.

Define clustering coefficient for v, c(v) = (delta(v) / tau(v)).

Define clustering coefficient for G, C(G) = sum(c(v)) / |V'|, for all v in V'.

Define weighted clustering coefficient for g, Cw(G) = sum(w(v) * c(v)) / sum(w(v)), for all v in V'.

Value

Clustering coefficient for graph G.

Author(s)

Li Long li.long@isb-sib.ch

References

Approximating Clustering Coefficient and Transitivity, T. Schank, D. Wagner, Journal of Graph Algorithms and Applications, Vol. 9, No. 2 (2005).

See Also

clusteringCoefAppr, transitivity, graphGenerator

Examples

1
2
3
4
5
6
7
con <- file(system.file("XML/conn.gxl",package="RBGL"))
g <- fromGXL(con)
close(con)
cc <- clusteringCoef(g)
ccw1 <- clusteringCoef(g, Weighted=TRUE)
vW  <- c(1, 1, 1, 1, 1,1, 1, 1)
ccw2 <- clusteringCoef(g, Weighted=TRUE, vW)

Example output

Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

RBGL documentation built on Nov. 8, 2020, 5 p.m.