Local hydrological conditions and spatial connectivity shape invertebrate communities after rewetting in temporary rivers

Temporary rivers (TRs) dominate global river networks and are increasing in occurrence and spatiotemporal extent. However, few studies have investigated the communities that establish after rewetting events (i.e. the end of the dry phase), when local hydrological conditions can shape the communities through species sorting, and the spatial connectivity of sites can also influence colonisation. Here, we analysed the relative importance of both local hydrological conditions and spatial connectivity on the invertebrate communities of seven not impacted Mediterranean TRs after rewetting. We quantified the frequency and duration of drying events and the time since flow resumed. We also quantified spatial connectivity based on each site’s position in the river network (i.e. network connectivity) and the presence of nearby disconnected streams. Overall, we found that both hydrological conditions and network connectivity played a significant role in structuring aquatic invertebrate communities after rewetting. Taxonomic richness, functional richness and functional redundancy decreased with the frequency and duration of drying events and increased with time since the most recent rewetting. Network connectivity showed a significant unimodal relationship with taxonomic and functional metrics. In contrast, the presence of nearby disconnected streams was negatively related to functional richness and functional dispersion. Given that flow intermittence in Mediterranean areas is expected to intensify under future global change scenarios, our results can be helpful to guide future conservation and management actions.

Abstract Temporary rivers (TRs) dominate global river networks and are increasing in occurrence and spatiotemporal extent. However, few studies have investigated the communities that establish after rewetting events (i.e. the end of the dry phase), when local hydrological conditions can shape the communities through species sorting, and the spatial connectivity of sites can also influence colonisation. Here, we analysed the relative importance of both local hydrological conditions and spatial connectivity on the invertebrate communities of seven not impacted Mediterranean TRs after rewetting. We quantified the frequency and duration of drying events and the time since flow resumed. We also quantified spatial connectivity based on each site's position in the river network (i.e. network connectivity) and the presence of nearby disconnected streams. Overall, we found that both hydrological conditions and network connectivity played a significant role in structuring aquatic invertebrate communities after rewetting. Taxonomic richness, functional richness and functional redundancy decreased with the frequency and duration of drying events and increased with time since the most recent rewetting. Network connectivity showed a significant unimodal relationship with

