Nestedness versus modularity in ecological networks: two sides of the same coin?


Correspondence author. E-mail:


1. Understanding the structure of ecological networks is a crucial task for interpreting community and ecosystem responses to global change.

2. Despite the recent interest in this subject, almost all studies have focused exclusively on one specific network property. The question remains as to what extent different network properties are related and how understanding this relationship can advance our comprehension of the mechanisms behind these patterns.

3. Here, we analysed the relationship between nestedness and modularity, two frequently studied network properties, for a large data set of 95 ecological communities including both plant–animal mutualistic and host–parasite networks.

4. We found that the correlation between nestedness and modularity for a population of random matrices generated from the real communities decreases significantly in magnitude and sign with increasing connectance independent of the network type. At low connectivities, networks that are highly nested also tend to be highly modular; the reverse happens at high connectivities.

5. The above result is qualitatively robust when different null models are used to infer network structure, but, at a finer scale, quantitative differences exist. We observed an important interaction between the network structure pattern and the null model used to detect it.

6. A better understanding of the relationship between nestedness and modularity is important given their potential implications on the dynamics and stability of ecological communities.


The architecture of complex networks of species interactions, such as predation, parasitism and mutualism, plays an important role in the persistence and stability of species-rich communities (Krause et al. 2003; Teng & McCann 2004; Fortuna & Bascompte 2006; Bascompte, Jordano & Olesen 2006; Rooney et al. 2006; Bastolla et al. 2009). Hence, understanding network structure and its underlying mechanisms is a crucial task for interpreting community and ecosystem responses to global change (Tylianakis et al. 2008).

One well-studied type of ecological network is that of mutual dependences between plants and their pollinators or seed dispersers. It is well established that interactions in these mutualistic networks are heterogeneously distributed among species. That is, the bulk of species have a few interactions, but a few species are much more connected than expected by chance (Jordano, Bascompte & Olesen 2003). This heterogeneity describes a species-level property. If we look at the identity of who interacts with whom at a community-wide level, these networks tend to show a significantly nested pattern wherein specialists interact with proper subsets of the species interacting with generalists (Bascompte et al. 2003). These patterns have also been found in host–parasite networks (Vázquez et al. 2005). More recently, a significantly modular pattern characterized by the existence of densely connected, non-overlapping subsets of species – called modules – has also been identified. In this case, modules are composed of species having many interactions among themselves as well as very few with species in other modules (Jordano 1987; Dicks, Corbet & Pywell 2002; Olesen et al. 2007; Dupont & Olesen 2009).

The dynamical implications of one of the two community-level patterns, nestedness, have begun to be explored. Recent theoretical studies have shown that a nested structure minimizes competition and increases the number of coexisting species (Bastolla et al. 2009), and also makes the community more robust to both random extinctions (Memmott, Waser & Price 2004; Burgos et al. 2007) and habitat loss (Fortuna & Bascompte 2006). On the other hand, there are fewer studies which investigate the dynamical consequences of the modular structure for mutualistic networks. Nevertheless, since the seminal work of May (1972), it has been considered that modular or compartmentalized patterns described in food webs increase network stability, retaining the impacts of a perturbation within a single module and minimizing impacts on other modules (Krause et al. 2003; Teng & McCann 2004; see, however, Pimm 1979).

In spite of the relevance of nestedness and modularity for the stability and persistence of communities, the relationship between these structural patterns remains unknown (see Fig. 1). Only Olesen et al. (2007) explored both nestedness and modularity and found coexistence of these patterns in some pollination networks (see also Ramos-Jiliberto et al. 2009; Valdovinos et al. 2009). However, these authors looked at these two network patterns independently using different null models. Recent warnings suggest that network patterns should be addressed jointly instead of addressing one network pattern at a time (Lewinsohn et al. 2006). Similarly, understanding the relationship between several network patterns will help us to accurately determine the relevant and redundant aspects of network structure (Vermaat, Dunne & Gilbert 2009).

Figure 1.

 Matrix representations of a bipartite network. (a) Nested matrix. (b) Modular matrix. (c) Nested and modular matrix. Each black square indicates an interaction between the species in the respective row and column. All networks have the same number of species (20) and the same number of interactions (25). The solid line represents the isocline of perfect nestedness.

In order to better understand the relationship between the two network properties, we have explored nestedness and modularity for a large collection of mutualistic and host–parasite networks using a rigorous comparative framework.

Materials and methods

