Distributed Message-passing Algorithm