udacity preprocess connected nodes in graph