Data set

We have compiled a set of 95 ecological communities of mutualistic (34 plant–pollinator and 22 plant–seed disperser) and antagonistic (39 host–parasite) interactions (see Appendix S1 in Supporting Information). Each of these communities can be represented as a bipartite network where interactions are established between species that belong to two different sets (e.g. between plant and animal or host and parasite) but not between species of the same set. Using this data set, we have calculated two community-level structural properties: nestedness and modularity.


We have estimated an index of nestedness (N) by using the Aninhado software (Guimarães & Guimarães 2006), a modified version of the Nestedness Calculator software (Atmar & Patterson 1993). Each network is represented as a matrix with species from one set as rows and species from the other one as columns. Each element of the matrix is 1 if that particular plant (or host) interacts with that particular animal (or parasite) and 0 otherwise. The algorithm arranges the presence/absence matrix in order to minimize the absences to the left and the presences to the right of an isocline of perfect nestedness (see Fig. 1a,c). For each unexpected presence or absence, a normalized measure of global distance to the isocline is calculated, and these values are averaged. By using an analogy with physical disorder, this measure is called temperature (T) with values ranging from 0 to 100 (Atmar & Patterson 1993; Guimarães & Guimarães 2006). Because in this paper we emphasize nestedness, or order, instead of disorder, we define the level of nestedness, N, as N=(100−T)/100, with values ranging from 0 to 1 (maximum nestedness; for more details, see Bascompte et al. 2003).

Recent comparative studies have examined in detail the appropriateness of different metrics for estimating nestedness, including the nestedness temperature used here (Ulrich, Almeida-Neto & Gotelli 2009). In order to explore the sensitivity of our results to the metric used, we have also calculated nestedness by using the analytical measure introduced by Bastolla et al. (2009). This measure is very similar to the one introduced by Almeida-Neto et al. (2008) and studied in detail by Ulrich et al. (2009).


There are several algorithms to detect modular structures in networks (see Newman & Girvan 2004; Guimerà & Amaral 2005a,b; Rosvall & Bergstrom 2007). Here, we use a module-finding algorithm (Newman & Girvan 2004) combined with a simulated annealing optimization approach (Guimerà & Amaral 2005a,b) to detect modules. The algorithm uses a heuristic procedure to find an optimal solution for the maximization of a function called modularity (Newman & Girvan 2004). Although modularity optimization has a resolution limit which makes its application risky on large networks (Fortunato & Barthélemy 2007), we have used this method because we have not included the largest available community data sets due to computational limitations for the null models used (see below). Although our networks are bipartite (i.e. there are two groups of nodes with interactions between but not within groups), we use a modularity algorithm for unipartite networks. This algorithm defines groups of plants and animals whose species are highly connected to each other, rather than groups of plants and groups of animals created as a function of their shared interactions.

Modularity M is defined as

image(eqn 1)

where NM is the number of modules, L is the number of links in the network, ls is the number of links between nodes in module s and ds is the sum of the number of links of the nodes in module s (Newman & Girvan 2004). This function maximizes the number of links between nodes belonging to the same module and minimizes the number of links between nodes belonging to different modules. Because of its heuristic nature, we have made 10 realizations of the algorithm for each real community and report the maximum value of modularity obtained.

Null models

Once we have estimated the values of nestedness and modularity for a community, we want to know whether these values are significant compared with a random expectation. Otherwise, the network structure detected could be just a consequence of the density of links or connectance (i.e. the fraction of actual links in relation to the total number of possible links). In the case of nestedness and modularity, defining the random expectation is tantamount to deciding on the appropriate null model.

Null models are pattern-generating models that deliberately exclude a mechanism of interest and allow for randomization tests of ecological and biogeographic data (Gotelli 2001). We have used two null models as templates to statistically contrast the values of nestedness and modularity. Note that our null models maintain the bipartite structure of the communities by not allowing connections between plants and plants (hosts and hosts) and between animals and animals (parasites and parasites). The first null model is probabilistic (see Bascompte et al. 2003; we will subsequently refer to it solely as the probabilistic model). This model probabilistically maintains the observed total number of interactions and approximately maintains the number of interactions, or degree, per species. The probability of drawing an interaction between any given plant (host) and animal (parasite) is the arithmetic mean of the interaction probability of the plant and the animal. Thus, the probability of drawing an interaction is proportional to the degree of both the plant and the animal. This null model was used to detect significance of nestedness in Olesen et al. (2007).

