calculate adjacent nodes implemented