implemented methods of DistanceMatrix class