title: How can a heap be used to optimizie Prim's minimum spanning tree algorithm?
body: <p>I have to solve a question that is something like this:<br>
  I am given a number N which represents the number of points I have. Each point has two coordinates: <strong>X and Y.</strong> </p>
  
  <p>I can find the distance between two points with the following formula:<br>
  <strong>abs(x2-x1)+abs(y2-y1)</strong>,<br>
  (x1,y1) being the coordinates of the first point, (x2,y2) the coordinates of the second point and <code>abs()</code> being the absolute value.  </p>
  
  <p>I have to find the minimum spanning tree, meaning I must have all my points connected with the sum of the edges being minimal. <em>Prim's algorithm is good, but it is too slow</em>. I read that I can make it faster using a <a href="http://en.wikipedia.org/wiki/Heap_%28data_structure%29" rel="nofollow">heap</a> but I didn't find any article that explains how to do that. </p>
  
  <p>Can anyone explain me how Prim's algorithm works with a heap(some sample code would be good but not neccesarily), please?</p>