Distributed algorithm and reversible network