Function that connects nodes and their distances

Connect adjacent intersection nodes as pairs and calculate
the distance from pair to pair.