Introduction
River ecosystems that recurrently cease to flow or dry up at some point in time and space (i.e. temporary rivers, TRs) occupy more than 50% of the global river network (Messager et al., 2021) and they are becoming more abundant due to global change (Döll & Schmied, 2012;Sauquet et al., 2021). TRs are common in Mediterranean climates (Bonada & Resh, 2013;Cid et al., 2017) where they experience seasonal and predictable floods and droughts (McElravy et al., 1989;Gasith & Resh, 1999). These ecosystems fluctuate between two main periods: dry and wet, in which TRs experience different hydrological conditions (Gallart et al., 2012;Bonada et al., 2020). During the dry period, TRs dry up or have disconnected pools that can persist throughout the summer, whereas during the wet period TRs flow and instream habitats include both riffles and pools. These changing instream conditions impose a strong environmental filter that directly controls the taxonomic and functional composition of invertebrate communities (Williams, 2006;Gallart et al., 2012). In Mediterranean TRs, drying usually starts in late spring and early summer, when an increase in water temperature and a decrease in oxygen concentrations eliminate many lotic taxa, such as mayflies (Ephemeroptera), stoneflies (Plecoptera) and caddisflies (Trichoptera), i.e. EPT (Boulton & Lake, 2008;Bonada & Resh, 2013). During the dry period, many EPT insects cannot tolerate the conditions in pools, whereas lentic taxa as dragonflies (Odonata), beetles (Coleoptera) and true bugs (Hemiptera), i.e. OCH, increase in relative abundance (Acuña et al., 2005;Bonada et al., 2020). Later, in Mediterranean river catchments that are fed by surface runoff, flow resumption is typically triggered by increased precipitation and runoff in the headwaters, which is sometimes intense enough to cause flash floods that swiftly transform channels from completely dry to flowing strongly (Jacobson et al., 2000;Cohen & Laronne, 2005).
Invertebrate community recovery upon rewetting depends on the temporal dynamics of drying events (including frequency and duration) and the river network connectivity Bogan et al., 2015;Crabot et al., 2020). Within this context, resistance and resilience strategies play a key role in determining community assembly (Hershkovitz & Gasith, 2013;Bogan et al., 2017). Resistance strategies relate to the persistence of organisms in situ in dry habitats such as in the seedbank (Bohonak & Jenkins, 2003;Stubbington & Datry, 2013), and wet refuges such as isolated pools , whereas resilience strategies relate to the persistence of organisms ex situ and their subsequent colonisation via dispersal (Datry et al., 2014). The relative contribution of both strategies to community recovery upon rewetting is highly variable across regions and among river and disturbance types (Bonada et al., 2007a). Certain resistance strategies, such as the persistence of organisms in the hyporheic zone and its contribution to community recovery, may vary considerably depending on the river type (Dole-Olivier, 2011;Stubbington, 2012). Previous studies of aquatic invertebrate communities after rewetting in TRs across multiple climate types (e.g. arid: Stanley et al., 1994;temperate: Stubbington et al., 2009;Chester & Robson, 2011;Datry et al., 2012;tropical: Paltridge et al., 1997) have identified high richness of desiccation-tolerant taxa. In contrast, sediment rewetting experiments indicate that resistance strategies may play a negligible role in our study area (Folch, 2020). Resilience strategies can also be the main strategy for surviving the dry period in many regions (Fritz & Dodds, 2004;Acuña et al., 2005;Datry et al., 2014). This recolonisation via spatial dispersal can occur from perennial refuges including isolated water bodies as well as upstream and downstream reaches, by overland aerial dispersal Cañedo-Argüelles et al., 2015) or drift and active migration, respectively (Eveleens et al., 2019;Pařil et al., 2019).
The fragmentation of TR river networks by flow intermittence has different effects on the recolonisation of aquatic invertebrates depending on their dispersal abilities Phillipsen et al., 2015;Sarremejane et al., 2017a;Crabot et al., 2020). Strong drifters show local dispersal that is highly dependent on network connectivity (Bogan & Boersma, 2012;Sarremejane et al., 2020a), whereas insects with a winged adult phase might rapidly recolonise rewetted habitats even if they are relatively isolated from the river network Sarremejane et al., 2017b).
Overall, both local hydrological conditions and spatial connectivity can determine the taxonomic richness and functional diversity of aquatic invertebrate communities upon rewetting. Firstly, local hydrological conditions can constrain the number of taxa that inhabit a given site and filter certain ecological traits, therefore, affecting taxonomic and functional metrics. Several studies have shown that taxonomic and functional richness decline along a gradient of flow permanence (Bonada et al., 2007b;Schriever et al., 2015). Thus, taxonomic and functional richness may decrease in rewetted habitats as the length of the preceding dry phase increases. Also, rheophilic taxa such as EPT can be more common in TRs with greater connectivity to perennial reaches, where they are favoured by continuous flow Datry et al., 2014), whereas OCH can be more common in TRs with higher dry period durations because of their high affinity for pool habitats (Williams, 1996;Bonada et al., 2007b). Secondly, spatial connectivity can determine community assembly by affecting the capacity of dispersing invertebrates to reach suitable habitats (Heino et al., 2015;Cañedo-Argüelles et al., 2015;Sarremejane et al., 2017b). At high levels of spatial connectivity, species with strong dispersal abilities can colonise suitable habitats via mass effects and maintain viable populations throughout the river network, promoting their widespread dominance (Heino et al., 2015). Conversely, at highly isolated sites, dispersal limitation can lead stochastic processes to be the dominant influence on species distributions and thus community composition (Mykrä et al., 2007). Therefore, taxonomic richness can peak at intermediate levels of spatial connectivity (Mouquet & Loreau, 2003;Altermatt et al., 2013;Vanschoenwinkel et al., 2013).
In this study, we analysed the effects of local hydrological conditions and the relative importance of spatial connectivity on the composition of invertebrate communities approximately one month after rewetting in seven not impacted TRs in a Mediterranean river network. This time period is sufficient for aquatic invertebrate communities to assemble after flow resumption (Fowler, 2004;Vander Vorste et al., 2016), which usually occurs as floods in Mediterranean rivers (Cid et al., 2017). We used temperature data recorded continuously over 1.5 years to assess the temporal dynamics of drying events. Additionally, we analysed spatial connectivity using two metrics, one based on each site's position in the river network (i.e. network connectivity), which influences recolonisation by drift, and one based on its proximity to nearby disconnected streams (i.e. streams that did not flow directly into each studied subcatchment), which affects overland dispersal. Our first hypothesis (H1) was that taxonomic and EPT richness and functional metrics would decrease linearly with frequency and duration of drying events, and increase over time after the resumption of flow. We expected OCH richness to show the opposite response to hydrological metrics since OCH could be more common in pool conditions. Secondly, we hypothesised (H2) a unimodal relationship between both taxonomic and functional metrics and spatial connectivity metrics. Our third hypothesis (H3) was that aquatic passive dispersal would be more important than aerial active dispersal for colonising rewetted habitats, because high river flows during rewetting could favour drift of organisms from upstream reaches (McArthur & Barnes, 1985;Paltridge et al., 1997).

