title: Does Dijkstra's algorithm give shortest path always?
body: <p>I am learning Dijkstra's algorithm and had a basic query. I have a graph that looks as follows..(non-negative nodes):</p>
  
  <p>A---2-----B------16------D-----3-------F<br>
  *                                      *<br>
  *                                      *<br>
  3                                      4<br>
  *                                      *<br>
  C----------2---------------------------E  </p>
  
  <p>Not clear from above graph display, but AC has a distance of 3 and EF has a distance of 4.</p>
  
  <p>I am interested in finding shortest path between A and F.</p>
  
  <p>Consider destination node F. When we consider its nearest node, we get D (DF has weight 3 and EF 4). However, when we follow that path, we get the shortest path as: A,B,D,F (total distance: 19). </p>
  
  <p>A quick observation tells us that the shortest path is actually A,C,E,F (distance: 9). However, since in the 1st step, E was more distant than D, we followed D.</p>
  
  <p>Am I missing something here? Dijkstra's algorithm is clearly not showing the right result here.</p>