passing messages and adding neighbor nodes