Consensus-based Algorithms for Distributed Network-State Estimation and Localization