count only edges to valid contigs in function ...count_distances