Study area
The study was carried out in Sant Llorenç del Munt i l'Obac Natural Park, a protected area in the Vallès Occidental region (Catalonia, NE Spain) (Fig. 1a). The area has a Mediterranean climate, with irregular and heavy rainfall, mostly in winter, some rainfall in spring and autumn, and dry summers. The underlying geology is dominated by karst limestone, with highly permeable substrates. Therefore, during summer, surface flow in TRs persists for hours to days after rainfall. Almost all TRs within the park dry up during summer, either with disconnected pools or completely dry riverbeds. There are also several permanent streams in areas where discharge from karstic aquifers exists, with very low flows during summer. The TRs sampled belong to two main catchments that discharge to the Mediterranean Sea: the Besòs and the Llobregat.

Invertebrate sampling and processing
We sampled seven TRs with similar instream conditions (Supplementary Table S1). Within them, we selected 32 sites which, based on previous studies (Rieradevall et al., 1999;Bonada et al., 2007b) and field observations, encompassed a wide hydrological gradient. Twenty-five sites were sampled approximately one month after rewetting, from the 18-21 November 2019, to ensure enough time for assembly of post-rewetting communities. A few weeks before sampling (from 21 to 23 October) intense rainfall and flash floods affected all of the sampled TRs (Supplementary Figs. 1, 2).
Each site consisted of a 100-m-long reach and was located 100-500 m from its nearest site. Invertebrates were collected by kick sampling with a 250-lm mesh net, covering all habitats in proportion to their  occurrence. Samples were preserved in 96% ethanol. Invertebrates were counted and identified in the laboratory to the lowest practical taxonomic level, usually genus except for some Diptera (Supplementary Table S2). Three taxonomic metrics were calculated: total taxa richness (TRic), EPT richness and OCH richness.

Functional traits
We used eight biological traits (and 39 categories) to characterise the functional features of invertebrate communities: life-cycle features, reproduction, aquatic stages, dispersal mode, resistance forms, respiration, and locomotion and substrate relation (Tachet et al., 2010, Supplementary Table S3). These traits can be related to resistance and resilience to drying (e.g. Bonada et al., 2007b;Aspin et al., 2019;Belmar et al., 2019). Feeding habits and food types were excluded because they have no direct relationship to resistance or resilience to drying (Sarremejane et al., 2020a;Crabot et al., 2020), and body size was excluded because trait databases may show limited concordance with the true size distribution of specimens (Orlofske & Baird, 2014). Each genus was coded according to its affinity to each trait category using a fuzzy coding approach (Chevenet et al., 1994), from 0 for no affinity, to 3 for the strongest affinity, except for one trait, locomotion and substrate relation, which was coded from 0 to 5 (Supplementary Table S4). Trait information for Oligochaeta and Hydrachnidia was unavailable and, therefore, these taxa were excluded from trait analyses.
We quantified the relative proportion of the four major dispersal modes considered in invertebrates from freshwater ecosystems, i.e. aquatic passive, aquatic active, aerial passive and aerial active (Sarremejane et al., 2020b), using the database of Tachet et al. (2010). The proportion of aerial active and aquatic passive dispersers served to test H3.

