title: C++ Connected Hexagons on a Tile
body: <p>I have a problem where I need to represent hexagons on a tile by their centre (which I refer to as a node) in my graph. Given a tile of hexagons, how can I find if two hexagons <code>x</code> and <code>y</code> are connected?</p>
  
  <p><a href="https://i.stack.imgur.com/1es3F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1es3F.png" alt="enter image description here"></a><br>
  <sub>(source: <a href="http://domathtogether.com/wp-content/uploads/2012/10/hexagons.png" rel="nofollow noreferrer">domathtogether.com</a>)</sub>  </p>
  
  <p>The following would work on hexagons with their position in two dimensional space, however I want to represent their position by an integer coordinate <code>(0, 1), (0, 2), (0, 3), (1, 1), (1, 2), (1, 3) etc</code>.  </p>
  
  <pre><code>if (n1-&gt;getPoint().getEuclideanDistance(n2-&gt;getPoint()) &lt; diameter)
  {
      // The two are connected.
  }
  </code></pre>