The second null model is a fixed null model (Gale 1957; Connor & Simberloff 1979; Gotelli 2000; we will subsequently refer to it solely as the fixed model). This null model maintains exactly the same number of interactions per species. There are two general strategies for obtaining random matrices keeping the number of interactions per species the same as in the real one: ‘swap’ algorithms and ‘fill’ algorithms. Although there is still some controversy regarding the suitability of the two procedures (Manly & Sanderson 2002; Gotelli & Entsminger 2003), it has been noted that they generate very similar results (Gotelli & Entsminger 2001).

In the swap algorithm, the original matrix is reshuffled by repeatedly swapping 2×2 submatrices that preserve the row and column totals (for an independent swap algorithm, see Roberts & Stone 1990 and for a sequential swap algorithm, see Manly 1995). Transpositions are created by randomly selecting a pair of rows and a pair of columns in the matrix, then the four cells are swapped if possible. If a swap is not possible, another pair of random rows and columns is selected. A modified version of the independent swap algorithm – the trial swap – can reduce the potential problem of exploring a biased subset of the null space and then increase the significance of a non-random pattern (Miklós & Podani 2004; Joppa et al. 2009). However, as our goal is not so much to detect the level of significance of a single network pattern but to compare two patterns of network organization, here we have used the independent swap algorithm by performing 10 000 random transpositions for the creation of each random matrix (Itzkovitz et al. 2004). It is worth noting that the independent swap null model was utilized by Guimerà & Amaral (2005a,b) and subsequently by Olesen et al. (2007) to detect the significance of modularity.

Which null model should be used is a fascinating challenge, and each should be assessed in relation to the trade-off between the type I and type II errors they convey (Sanderson, Moulton & Selfridge 1998; Gotelli 2000, 2001; Gotelli & Entsminger 2001, 2003; Manly & Sanderson 2002; Ulrich & Gotelli 2007). When detecting nestedness, probabilistic null models tend to have a high type I error (falsely rejecting the null hypothesis), while our fixed null model has previously been shown to exhibit a high type II error, i.e. incorrectly accepting the null hypothesis when it is wrong (Ulrich & Gotelli 2007). At any rate, using a null model that preserves both the number of ones in rows and columns presents important challenges in terms of uniformly sampling all null space, having sufficient degrees of freedom and implementation time. For reasons such as these, there has been a preference for the probabilistic model; this version has also been shown to have the smallest type I error compared with other probabilistic null models (Rodríguez-Gironés & Santamaría 2006).

We have generated an ensemble of 100 random matrices for each community with the probabilistic model and another ensemble of 100 matrices with the fixed model. Note that the probabilistic model can yield degenerate matrices, i.e. matrices with fewer species than the real communities because some species are not assigned any interactions. Although avoidance of such degenerate matrices is a matter of discussion (Gotelli 2000), we eliminate them here in order to avoid potential influences of the number of species on our analysis. In the population of 100 randomizations, therefore, all matrices have the same number of species. For each random matrix, we have calculated the values of nestedness and modularity to which we compare the values for the real communities.

Differences in degree distribution

As noted above, the probabilistic model only approximately maintains the degree per species. In fact, the probabilistic model tends to make specialist species less specialist and generalist ones less generalist (Bascompte et al. 2003). This makes the degree distribution of the resulting random matrices less heterogeneous. To quantify this effect, we calculate the agreement between the degree distribution of networks generated by the probabilistic model and that of the real communities in the following fashion. First, we measure the area inline image between the real cumulative distribution function P(k) and the model cumulative distribution function PM(k):

image(eqn 2)

where k is the degree. Second, we calculate the normalized area inline image where K is the two distributions’ observed support (i.e. the difference between the maximum and minimum values observed). Note that the normalization implies that values of inline image fall within the bounds [0, 1]. As the fixed model maintains the empirical degree distribution, inline image for all networks generated by this model.


We found that there is a significant correlation between nestedness and modularity for plant–pollinator communities (r=0·363, P=0·035) but not for plant–seed disperser (r=0·151, P=0·503) and host–parasite (r=−0·066, P=0·689) networks. However, we note that real communities differ among themselves with regard to both the number of species and of interactions which presents a possible confounding effect. By narrowing our focus on the values of nestedness and modularity calculated for the population of random matrices generated by the two null models, we were able to eliminate this confounding effect.