Functional metrics
We used three matrices to characterise the functional space and to estimate the functional metrics of aquatic invertebrates: a taxon counts by site matrix (i.e. sites 9 taxa), a matrix containing the fuzzy-coded trait profile for each taxon (i.e. taxa 9 traits), and the resulting community-level matrix representing the mean trait profile for each site (i.e. sites 9 traits).
We defined the functional space as a multidimensional Euclidean space, and we performed a Principal Component Analysis (PCA) using the taxa 9 traits matrix to obtain a set of uncorrelated axes that represented the variability of the trait categories contained in that matrix (Gutiérrez-Cánovas et al., 2015). We retained the first three principal components, which were the significant ones resulting from the application of the broken stick rule (Jackson, 1993). These principal components constituted the dimensions of the functional space in which we quantified functional metrics, and we checked their homogeneity following the method described in Múrria et al. (2020). Then, we built several simulated binary matrices with one category per trait, following a random sampling based on the probability that each category was present in a randomly generated individual belonging to a genus. These matrices were projected into the generated functional space to create clouds of points that simulate the suite of potential trait combinations that comprise inter-and intra-genus functional variability. We then calculated three components of functional diversity at the whole-community level: functional richness (FRic), functional dispersion (FDis), and functional redundancy (FR), using the R packages 'vegan' (Oksanen et al., 2019) and 'ade4' (Dray & Dufour, 2007). FRic quantifies the filling of the functional space and was estimated as the hypervolume enclosing the functional space filled by the community (Villéger et al., 2008). FDis describes the distribution of taxa in functional space and was calculated by averaging the Euclidean distance from each simulated point to the community centroid (Laliberté & Legendre, 2010). FR quantifies the degree of functional space overlap among taxa in the functional space (Rosenfeld, 2002) and was calculated by summing the total overlap in the functional space between each taxon pair in a community (Gutiérrez-Canovas et al., 2015). FRic reaches higher values when taxa have contrasting trait profiles, FDis when there are taxa with trait profiles that differ greatly from the community mean values, and FR when many taxa are functionally similar. Finally, each functional metric was standardised by its maximum from all communities, so that index values ranged between 0 and 1 (Mouchet et al., 2010;Bruno et al., 2016).

Local hydrological conditions
Two temperature data loggers (HOBO PendantÒ Temperature/Light logger) were installed from July 2018 to December 2019 in each site, one in a riffle and one in a pool, to monitor the flow intermittence, i.e. the proportion of zero-flow days for the entire data period. Loggers were set to log temperature at hourly intervals. We compared the diurnal temperature variation of loggers placed within the river with loggers hung from nearby trees to infer when a site was wet or dry (Gungle, 2006). First, we calculated the daily temperature range as the difference between the maximum and the minimum temperature. Then we fitted linear and sinusoidal regression models, being the former typical of loggers placed in perennial rivers and the latter typical of those installed in TRs ( Supplementary  Fig. 3). For each daily temperature range value, we calculated if it was closer to those predicted by the linear or the sinusoidal model. In the first case, we considered the site as wet, i.e. surface water was present, whereas in the latter, we considered the site as dry, i.e. surface water was absent or restricted to disconnected pools. We validated this approach using field observations and time-lapse photographs and found a prediction accuracy of 76%.
Due to data logger malfunction on very cold days and the loss of loggers washed out by floods, 44 of 69 loggers placed within the river had more missing values than recorded values. We filled in missing information about each site's status (wet/dry) using a logistic regression model based on the channel slope, altitude, geology, as well as antecedent humidity, precipitation and temperature. These variables have a major influence on the hydrology of TRs (Cid et al., 2017;Datry et al., 2017). For humidity, precipitation and temperature, we computed summary measures for 14, 30, and 90-day periods. For each period, we summarised the daily measurements as the median, mean and slope of a linear regression model across all measurements recorded during that period. We excluded days with missing measurements in this aggregation step. Hence, for each data logger and day, we obtained a total of 27 statistics summarising changes in humidity, precipitation, and temperature ( Supplementary Fig. 4), and combined these statistics with information on the river's slope, altitude, and geology to yield a set of 30 variables used to predict a site's status. The logistic regression model and the evaluation of its predictive performance are provided in Supplementary Appendix 1. We used the entire 1.5year data period to calculate two metrics to characterise the temporal dynamics of drying events for each sample: the total duration of drying events (TotDur), which represents the total number of zero-flow days, and the frequency of drying events (TotNum), which represents the number of drying events. In addition, we calculated the number of days between the most recent rewetting and each sampling event (i.e. days since rewetting).

