Subspace-based algorithm for distance networks