Using a population of randomizations for each real matrix and calculating the correlation between the two structural properties in each of these populations of randomizations, we observed that there is a change in the sign of the correlation between nestedness and modularity as a function of the connectance (see Fig. 2). For communities with low connectances, the higher the nestedness, the higher the modularity. By contrast, the higher the nestedness, the lower the modularity for communities with high connectances. Thus, an increase in the number of interactions for a fixed number of species reduces the possibility that the interaction matrix would be both nested and modular. This implies that only communities with low connectances are likely to simultaneously present nested and modular patterns. This confirms but constrains the results of Olesen et al. (2007) for pollination networks.

Figure 2.

 Correlation between nestedness and modularity depends on network connectance. Each circle represents the value of the correlation for 100 random matrices generated by each of the two null models for the same real community. Black and white circles indicate significant and non-significant correlations respectively. The solid line is the best fit linear regression. The dashed line separates positive and negative correlations and is shown as a guide for the reader.

The above general result is modulated quantitatively by the type of community (seed dispersal, pollination and host–parasite) and the type of null model used to infer statistical significance. Specifically, at a finer scale, the correlation coefficient between nestedness and modularity decreases significantly with network connectance (Fig. 2) for seed dispersal and host–parasite communities (r=−0·801, P<0·001; r=−0·625, P<0·001 for the fixed model and r=−0·710, P<0·001; r=−0·768, P<0·001 for the probabilistic one). For pollination communities, this relationship is significant only for matrices created with the probabilistic model (r=−0·718, P<0·001). Therefore, there is also a change in the magnitude of this relationship depending on the null model used for creating the random matrices. The probabilistic model exhibits a smaller range of coexistence for the two structural patterns. Additionally, the negative correlation between nestedness and modularity is observed at smaller values of connectance for the probabilistic model than for the fixed model (see Fig. 2).

The differences between null models also affect the detection of the nested and modular patterns in real communities. When compared to the probabilistic model, 77%, 88% and 69% of seed dispersal, pollination and host–parasite communities are significantly nested, respectively, compared to just 0%, 15% and 0%, when compared to the fixed model (see Appendix S1). When examining modularity, 9%, 29% and 38% of seed dispersal, pollination and host–parasite communities, respectively, are significantly modular when compared to the probabilistic model, in contrast to 23%, 59% and 67% when compared to the fixed model respectively. The results for nestedness do not change qualitatively when using the analytical measure (Bastolla et al. 2009). The primary difference is that when compared to the probabilistic model, the analytical measure less frequently indicates significant nestedness. Importantly, there is a significant positive correlation between the tendency to detect significant nestedness, as measured by the z-score, for the metric based on nestedness temperature and the analytic measure for the two null models (r=0·930, P<0·001 and r=0·747, P<0·001 respectively).

It is worth noting that the five communities which are significantly nested according to the fixed model are also significantly modular according to that model and significantly nested when compared to the probabilistic model. In the same way, 23 of the 27 significantly modular communities according to the probabilistic model are also significantly nested according to that model and significantly modular according to the fixed model. This implies that both null models are very conservative for the specific patterns they tend to detect as significant. That is, if a community is nested according to the fixed model, that community should also be nested compared to the probabilistic model. Similarly, if a community is modular according to the probabilistic model, that community should also be modular when compared to the fixed model because the probabilistic model is more conservative in detection of significant modularity. It appears that there is strong interplay between the structural patterns of the networks and the null models which detect them. This result builds on the interaction between null model and index of nestedness found by Ulrich & Gotelli (2007).

One factor which helps explain why the probabilistic model tends to detect nestedness more frequently than the fixed one is that the fixed null model exhibits high type II error when detecting nestedness, i.e. it incorrectly accepts the null hypothesis more frequently (Ulrich & Gotelli 2007). As noted above, the trial swap reduces the type II error through an improvement of the sampling of the parameter space (Miklós & Podani 2004). Accordingly, Joppa et al. (2010) have found that the fraction of mutualistic communities significantly nested increases to about one of three when using a version of the trial swap and the nestedness temperature used here. This, however, is not incompatible with contributions from additional factors. Among others, there could be correlations between nestedness and degree distribution (see Medan et al. 2007).