Spatial connectivity
We delimited the entire river network of the Sant Llorenç del Munt i l'Obac Natural Park using geospatial data. Then, the network was divided into subcatchments, which represented the most coherent river networks in the dataset, and each containing one or more TR. Using these subcatchments, we built a synthetic network taking the river confluences as nodes (Fig. 2) using the R package 'igraph' (Csardi & Nepusz, 2006), with each site assigned to its nearest node using the function 'nn2' in the R package 'RANN' (Arya et al., 2019). We calculated each node's closeness centrality, to indicate the capacity of their position within the network to connect to other nodes (Freeman, 1979). We defined our TRs as directed networks with an upstream to downstream direction (i.e. dendritic network; Fig. 2). Therefore, we categorised closeness centrality by calculating the 'out-closeness' using the function 'closeness' in the package 'igraph'. By considering the 'out-closeness' as our centrality metric we assume that a higher closeness value for a given site implies higher isolation (i.e. upstream reaches) within a network (Borthagaray et al., 2020). Closeness provides a solid proxy of dendritic network structure and can relate significantly to biodiversity in river networks at theoretical, experimental, observational and management levels (Estrada & Bodin, 2008;Economo & Keitt, 2010;Altermatt, 2013;Borthagaray et al., 2020). We used closeness to characterise the potential for recolonisation through the river network by smallto large-scale drift.
We calculated a spatial connectivity metric, 'surrounding water', to capture overland dispersal by flying adult insects. For each site, surrounding water represents the total length of streams that did not flow directly into the subcatchment where the site was located within a Euclidean distance of 1 km. We chose a 1 km distance because it can capture most invertebrate colonisation events (Tonkin et al., 2014). This metric incorporates streams that are not connected to each other through the river network, and therefore indicates dispersal across a landscape ( Supplementary  Fig. 5). We used ArcMap 10.0 (ESRI, 1999) to generate the corresponding buffers and to quantify the total length of nearby disconnected streams. In spite of its ecological relevance (Cañedo-Argüelles et al., 2015), we did not calculate the distance from each site to the nearest perennial site, due to a lack of detailed hydrological data for the stream network.

Modelling
The relationships between response variables (i.e. TRic, EPT and OCH richness, FRic, FR, and FDis) and predictor variables (days since rewetting, TotDur, TotNum, closeness, and surrounding water) were tested using linear mixed-effect models (LMM) by applying the function 'lme' included in the R package 'nlme' (Pinheiro et al., 2021), after validating the Gaussian distribution of the response variables. Each model included predictor variables as fixed effects and the river as a random effect to control for the potential non-independence of sites within TRs. We used the function 'r.squaredGLMM' in the R package 'MuMIn' (Bartoń, 2020) to calculate two goodnessof-fit measures: the marginal R 2 (R 2 m), which indicates the variance explained by fixed effects, and the conditional R 2 (R 2 c), which represents that explained by both fixed and random effects. Based on exploratory analyses to identify the best-fitting models, unimodal relationships were used between community metrics and closeness. Closeness was log-transformed to improve the fit with response variables and closeness values were represented inverted so that its graphical representation is more intuitive (higher values correspond to higher centrality). To test the significance of unimodal relationships, each model was fitted using the maximum likelihood (ML) to compare it to the associated null model with likelihood ratio tests (Luke, 2017), using the function 'lrtest' in the R package 'lmtest' (Zeileis & Hothorn, 2002).
We used a null model procedure to determine whether the relationships between taxonomic and functional richness differed from those expected by chance, and thus to indicate whether observed functional metric responses were driven by taxonomic richness or predictor variables (Villéger et al., 2008). Basing on the sites 9 taxa and taxa 9 trait matrices used to construct the functional space, we randomly reassigned functional traits to each taxon (99 simulations) to recalculate their relationships with predictor variables (Bruno et al., 2016). For each simulation, we used the same procedure as used for the data models: we calculated FRic, FR, and FDis and re-examined their relationship with the same predictors using LMM regressions to obtain the simulated intercepts and slopes for each relationship. All analyses were conducted in R version 4.1.0 (R Development Core Team, 2021).

