\HeaderA{triad.census}{Triad census, subgraphs with three vertices}{triad.census}
\keyword{graphs}{triad.census}
\begin{Description}\relax
This function counts the different subgraphs of three
vertices in a graph.
\end{Description}
\begin{Usage}
\begin{verbatim}
triad.census(graph)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graph}] The input graph, it should be directed. An undirected
graph results a warning, and undefined results.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Triad census was defined by David and Leinhardt (see References
below). Every triple of vertices (A, B, C) are classified into the 16
possible states:
\Itemize{
\item[003] A,B,C, the empty graph.
\item[012] A-\textgreater{}B, C, the graph with a single directed edge.
\item[102] A\textless{}-\textgreater{}B, C, the graph with a mutual connection between two
vertices.
\item[021D] A\textless{}-B-\textgreater{}C, the out-star.
\item[021U] A-\textgreater{}B\textless{}-C, the in-star.
\item[021C] A-\textgreater{}B-\textgreater{}C, directed line.
\item[111D] A\textless{}-\textgreater{}B\textless{}-C.
\item[111U] A\textless{}-\textgreater{}B-\textgreater{}C.
\item[030T] A-\textgreater{}B\textless{}-C, A-\textgreater{}C.
\item[030C] A\textless{}-B\textless{}-C, A-\textgreater{}C.
\item[201] A\textless{}-\textgreater{}B\textless{}-\textgreater{}C.
\item[120D] A\textless{}-B-\textgreater{}C, A\textless{}-\textgreater{}C.
\item[120U] A-\textgreater{}B\textless{}-C, A\textless{}-\textgreater{}C.
\item[120C] A-\textgreater{}B-\textgreater{}C, A\textless{}-\textgreater{}C.
\item[210] A-\textgreater{}B\textless{}-\textgreater{}C, A\textless{}-\textgreater{}C.
\item[300] A\textless{}-\textgreater{}B\textless{}-\textgreater{}C, A\textless{}-\textgreater{}C, the complete graph.
}

This functions uses the RANDESU motif finder algorithm to find and
count the subgraphs, see \code{\LinkA{graph.motifs}{graph.motifs}}.
\end{Details}
\begin{Value}
A numeric vector, the subgraph counts, in the order given in the
above description.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{References}\relax
See also Davis, J.A. and Leinhardt, S.  (1972).  The Structure of
Positive Interpersonal Relations in Small Groups.  In J. Berger
(Ed.), Sociological Theories in Progress, Volume 2, 218-251. 
Boston: Houghton Mifflin.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{dyad.census}{dyad.census}} for classifying binary relationships,
\code{\LinkA{graph.motifs}{graph.motifs}} for the underlying implementation.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- erdos.renyi.game(15, 45, type="gnm", dir=TRUE)
triad.census(g)
\end{ExampleCode}
\end{Examples}

