  Community definitions usually focus on edges, inside and between the
communities. However, the high density of edges within a community determines
correlations between nodes going beyond nearest-neighbours, and which are
indicated by the presence of motifs. We show how motifs can be used to define
general classes of nodes, including communities, by extending the mathematical
expression of Newman-Girvan modularity. We construct then a general framework
and apply it to some synthetic and real networks.
