title: Locate Fermat's point in a triangle using BFS
body: <p>Given 3 points in a grid, how would you find a point such that sum of distances of this point from all 3 points in minimized. An obvious answer to this problem is Fermat's triangle. I am interested in knowing if we can locate Fermat's point using a breadth first search algorithm in a graph.</p>
  
  <pre><code>struct node{
    int Person1X,Person1Y,Person2X,Person2Y,Person3X,Person3Y; //X and Y coordinates of all 3 persons
    int steps;   //sum of distances covered by all 3 person to reach this state
  }
  </code></pre>
  
  <p>While doing the BFS we could put a constraint, 
  if steps>min(sum of any two edges of the triangle with 3 persons as vertices) return;</p>
  
  <pre><code>if(Person1X=Person2X=Person2X)AND(Person1Y=Person2Y=Person3Y) return steps;
  </code></pre>