title: When will Dijkstra's algorithm and Prim's algorithm produce different outputs?
body: <p>I know the difference between Prim's and Dijkstra's algorithm. The former produces a MST while latter gives shortest path from source to all node.  Mathematically, these aren't the same, so we wouldn't always expect the two algorithms to produce the same results.</p>
  
  <p>However, while trying different examples I am getting the same result. The pseudocode for Prim's algorithm and Dijkstra's algorithm also look very similar. Can someone please give me an example where Prim's produces a MST which will not be obtained while solving with Dijkstra's or vice-versa.</p>
  
  <p>Also, according to my knowledge. Both of these algorithm uses following approach. Please correct me if I am wrong:</p>
  
  <blockquote>
    <p>Find shortest i-j where i from set which has already been included and j
         from set which hasn't been included yet and then add j to the set.</p>
  </blockquote>