title: Using breadth first or depth first to separate connected components
body: <p><a href="https://i.stack.imgur.com/aTImJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aTImJ.png" alt="enter image description here"></a></p>
  
  <ol>
  <li><p>I have a data set that gave me the following picture that I have attached.Each node represents a cluster and the number inside the node represents the number of points in that cluster.</p></li>
  <li><p>I also wrote a code to trace back those points. As an example lets say I want to know which points out of all data, gives me the RED node with 46 points.I was able to find out.</p></li>
  <li><p>Here is where the problem starts. Suppose I have 2 nodes with 24 points in each. How can I know which points represents the red and the blue.(Like in the picture). Of course I can cross check the adjacent nodes and check for similar points. But I want a code to that. Basically I want to separate the connected components based on their adjacent nodes.</p></li>
  <li><p>So how can I separate these connected components using depth first or breadth-first search?</p></li>
  <li><p>I have been investigating breadthfirst and depth first search but I dont know how to do it. I am new to Matlab can someone help me.</p></li>
  </ol>