Use this if you are using igraph from R
This function counts the different subgraphs of three vertices in a graph.
The input graph, it should be directed. An undirected graph results a warning, and undefined results.
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:
A,B,C, the empty graph.
A->B, C, the graph with a single directed edge.
A<->B, C, the graph with a mutual connection between two vertices.
A<-B->C, the out-star.
A->B<-C, the in-star.
A->B->C, directed line.
A<->B<->C, A<->C, the complete graph.
This functions uses the RANDESU motif finder algorithm to find and count the
A numeric vector, the subgraph counts, in the order given in the above description.
Gabor Csardi firstname.lastname@example.org
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.
g <- sample_gnm(15, 45, directed = TRUE) triad_census(g)