title: Sorting Connected Edges in Matlab
body: <p>I have a list of edges stored in a random way and I am currently trying to rearrange them in a way they are all connected. I would like to know if is there anything already implemented in matlab for doing so or any algorithm I can look for to solve this.
  Let me be a bit more specific</p>
  
  <pre><code>1  2
  3  4
  2  5
  5  3
  </code></pre>
  
  <p>Must become</p>
  
  <pre><code>1   2
  2   5
  5   3
  3   4 
  </code></pre>
  
  <p>where the first number in each row is the second in the previous row.</p>
  
  <p>I thank you guys in advance for your help.</p>