Introduction Mitigating or preventing the spread of infectious diseases is the ultimate goal of infectious disease epidemiology, and understanding the dynamics of epidemics is an important tool to achieve this goal. A rich body of research [1],[2],[3] has provided major insights into the processes that drive epidemics, and has been instrumental in developing strategies for control and eradication. The structure of contact networks is crucial in explaining epidemiological patterns seen in the spread of directly transmissible diseases such as HIV/AIDS [1],[4],[5], SARS [6],[7], influenza [8],[9],[10],[11] etc. For example, the basic reproductive number R0, a quantity central to developing intervention measures or immunization programs, depends crucially on the variance of the distribution of contacts [1],[12],[13], known as the network degree distribution. Contact networks with fat-tailed degree distributions, for example, where a few individuals have an extraordinarily large number of contacts, result in a higher R0 than one would expect from contact networks with a uniform degree distribution, and the existence of highly connected individuals makes them an ideal target for control measures [7],[14]. While degree distributions have been studied extensively to understand their effect on epidemic dynamics, the community structure of networks has generally been ignored. Despite the demonstration that social networks show significant community structure [15],[16],[17],[18], and that social processes such as homophily and transitivity result in highly clustered and modular networks [19], the effect of such microstructures on epidemic dynamics has only recently started to be investigated. Most initial work has focused on the effect of small cycles, predominantly in the context of clustering coefficients (i.e. the fraction of closed triplets in a contact network) [20],[21],[22],[23],[24]. In this article, we aim to understand how community structure affects epidemic dynamics and control of infectious disease. Community structure exists when connections between members of a group of nodes are more dense than connections between members of different groups of nodes [15]. The terminology is relatively new in network analysis and recent algorithm development has greatly expanded our ability to detect sub-structuring in networks. While there has been a recent explosion in interest and methodological development, the concept is an old one in the study of social networks where it is typically referred to as a “cohesive subgroups,” groups of vertices in a graph that share connections with each other at a higher rate than with vertices outside the group [18]. Empirical data on social structure suggests that community structuring is extensive in epidemiological contacts [25],[26],[27] relevant for infectious diseases transmitted by the respiratory or close-contact route (e.g. influenza-like illnesses), and in social groups more generally [16],[17],[28],[29],[30]. Similarly, the results of epidemic models of directly transmitted infections such as influenza are most consistent with the existence of such structure [8],[9],[11],[31],[32],[33]. Using both simulated and empirical social networks, we show how community structure affects the spread of diseases in networks, and specifically that these effects cannot be accounted for by the degree distribution alone. The main goal of this study is to demonstrate how community structure affects epidemic dynamics, and what strategies are best applied to control epidemics in networks with community structure. Results We generate networks computationally with community structure by creating small subnetworks of locally dense communities, which are then randomly connected to one another. A particular feature of such networks is that the variance of their degree distribution is relatively low, and thus the spread of a disease is only marginally affected by it [34]. Running standard susceptible-infected-resistant (SIR) epidemic simulations (see Methods) on these networks, we find that the average epidemic size, epidemic duration and the peak prevalence of the epidemic are strongly affected by a change in community structure connectivity that is independent of the overall degree distribution of the full network (Figure 1). Note that the value range of Q shown in Figure 1 is in agreement with the value range of Q found in the empirical networks used further below, and that lower values of Q do not affect the results qualitatively (see Suppl. Mat. Figure S1). 10.1371/journal.pcbi.1000736.g001 Figure 1 Effect of community structure, measured as modularity (Q) on epidemic dynamics. Panels show effect of community structure on (a) final size, (b) duration and (c) peak prevalence (i.e. maximum frequency of population infected). Each of the points represents the average of maximally 2000 simulation runs (only simulations with a final size of at least 2% of the population were included in calculating the averages). Error bars are omitted because the ranges are less than the size of the plotting points. The different colors represent different transmission rates: gray, β = 0.05 (R0≈2.5); blue, β = 0.06 (R0≈3); red, β = 0.08 (R0≈4). Panel (d) shows that the effect of a change in community structure on the squared coefficient of variation of the degree distribution (CV)2 is negligible. Epidemics in populations with community structure show a distinct dynamical pattern depending on the extent of community structure. In networks with strong community structure, an infected individual is more likely to infect members of the same community than members outside of the community. Thus, in a network with strong community structure, local outbreaks may die out before spreading to other communities, or they may spread through various communities in an almost serial fashion, and large epidemics in populations with strong community structure may therefore last for a long time. Correspondingly, the incidence rate can be very low, and the number of generations of infection transmission can be very high, compared to the explosive epidemics in populations with less community structure (Figures 2a and 2b). On average, epidemics in networks with strong community structure exhibit greater variance in final size (Figures 2c and 2d), a greater number of small, local outbreaks that do not develop into a full epidemic, and a higher variance in the duration of an epidemic. 10.1371/journal.pcbi.1000736.g002 Figure 2 Typical incidence curves and distributions of final size in networks with medium and strong community structure. (a) and (b): Typical incidence curves of disease outbreaks in a network with medium community structure ((a): Q≈0.76) and a network with strong ((b): Q≈0.9) community structure (disease parameters equal to those in Figure 1 for the case where R0≈3). Each stacked bar represents the cumulative number of new cases during a given day. The color of a single infection case denotes the infection generation (initial case = 0), i.e. the number of hosts through which the infection has been passed on before infecting the current case. (c) and (d): Distribution of final size of simulations of disease outbreaks in a network with medium ((c), same contact network as in (a)) and strong ((d), same contact network as in (b)) community structure. Note that only simulations with a final size of at least 2% of the population were included in the distributions. In order to halt or mitigate an epidemic, targeted immunization interventions or social distancing interventions aim to change the structure of the network of susceptible individuals in such a way as to make it harder for a pathogen to spread [35]. In practice, the number of people to be removed from the susceptible class is often constrained for a number of reasons (e.g., due to limited vaccine supply or ethical concerns of social distancing measures). From a network perspective, targeted immunization methods translate into indentifying which nodes should be removed from a network, a problem that has caught considerable attention (see for example [36] and references therein). Targeting highly connected individuals for immunization has been shown to be an effective strategy for epidemic control [7],[14]. However, in networks with strong community structure, this strategy may not be the most effective: some individuals connect to multiple communities (so-called community bridges [37]) and may thus be more important in spreading the disease than individuals with fewer inter-community connections, but this importance is not necessarily reflected in the degree. Identification of community bridges can be achieved using the betweenness centrality measure [38], defined as the fraction of shortest paths a node falls on. While degree and betweenness centrality are often strongly positively correlated, the correlation between degree and betweenness centrality becomes weaker as community structure becomes stronger (Figure 3). Thus, in networks with community structure, focusing on the degree alone carries the risk of missing some of the community bridges that are not highly connected. Indeed, at a low vaccination coverage, an immunization strategy based on betweenness centrality results in fewer infected cases than an immunization strategy based on degree as the magnitude of community structure increases (Figure 4a). This observation is critical because the potential vaccination coverage for an emerging infection will typically be very low. A third measure, random walk centrality, identifies target nodes by a random walk, counting how often a node is traversed by a random walk between two other nodes [39]. The random walk centrality measure considers not only the shortest paths between pairs of nodes, but all paths between pairs of nodes, while still giving shorter paths more weight. While infections are most likely to spread along the shortest paths between any two nodes, the cumulative contribution of other paths can still be important [40]: immunization strategies based on random walk centrality result in the lowest number of infected cases at low vaccination coverage (Figure 4b and 4c). 10.1371/journal.pcbi.1000736.g003 Figure 3 The breakdown of the correlation between degree and betweenness centrality (CB ) with increasing community structure. (a) The correlation coefficient r2 decreases rapidly as modularity increases. (b–d): Correlation between degree and betweenness in network with (b) medium, (c) strong and (d) very strong community structure. 10.1371/journal.pcbi.1000736.g004 Figure 4 Assessing the efficacy of targeted immunization strategies based on deterministic and stochastic algorithms in the computationally generated networks. Color code denotes the difference in the average final size Sm of disease outbreaks in networks that were immunized before the outbreak using method m. The top panel (a) shows the difference between the degree method and the betweenness centrality method, i.e. Sdegree − Sbetweenness . A positive difference (colored red to light gray) indicates that the betweenness centrality method resulted in smaller final sizes than the degree method. A negative difference (colored blue to black) indicates that the betweenness centrality method resulted in bigger final sizes than the degree method. If the difference is not bigger than 0.1% of the total population size, then no color is shown (white). Panel (a) shows that the betweenness centrality method is more effective than the degree based method in networks with strong community structure (Q is high). (b) and (c): like (a), but showing Sdegree − Srandomwalk (in (b)) and Sbetweenness − Srandomwalk (in (c)). Panels (b) and (c) show that the random walk method is the most effective method overall. Panel (d) shows that the community bridge finder (CBF) method generally outperforms the acquaintance method (with n = 1) except when community structure is very strong (see main text). Final epidemic sizes were obtained by running 2000 SIR simulations per network, vaccination coverage and immunization method. To test the efficiency of targeted immunization strategies on real networks, we used interaction data of individuals at five different universities in the US taken from a social network website [41], and obtained the contact network relevant for directly transmissible diseases (see Methods). We find again that the overall most successful targeted immunization strategy is the one that identifies the targets based on random walk centrality. Limited immunization based on random walk centrality significantly outperforms immunization based on degree especially when vaccination coverage is low (Figure 5a). 10.1371/journal.pcbi.1000736.g005 Figure 5 Assessing the efficacy of targeted immunization strategies in empirical networks based on deterministic and stochastic algorithms. The bars show the difference in the average final size Sm of disease outbreaks (▵ cases) in networks that were immunized before the outbreak using method m. The left panels show the difference between the degree method and the random walk centrality method, i.e. Sdegree − Srandomwalk . If the difference is positive (red bars), then the random walk centrality method resulted in smaller final sizes than the degree method. A negative value (black bars) means that the opposite is true. Shaded bars show non-significant differences (assessed at the 5% level using the Mann-Whitney test). The middle and right panels are generated using the same methodology, but measuring the difference between the acquaintance method (with n = 1 in the middle column and n = 2 in the right column, see Methods) and the community bridge finder (CBF) method, i.e. Sacquaintance1 − SCBF and Sacquaintance2 − SCBF . Again, positive red bars mean that the CBF method results in smaller final sizes, i.e. prevents more cases, than the acquaintance methods, whereas negative black bars mean the opposite. Final epidemic sizes were obtained by running 2000 SIR simulations per network, vaccination coverage and immunization method. In practice, identifying immunization targets may be impossible using such algorithms, because the structure of the contact network relevant for the spread of a directly transmissible disease is generally not known. Thus, algorithms that are agnostic about the full network structure are necessary to identify target individuals. The only algorithm we are aware of that is completely agnostic about the network structure network structure identifies target nodes by picking a random contact of a randomly chosen individual [42]. Once such an acquaintance has been picked n times, it is immunized. The acquaintance method has been shown to be able to identify some of the highly connected individuals, and thus approximates an immunization strategy that targets highly connected individuals. We propose an alternative algorithm (the so-called community bridge finder (CBF) algorithm, described in detail in the Methods) that aims to identify community bridges connecting two groups of clustered nodes. Briefly, starting from a random node, the algorithm follows a random path on the contact network, until it arrives at a node that does not connect back to more than one of the previously visited nodes on the random walk. The basic goal of the CBF algorithm is to find nodes that connect to multiple communities - it does so based on the notion that the first node that does not connect back to previously visited nodes of the current random walk is likely to be part of a different community. On all empirical and computationally generated networks tested, this algorithm performed mostly better, often equally well, and rarely worse than the alternative algorithm. It is important to note a crucial difference between algorithms such as CBF (henceforth called stochastic algorithms) and algorithms such as those that calculate, for example, the betweenness centrality of nodes (henceforth called deterministic algorithms). A deterministic algorithm always needs the complete information about each node (i.e. either the number or the identity of all connected nodes for each node in the network). A comparison between algorithms is therefore of limited use if they are not of the same type as they have to work with different inputs. Clearly, a deterministic algorithm with information on the full network structure as input should outperform a stochastic algorithm that is agnostic about the full network structure. Thus, we will restrict our comparison of CBF to the acquaintance method since this is the only stochastic algorithm we are aware of the takes as input the same limited amount of local information. In the computationally generated networks, CBF outperformed the acquaintance method in large areas of the parameter space (Figure 4d). It may seem unintuitive at first that the acquaintance method outperforms CBF at very high values of modularity, but one should keep in mind that epidemic sizes are very small in those extremely modular networks (see Figure 1a) because local outbreaks only rarely jump the community borders. If outbreaks are mostly restricted to single communities, then CBF is not the optimal strategy because immunizing community bridges is useless; the acquaintance method may at least find some well connected nodes in each community and will thus perform slightly better in this extreme parameter space. In empirical networks, CBF did particularly well on the network with the strongest community structure (Oklahoma), especially in comparison to the similarly effective acquaintance method with n = 2. (Figure 5c). As immunization strategies should be deployed as fast as possible, the speed at which a certain fraction of the network can be immunized is an additional important aspect. We measured the speed of the algorithm as the number of nodes that the algorithm had to visit in order to achieve a certain vaccination coverage, and find that the CBF algorithm is faster than the similarly effective acquaintance method with n = 2 at vaccination coverages / −1), where and are the mean degree and mean square degree, respectively, and where T is the average probability of disease transmission from a node to a neighboring node, i.e. T≈β/γ. Note that the variation in the degree is too small to be of relevance here (see further below and Figure 1d). The reason we chose γ = 0.2 (i.e. an average length of infectious period of 5 days) and R0≈3 in most simulations (unless mentioned otherwise) is that these parameter values reflect, very roughly, some of the most widespread infectious diseases to which our study is relevant (i.e. flu-like infectious diseases that are transmitted directly from person to person by the respiratory or close-contact route [8],[9],[48],[49],[50]). After a simulation, we record the total number of cases infected (the epidemic size), the maximum frequency of infection at any point during the simulation (the peak prevalence), and the number of days that have passed between the first infected case and the simulation stop (the duration of the epidemic). Generation of network with community structure In order to understand the effect of community structure, we generated networks with 2000 nodes from scratch with varying degrees of community structure. The strength of community structure is generally measured as network modularity Q, which is defined as where eij is the fraction of all edges in the network that link nodes in community i to nodes in community j, and [15]. Thus, ai represents the fraction of edges in the network that connect to nodes in community i. If edges were to fall between nodes without any regard for communities, we would have eij = ai aj , and thus Q = 0. There are numerous methods to calculate the value of Q for a given network, and the development of more accurate and efficient methods is still a very active research field. In particular, one has to be careful when comparing values of Q because some measures are normalized while others or not [51]. We have used the spin glass method introduced by Reichhardt and Bornholdt [52] to measure Q throughout this manuscript. 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 between-community 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). The quantity (CV)2 is the square of the coefficient of variation in degree (i.e. the squre of the ratio of the standard deviation of degree to the mean degree, where degree is defined as the number of edges incident to a node). (CV)2 is important for the spread of infectious diseases since it is known that where ρ0 is the value of R0 under the assumption of a homogenous network (i.e. no variance in the degree distribution) [1],[56]. Empirical networks We used the network data collected on the social network website Facebook (www.facebook.com) by Traud et al. [41]. The data contains the friendship network at five US universities, where nodes represent individuals (i.e. members of the university), and edges represent friendship links between two individuals. Additionally, the data includes covariate information (if available) about the individuals, such as the gender of the individual, the dormitory residence, major (field of specialization) etc. While such friendship network data are interesting for various reasons, they do not necessarily reflect the contact network relevant for the spread of infectious diseases. Clearly, a friendship connection between two individuals on a social network website does not necessarily mean that there is also a connection between the two individuals in the contact network relevant to the spread of infectious diseases. Thus, in order to obtain contact network data that are relevant for the spread of infectious diseases transmitted directly from person to person by the respiratory or close-contact route, we make the following assumptions: Individuals who have a friendship relation in the network, and who either (a) have the same dormitory residence, or (b) who major in the same field and the same class year, are likely to be in close enough physical contact on a regular basis as to be able to transmit an infection to each other. Thus, using the raw friendship data and the available information on dormitory residence, major, and class year, we extract the subgraph which reflects our assumptions. Having extracted the subgraph, we remove all nodes who are not part of the largest connected component (i.e. small subgraphs that are not part of the larger network). The networks thus reduce to the following contact networks: Caltech (620 nodes and 7,255 edges, Q = 0.788) Princeton (5,112 nodes and 28,684 edges, Q = 0.753) Georgetown (7,651 nodes and 79,799 edges, Q = 0.662) Oklahoma (10,386 nodes and 163,225 edges, Q = 0.914) North Carolina (13,081 nodes, 88,266 edges, Q = 0.812) We note that the modularity Q of these networks is within the range of modularities measured in the computationally generated networks (see for example Figure 1), with the exception of one network (Georgetown). Clearly, these networks will contain contacts that are not relevant for the spread of diseases (false positives) - at the same time, they will also miss some relevant contacts (false negatives). However, given the accuracy and amount of data, these networks are well suited to study the spread of infectious diseases on human contact networks, in particular for diseases transmitted directly from person to person by the respiratory or close-contact route. Degree distributions of these networks are shown in Suppl. Mat. Figure S2. Immunization algorithms The algorithms used to identify nodes can be divided into two classes: deterministic and stochastic algorithms. Deterministic algorithms require the complete information about each node (i.e. either the number or the identity of all connected nodes for each node in the network), and they rank nodes by processing that information by a procedure specific to that algorithm. Target nodes are then chosen by their rank (from high to low). Thus, for a given network structure, deterministic algorithms always give the same result, i.e. they identify the same target nodes (except for random choices when two nodes have exactly the same rank). Stochastic algorithms, on the other hand, do not require such detailed structural information - they identify target nodes by collecting information locally from randomly chosen nodes in the network. These algorithms represent the type of investigation-related information in actual epidemics. We will now describe a number of deterministic and stochastic algorithms as we have used them in the main text. Deterministic algorithms We identifiy target nodes by ranking nodes to one of the three following criteria: degree, betweenness centrality, and random-walk centrality. The degree of a node simply denotes the number of edges incident to a node. The betweenness centrality CB(i) of a node i is defined as where s, t and i are distinct nodes of the graph, σst is the total number of shortest paths between nodes s and t, and σst(i) is the number of those shortest paths that go through node i [38]. The random-walk centrality of a node i is a measure based on random walks, counting how often the node i is traversed by a random walk between any pair of nodes s and t. Following Newman [39], we rank nodes according to the random-walk measure where for i≠s, t. Here, Aij is the element in the adjacency matrix of the graph (0 or 1 in our case), and Tis is the element in the voltage matrix which is calculated as described in detail in Newman [39]. Nodes are ranked according to the measure chosen (i.e degree, betweenness centrality, or random-walk centrality). We then immunize nodes going from high to low rankings, until the desired immunization coverage is achieved. Stochastic algorithms We use two stochastic algorithms to identify target nodes without knowledge of the full network structure. In the algorithms described below, targets are identified and immunized if they have not been immunized before. The first algorithm, acquaintance immunization, has been described by Cohen et al. [42] and it works as follows: pick a random node v0 , and then pick a random acquaintance v1 , i.e. a randomly picked neighboring node of v0 . Immunize nodes that have been referred to as acquaintances at least n times until the desired immunization coverage is achieved. In the case n = 1, every acquaintance will be immunized immediately. The acquaintance strategy has been shown to identify highly connected individuals, particularly in fat-tailed networks (such as so-called scale-free networks). We propose another strategy, the community-bridge-finder (CBF) strategy, which rests on the observation that some individuals act as bridges between communities. The goal of the CBF algorithm is to identify such individuals based on random walks, without knowledge of the network structure, and thus without knowledge of the communities in a network. The algorithm works as follows: pick a random node vi = 0 and follow a random path (one node at a time, with the only condition that a node has not been visited by the random walk before). At every node vi≥2 , check if there is more than one connection from vi to any of the visited nodes (the requirement for more than one connection stems from the simple fact that every node vi will have at least one connection to vi−1 ). If there is just one back connection (i.e. from vi to vi−1 ), a potential target vi−1 has been identified. As an additional check, pick two random neighboring nodes of vi (other than vi−1 ) and check for connections back to the previously visited nodes vj