title: Why is the Dijkstra Implementation working even if I use Simple Queue instead of priority queue?
body: <p>I tried implementing Dijkstra using normal queue and whenever I relax edge I add that vertex to the queue here is the implementation in java</p>
  <pre><code>import java.util.*;
  
  public class Main 
  {
      static HashMap&lt;Integer, List&lt;Edge&gt;&gt; graph = new HashMap&lt;&gt;();
      public static void main(String[] args)
      {
          graph.put(0, (List&lt;Edge&gt;)Arrays.asList(new Edge[]{
              new Edge(0, 1, 5),
              new Edge(0, 2, 2),
          }));
          graph.put(1, (List&lt;Edge&gt;)Arrays.asList(new Edge[]{
              new Edge(1, 3, 1),
          }));
          graph.put(2, (List&lt;Edge&gt;)Arrays.asList(new Edge[]{
              new Edge(2, 1, 1),
              new Edge(2, 3, 7),
          }));
          graph.put(3, (List&lt;Edge&gt;)Arrays.asList(new Edge[]{}));
          Integer[] dist = dijkstra(graph, graph.size(), 0);
          for(int i = 0;i &lt; dist.length;i++)
          {
              System.out.print(&quot; &quot; + dist[i]);
          }
      }
      public static Integer[] dijkstra(HashMap&lt;Integer, List&lt;Edge&gt;&gt; graph, int numNodes, int start)
      {
          Integer[] dist = new Integer[numNodes];
          for(int i = 0; i &lt; dist.length;i++)
          {
              dist[i] = Integer.MAX_VALUE;
          }
  
          LinkedList&lt;Integer&gt; queue = new LinkedList&lt;Integer&gt;();
  
          dist[start] = 0;
          queue.add(start);
          while(queue.size()!=0)
          {
              Integer current = queue.poll();
              List&lt;Edge&gt; edges = graph.get(current);
              for(Edge e : edges)
              {
                  if(dist[e.from] + e.weight &lt; dist[e.to])
                  {
                      dist[e.to] = dist[e.from] + e.weight;
                      queue.add(e.to);
                  }
              }
          }
  
          return dist;
      }
  }
  
  class Edge
  {
      int from, to, weight;
      Edge(int from, int to, int weight)
      {
          this.from = from;
          this.to = to;
          this.weight = weight;
      }
  }
  
  </code></pre>
  <p>as you can see i am adding vertex to queue whenever there is relaxation.
  My queustion is that is this correct Implementation, i mean will it work in all cases? and what drawbacks it has over priority queue?</p>