To generate networks with community structure, we initialize a network by creating 50 small-world communities (as found in various social networks, see e.g. ref. [53] ) of 40 nodes using the Watts-Strogatz algorithm [54] such that each node has exactly 8 edges connecting to nodes of the same community. We then add 2000 edges randomly between randomly chosen nodes, making sure that the edges fall between communities only. Thus, we create a graph with 2000 nodes and 10000 (i.e. (2000+50 * 40 * (8/2))) undirected edges where one out of five edges falls between communities. The average degree of the network is 10, which is in line with recent reports on social contact patterns [55] . Starting from this initial network where Q<0.76, we create networks with increasing community structure by rewiring between-community edges so that they become within-community edges. More precisely, at each rewiring step, we (i) randomly choose a betweencommunity edge, (ii) randomly choose one of the two communities that the edge connects, (iii) pick a random node of the chosen community, and (iv) rewire the edge by detaching it from the node of the community that was not chosen in step (ii), and attaching it to the new node in the community that was chosen in step (iii). At all times, edges must always fall between two distinct nodes, and there can only be one edge between any two pair of nodes. We've also tested if all networks thus created consist of only a single connected component (they do).