Dispersal trait analysis
The proportion of aerial active and aquatic passive dispersers was not related to any hydrological metric (Table 2 and Supplementary Fig. 6) nor surrounding water (Fig. 5g, h). Similarly, none of the disperser groups showed a strong unimodal relationship with closeness ( Fig. 4g, h), although the relationship was marginally significant for aerial dispersers (Table 3). Relationships between aerial passive and aquatic active dispersers and predictor variables are provided in Supplementary Figs. 6, 7 and Tables S5, S6.

Null models
For the significant relationships observed between functional metrics and predictor variables (Table 2, 3), null models revealed that the intercepts and slopes for the FRic models including hydrological metrics, closeness and surrounding water differed from null distributions (P \ 0.05), suggesting non-randomness (Supplementary Fig. 8 and Table S7). In contrast, the intercepts and slopes for the FR and FDis models were comparable to the null distribution (P [ 0.05), suggesting that the significant relationships found between FR and hydrological metrics and closeness, Table 2 LMM results relating taxonomic and functional metrics to hydrological metrics as fixed effects and river as a random effect Days since rewetting and the significant relationship between FDis and surrounding water were all driven by TRic (Supplementary Fig. 8 and Table S7).

Discussion
We found that both local hydrological conditions and network connectivity significantly affected invertebrate community composition after rewetting. Similarly, Cañedo-Argüelles et al. (2020) used a different but complementary approach (analysis of Bray-Curtis pairwise dissimilarities between communities) and found that both local hydrological conditions and spatial connectivity shaped invertebrate metacommunities in Mediterranean TR networks close to our study area. In addition, Crabot et al. (2020) found that local hydrological conditions Fig. 4 Relationships between taxonomic (a, c, e) and functional (b, d, f) metrics, dispersal trait categories (g, h) and closeness. Solid lines represent the fitted LMM values using unimodal relationships (see Table 3). Log-transformed closeness values were inverted so that higher values corresponded to a higher centrality (i.e. connectivity).
Abbreviations (a-f) are defined in the Fig. 3 caption. g Aerial active = proportion of aerial active dispersers, and h Aquatic passive = proportion of aquatic passive dispersers influenced invertebrate beta diversity, but the effects depended on the spatial drying pattern (e.g. beta diversity was higher for basins with intermittent headwaters and perennial downstream reaches than for basins with perennial headwaters and intermittent downstream reaches). These patterns likely reflect a combination of strong abiotic filters associated with seasonal hydrological variability in TRs , and dispersal limitation associated with river network fragmentation by flow intermittence , 2020Sarremejane et al., 2017a). We also found a reduction in taxonomic and functional metrics as the frequency and duration of drying events increased, supporting our H1. Our results are consistent with previous studies focusing on the rewetting phase (e.g. Acuña et al., 2005;Doretto et al., 2020) and other analyses of richness patterns in TRs (e.g. Datry et al., 2014;Schriever et al., 2015;Sarremejane et al., 2020a;Crabot et al., 2021). Sites with lower TotDur may support richer communities including taxa with a wider range of trait profiles, which can colonise and persist in less stressful conditions, thus reducing the influence of environmental filtering (Bonada et al., 2007b;Sánchez-Montoya et al., 2018). Similarly, a high frequency of drying events (i.e. high TotNum) can limit the maximum taxonomic and functional richness that a community can attain, because a high disturbance frequency prevents some taxa (e.g. K-strategists) from colonising and persisting Stubbington et al., 2017). Time since rewetting also influenced taxonomic and functional metrics, suggesting that the relatively long-term characteristics of drying regimes (here, TotDur and TotNum) and recent instream conditions both influence invertebrate community composition in TRs. In contrast, Arias-Real et al. (2021) found that the time since the last rewetting event had a minor effect on density and diversity metrics compared with the annual duration and frequency of drying events. This difference between Arias-Real et al. (2021) and or study could be related with the sampling period. Arias-Real et al. (2021) collected invertebrate samples just after the rainy season (February), whereas we collected them after rewetting (November). It is very likely that our study better captured the effects of the rewetting in terms of dispersal and colonisation, that could be lost to some extent in February when communities are stabilised and density-dependent processes (e.g. competition, predation) operate (Closs & Lake, 1994;Godoy et al., 2016). These findings highlight the importance of considering both recent and longer-term antecedent hydrological conditions (Sánchez-Montoya et al., 2018), especially in TRs with highly variable hydrological regimes, such as those in our semi-arid study area (Gallart et al., 2012).
Supporting our H1, EPT richness decreased with drying frequency (i.e. TotNum), likely because many EPT taxa are rheophiles and flow cessation and drying Significant results are denoted by asterisks (*P \ 0.05, **P \ 0.01, ***P \ 0.001) may prevent their persistence in TRs (Acuña et al., 2005;Williams, 2006;Sánchez-Montoya et al., 2018;Aspin et al., 2018). However, OCH richness also decreased significantly with TotDur and TotNum, partially rejecting our H1. After flow resumes, water flows through the river network, and lentic habitats which support high OCH richness in TRs (Williams, 1996;Bonada et al., 2007b) are less abundant. Moreover, sites with longer TotDur were more likely to dry fast without retaining lentic habitats, and thus did not have OCH populations that persisted after flow resumed. Functional analyses revealed that invertebrate communities from TRs with lower TotDur and TotNum occupied a higher trait hypervolume (i.e. higher FRic) and had a higher number of taxa with similar traits (i.e. higher FR). These results suggest a lower impact of local species loss on functional Fig. 5 Relationships between taxonomic (a, c, e) and functional (b, d, f) metrics, dispersal trait categories (g, h) and surrounding water (km). Solid lines represent the fitted LMM values (see Table 3). Abbreviations are defined in the Figs. 3 and 4 captions diversity in less intermittent rivers, potentially supporting recovery of ecosystem functioning after disturbances such as drying events . In contrast, at the most intermittent sites the loss of taxonomic diversity might have an impact in ecosystem functioning through a reduction or the loss of key ecological traits (Crabot et al., 2021). However, the relationships between FR and hydrological metrics should be taken with caution since they were significantly affected by differences in TRic, confirming that null models are essential to assess changes in FR due to the intimate relationship between taxonomic and functional richness.
As hypothesised in H2, we found a unimodal relationship between taxonomic metrics and the longitudinal connectivity of each site to the rest of the river network (i.e. closeness) that was usually not dependent on the river identity (i.e. small differences between R 2 m and R 2 c). In this study, closeness centrality captured the upstream-downstream relative position of the sites, which after a rewetting event is of great importance (Doretto et al., 2020). As all TRs were flooded during the same rainfall event, the identity of each TR lost relevance against the spatial isolation. The relevance of closeness has already been shown at larger landscape scales when assessing changes in species richness (Borthagaray et al., 2020). Interestingly, here this effect was detected at a smaller spatial scale, highlighting the potential of this metric for explaining diversity patterns in dendritic networks (Economo & Keitt, 2010;Carrara et al., 2012;Altermatt, 2013). Taxa richness may peak at intermediate levels of network connectivity Vanschoenwinkel et al., 2013) or species dispersal (Mouquet & Loreau, 2003), and this unimodal relationship likely reflects the interplay between the effects of dispersal limitation at isolated sites and mass effects at well-connected sites (Heino et al., 2015;Brown et al., 2018). At intermediate connectivity levels, low dispersal limitation allows the species to track environmental gradients and, at the same time, communities are not homogenised by mass effects (Heino et al., 2015). Overall, this could lead to a higher niche occupancy and a higher number of taxa. However, unimodal relationships might vary depending on the spatial extent and resolution considered, the topology of the network and the spatial autocorrelation among environmental variables (Thompson et al., 2020). According to the metacommunity theory (Heino et al., 2015) and empirical studies (Brown & Swan, 2010;Tolonen et al., 2017), and taking the dispersal abilities of the studied organisms into consideration (Sarremejane et al., 2020b), mass effects should be operating at the spatial scale that we assessed (i.e. differences within streams and between nearby streams). Contrarily, our results suggest that dispersal limitation could take place at small spatial scales in river and stream networks fragmented by droughts (i.e. TRs). However, this message needs to be taken with caution since we sampled the communities only one month after rewetting, when no sufficient time might have elapsed to allow for mass effects.
Our surrounding water metric, which described the spatial connectivity based on the length of nearby disconnected streams, had a negligible effect on taxonomic richness and trait dispersal, except for a negative relationship with functional richness and functional dispersion that was significantly affected by differences in TRic. Thus, overland aerial dispersal seems to have a minor importance for community assembly after rewetting in the studied river network. Although overland dispersal can play a key role for community assembly in river networks that are fragmented by droughts Razeng et al., 2016), the dispersal by drift and following the river network seems to be more important after the rewetting, when the whole network has been connected by floods. Accordingly, Doretto et al. (2020) reported that dispersal occurred mainly by drift through the river network in Alpine streams recovering from a dry period. Also, previous studies in perennial river networks showed that aquatic invertebrates disperse mainly following the river channel (Hughes, 2007;Brown & Swan, 2010;Rouquette et al., 2013). This could explain why we found no relationship between the spatial connectivity metrics and the relative abundance of aerial and aquatic dispersers (thereby rejecting our H3). The negative relationship between surrounding water with functional richness could be related with the fact that disconnected streams can promote the dispersal of strong flyers (e.g. Heteroptera and Odonata) that could dominate the communities through mass effects . However, additional studies covering a wider range of surrounding water are needed to validate this hypothesis.

