We simulated metacommunities in a hypothetical riverine network to investigate whether and how connectivity affects the species richness of groups with different dispersal abilities under different niche- and dispersal-assembly rules. The simulated network was represented by a graph in which the nodes represented habitat patches, each with a particular environmental condition. We built our model based on Müller's “colonization cycle” hypothesis, in which adult aquatic insects compensate for the gradual downstream movement of larvae by flying preferentially upstream to oviposition. Species occurrence in each patch was probabilistically determined, taking into account environmental filtering and/or dispersal ability in different assembly scenarios. Variation in local species richness was explained by connectivity in both assembly scenarios, especially when dispersal ability was weak. In niche assembly metacommunities, the effect of connectivity was also dependent on the location of preferable patches. In general, local species richness was higher when dispersal ability was strong. Our findings suggest that the role of connectivity in shaping riverine metacommunities is context dependent and that the spatial structure of riverine networks should be considered in monitoring freshwater biota.