added new topological distance method for distance metrics, and fixed errors in matrix generator