I know how to compare two distance matrices if they order the points in the same way, but what if that is not guaranteed? Say we have 3 points n1, n2 and n3, and their distance matrix:
0 4 5
4 0 3
5 3 0
Then another set of points m1, m2 and m3 and their distance matrix:
0 3 4
3 0 5
4 5 0
If I directly compare the two matrices (e.g. using Mantel's test), those two would be quite different. But if we reorder the points, they are actually equivalent (n1 = m3, n2 = m1, n3 = m2).
So how can we compare two matrices considering this point permutation? A BF way is to try each permutation and take the highest similarity, but that would be O(n!).
For one-dimension case I found this solution: Given two arrays, find the permutations that give closest distance between two arrays. But I'm not sure how to use it in my case.