  Clustering is the propensity of nodes that share a common neighbour to be
connected. It is ubiquitous in many networks but poses many modelling
challenges. Clustering typically manifests itself by a higher than expected
frequency of triangles, and this has led to the principle of constructing
networks from such building blocks. This approach has been generalised to
networks being constructed from a set of more exotic subgraphs. As long as
these are fully connected, it is then possible to derive mean-field models that
approximate epidemic dynamics well. However, there are virtually no results for
non-fully connected subgraphs. In this paper, we provide a general and
automated approach to deriving a set of ordinary differential equations, or
mean-field model, that describes, to a high degree of accuracy, the expected
values of system-level quantities, such as the prevalence of infection. Our
approach offers a previously unattainable degree of control over the
arrangement of subgraphs and network characteristics such as classical node
degree, variance and clustering. The combination of these features makes it
possible to generate families of networks with different subgraph compositions
while keeping classical network metrics constant. Using our approach, we show
that higher-order structure realised either through the introduction of loops
of different sizes or by generating clustered networks based on different
subgraphs, leads to significant differences in epidemic dynamics despite
controlling for basic network metrics.
