Given a matrix of distances between points in one dimension, I'd like to use R to convert the matrix into an ordered vector of points from left to right (or right to left, doesn't matter) as well as outputting a vector of distances from the first element of that vector to all subsequent elements.
For example, this matrix:
> m2
A B C D
A 0 11 2 6
B 11 0 9 5
C 2 9 0 4
D 6 5 4 0
...represents the following relationship:
2 4 5
A--C----D-----B
And I'd like to output the vectors
X = c(A, C, D, B) (or c(B, D, C, A))
Y = c(2, 4, 5) (or c(5, 4, 2)
I would be grateful for any help with this.