In 52% of the communities, there is a significant difference (P<0·001) in the degree distribution of both plants (hosts) and animals (parasites) in at least 50% of the random matrices. This fraction increases to 94% if we allow that only one of the two degree distributions needs to be significantly different. The correlation between these differences and the differences in nestedness values predicted by the two null models is also significant (r=0·521, P<0·001, see Fig. 3). Greater differences in the degree distribution are strongly associated with greater differences in nestedness. Hence, the less heterogeneous the degree distribution, the lower is the nestedness value for matrices generated by the probabilistic model. These differences in the degree distribution are not significantly correlated with network connectance (r=0·080, P=0·442), which is consistent with the fact that this null model probabilistically maintains the overall number of interactions. Therefore, it seems that the probabilistic model increases the chance to detect significantly nested communities because it directly reduces the heterogeneity of the degree distribution. This implies type I errors and further explains the differences in nestedness detection between the two null models.

Figure 3.

 Relationship between the differences in the degree distribution and differences in mean nestedness for random matrices generated by the probabilistic model. Each circle represents the values for the set of randomizations for a given community. The solid line is the best fit linear regression. Differences in the degree distribution are due to the fact that matrices generated with the probabilistic model exhibit less heterogeneous degree distributions than real communities. Hence, the less heterogeneous the degree distribution, the lower the nestedness value of matrices generated with the probabilistic model. Recall that the fixed model maintains the exact degree distribution of the real communities.


Our current study methodologically improves that of Olesen et al. (2007) in at least two ways. First, the randomization in the test for modularity preserves the bipartite character of these networks (plants can interact only with animals). Second, the randomization uses exactly the same null model for checking the significance of both nestedness and modularity. More importantly, from a conceptual point of view, our current study explores the correlation between these two network patterns; specifically, we address how such a correlation is mediated by network connectance and by the interaction between the network pattern and the null model used to detect it. Despite these differences, our extended and improved exploration confirms the results by Olesen et al. (2007) as at least 15% of the communities are significantly nested and modular for both null models, all of them plant–pollinator networks.

Both nestedness (Bastolla et al. 2009) and modularity (May 1972; Teng & McCann 2004) are thought to provide benefits for ecological communities. In the context of our study, the intricate relationship between nestedness and modularity has clear potential to temper or augment the different implications of the two patterns. Consequently, as previously suggested by Lewinsohn et al. (2006), simultaneously looking at several network patterns can substantially advance our understanding of the architecture of ecological networks.

Recently, Vermaat et al. (2009) analysed the covariance among structural properties of food webs. They observed that 20 distinct properties could largely be captured in three major dimensions related to connectance, species richness and net primary productivity respectively. By contrast, we find here that nestedness and modularity do not appear to provide overlapping or redundant information; in fact, the relationship between these two properties and connectance implies the existence of trade-offs in how densely connected communities can fruitfully organize their connections.

It will be interesting to see how an additional property of host–parasite interactions – intervality – fits into the picture we provide here (Mouillot, Krasnov & Poulin 2008). This could contribute to the fact that a large fraction of host–parasite networks are significantly modular when comparing with the two null models. Hence, it appears that antagonistic interactions may tend to be organized in compartments even when they are densely connected.

Apart from this fact, one might have expected larger differences between the different types of networks in our analysis, in particular as the interactions in some are mutualistic, while in the others they are antagonistic. However, we do not find qualitative differences in how the correlation between nestedness and modularity changes with network connectance which appear to arise as a consequence of network type. Nevertheless, we observe here that the most highly connected communities tend to exhibit only one of these two properties.

One potential explanation of this fact is simply that it is exceedingly difficult to organize a large number of interactions. By contrast, it is possible that early on in its assembly, a simple fluctuation makes a community tend toward one pattern over the other and it continues along the same path. Another exciting alternative is that communities dynamically rearrange their interactions, via successful and unsuccessful introductions, speciations, or via extinctions, in one form or the other due to locally relevant features which are not accounted for in our meta-analysis. In either case, the fundamental question of why some communities are more densely connected than others also remains to be fully explained.


This work was funded by a PhD Fellowship from the Spanish Ministry of Education and Science (to M.A.F.), a CSIC-JAE Postdoctoral Fellowship (to D.B.S.), grants CGL2006-0373 (MCINN) and P07-RNM2824 (Junta de Andalucia) (to P.J.), and the European Heads of Research Councils, the European Science Foundation, and the EC Sixth Framework Programme through a EURYI (European Young Investigator) Award (to J.B.). This is publication n 667 of the Mitrani Department of Desert Ecology. We are thankful to the Centro de Supercomputación de Galicia (CESGA) for computing facilities.