graph: code cleanup in adjacency list connected nodes