title: Find min in Linked list
body: <p>I'm trying to find the min in a linked list of Vertices. This is what I wrote, but it is faulty. I don't get an error, but my program doesn't work and I think this is the source of the error. What am I doing wrong? </p>
  
  <pre><code>      Iterator itr = vertices.iterator();
        Vertex smallest= getVertex(s);
        Vertex temp;
        while (itr.hasNext()){
            smallest=(Vertex)itr.next();
             if(itr.hasNext() &amp;&amp; vertices.size()&gt; 1 ){//there are at least 2 vertices left
                  temp = (Vertex)itr.next();
                  if (temp.distance&lt; smallest.distance){
                      smallest = temp;
                  }
            }
       }
  </code></pre>