title: Can I use Prim's algorithm instead of Dijkstra's to find shortest path?
body: <p>I have been fighting all day in understanding Dijkstra's algorithm and implementing with no significant results. I have a matrix of cities and their distances. What I want to do is to given an origin point and a destination point, to find the shortest path between the cities.</p>
  
  <p>Example:</p>
  
  <pre><code>     __0__ __1__ __2__ 
   0  |  0  | 34  |  0  |
      |-----|-----|-----|
   1  | 34  |  0  | 23  |
      |-----|-----|-----|
   2  |  0  | 23  |  0  |
       ----- ----- -----
  </code></pre>
  
  <p>I started wondering if there is an other way to solve this. What if I apply Prim's algorithm from the origin's point and then I loop through the whole tree created until I find the destination point?</p>