Included undirected parameter in the Distances algorithm