added distance and connected nodes code