Conclusion
This study advances our understanding on how aquatic invertebrate communities respond to the resumption of surface flow throughout river networks after periods of fragmentation by drying. We found that both hydrological conditions and spatial connectivity influenced the taxonomic richness and functional diversity of aquatic invertebrate communities. The main pathway for invertebrate recolonisation after rewetting was through the river network from upstream to downstream reaches. By characterising how network connectivity influences community composition after flow resumption in TRs, our results could inform conservation and management actions in these rivers, especially under future global change scenarios. For example, biodiversity conservation planning in TRs could be improved by quantifying the influence of spatial connectivity on recolonisation processes and identifying key refuges that serve as sources of colonists after rewetting.
Funding Open Access funding provided thanks to the CRUE-CSIC agreement with Springer Nature. This research was carried out in the FEHM-Lab (Freshwater Ecology, Hydrology and Management) funded by the ''Agència de Gestió d'Ajuts Universitaris i de Recerca'' (AGAUR) at the ''Generalitat de Catalunya'' (2017SGR1643)''. This work was also supported by the MECODISPER project (CTM2017-89295-P) funded by the Spanish Ministerio de Economía, Industria y Competitividad (MINECO)-Agencia Estatal de Investigación (AEI) and cofunded by the European Regional Development Fund (ERDF). DCM was also supported by the MECODISPER project. MC and NB were supported by the Serra Húnter programme of the ''Generalitat de Catalunya'', and NB was supported by the H2020 European Research and Innovation action Grant Agreement no. 869226 (DRYvER).

Data availability Data available as Supplementary Information.
Code availability (software application or custom code) Code available from the authors upon request.

Conflict of interest Not applicable.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.