Use this if you are using igraph from R
Graph motifs are small connected subgraphs with a well-defined structure. These functions search a graph for various motifs.
count_motifs(graph, size = 3, cut.prob = rep(0, size))
| graph | Graph object, the input graph. | 
| size | The size of the motif. | 
| cut.prob | Numeric vector giving the probabilities that the search
graph is cut at a certain level. Its length should be the same as the size
of the motif (the  | 
count_motifs calculates the total number of motifs of a given
size in graph.
count_motifs returns  a numeric scalar.
Other graph motifs: 
motifs(),
sample_motifs()
g <- barabasi.game(100) motifs(g, 3) count_motifs(g, 3) sample_motifs(g, 3)