Detecting the topologies of complex networks with stochastic perturbations