title: Building tree/graph from image points
body: <p>I start to describe my problem with this picture:
  <img src="https://i.stack.imgur.com/prxGL.png" alt="enter image description here"></p>
  
  <p>In the picture, we can see some points (<em>black</em> dots). What I want to do is to first store all the points and then find the <strong>node</strong> points and the <strong>tip</strong> points (<em>red</em> dots). 
  What is more, I need to check if these red points can be connected by straight lines (along the black points) to find angles between the red lines. </p>
  
  <p>I don't know if I explained it clearly enough, but what I figured is that I should implement a tree/graph and than use some path finding to check if the red points are connected?</p>
  
  <p>Basically, I started with something like:</p>
  
  <pre><code>class Point {
  public:
  int x;
  int y;
  vector&lt;Point&gt; neighbors;
  
  Point(void);
  Point(int x, int y);
  }
  
  vector&lt;Point&gt; allPoints;
  </code></pre>
  
  <p>Where I store all the points in <code>allPoints</code> vector. Than for each <code>Point</code>, I check all his neighbors ([x+1,y], [x-1,y], [x+1,y+1], [x-1, y+1], ...) and store them in neighbors vector for that <code>Point</code>. </p>
  
  <p>Then, by the size of the neighbors vector, I determine if the Point is a <strong>node</strong> (3 or more neighbors), a <strong>tip</strong> (1 neighbor), or just some basic point (2 neighbors). </p>
  
  <p>And here comes the part, where I have no idea how to implement some path finding (to check whether there is a way for example from a tip point to the closest node point). </p>
  
  <p>What is more, I have no idea if my "tree" representation is good (probably is not). So if anyone would help me to achieve what I want, it would be great. </p>
  
  <hr>
  
  <p>P.S. I'm writing in C++ (and OpenCV) and VS2010.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>This is how it looks like in a real program (red lines are drown by me in paint, but this is what i want to achieve):</p>
  
  <p><img src="https://i.stack.imgur.com/47VfO.png" alt="enter image description here"></p>