Modularity is a quality function on partitions of a network which aims to identify highly clustered components. Given a graph G, the modularity of a partition of the vertex set measures the extent to which edge density is higher within parts than between parts; and the modularity q(G) of G is the maximum modularity of a partition of V(G). Knowledge of the maximum modularity of the corresponding random graph is important to determine the statistical significance of a partition in a real network. We provide bounds for the modularity of random regular graphs. Modularity is related to the Hamiltonian of the Potts model from statistical physics. This leads to interest in the modularity of lattices, which we will discuss. This is joint work with Colin McDiarmid.