\HeaderA{clusteringCoef}{Calculate clustering coefficient for an undirected graph}{clusteringCoef}
\keyword{models}{clusteringCoef}
\begin{Description}\relax
Calculate clustering coefficient for an undirected graph
\end{Description}
\begin{Usage}
\begin{verbatim}
clusteringCoef(g, Weighted=FALSE, vW=degree(g))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{g}] an instance of the \code{graph} class 
\item[\code{Weighted}] calculate weighted clustering coefficient or not
\item[\code{vW}] vertex weights to use when calculating weighted clustering coefficient
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
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 \code{v}, c(v) = (delta(v) / tau(v)). 

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

Define weighted clustering coefficient for \code{G}, 
Cw(G) = sum(w(v) * c(v)) / sum(w(v)), for all \code{v} in V'.
\end{Details}
\begin{Value}
Clustering coefficient for graph \code{g}.
\end{Value}
\begin{Author}\relax
Li Long <li.long@isb-sib.ch>
\end{Author}
\begin{References}\relax
Approximating Clustering Coefficient and Transitivity, T. Schank, D. Wagner, 
Journal of Graph Algorithms and Applications, Vol. 9, No. 2 (2005).
\end{References}
\begin{SeeAlso}\relax
clusteringCoefAppr, transitivity, graphGenerator
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- fromGXL(file(system.file("XML/conn.gxl",package="RBGL")))
cc <- clusteringCoef(g)
ccw1 <- clusteringCoef(g, Weighted=TRUE)
vW  <- c(1, 1, 1, 1, 1,1, 1, 1)
ccw2 <- clusteringCoef(g, Weighted=TRUE, vW)
\end{ExampleCode}
\end{Examples}

