Added method to connect adjacent nodes