0

I have an (x,y) matrix coordinates representing a path.

M=[2 2;2 1;1 1;3 1;3 2;3 3;2 3]

How can I transform it into matrix path beginning at the starting point (1,1) and ending at (3,1) so that:

M=[1 1;2 1;2 2;2 3;3 3;3 2;3 1]

Thank you in advance.

sapienz
  • 152
  • 5
  • 1
    Perform DFS on the graph until all of the vertices are in the path (or you run out of possible paths). – beaker Jan 28 '17 at 20:41
  • Here's a DFS implementation for you, in case you need one: http://stackoverflow.com/questions/31979369/combining-pairs-in-a-string-matlab/31994782#31994782 – beaker Jan 28 '17 at 20:43

0 Answers0