The inference of an underlying network topology from local observations of a complex system composed of interacting units is usually attempted by using statistical similarity measures, such as cross-correlation (CC) and mutual information (MI). The possible existence of a direct link between different units is, however, hindered within the time-series measurements. Here we show that, for the class of systems studied, when an abrupt change in the ordered set of CC or MI values exists, it is possible to infer, without errors, the underlying network topology from the time-series measurements, even in the presence of observational noise, non-identical units, and coupling heterogeneity. We find that a necessary condition for the discontinuity to occur is that the dynamics of the coupled units is partially coherent, i.e., neither complete disorder nor globally synchronous patterns are present. We critically compare the inference methods based on CC and MI, in terms of how effective, robust, and reliable they are, and conclude that, in general, MI outperforms CC in robustness and reliability. Our findings could be relevant for the construction and interpretation of functional networks, such as those constructed from brain or climate data.