Dijkstra adjacency list
<p>I have run into a problem converting pseudocode of Dijkstras algorithm into actual code. I was given and adjacency list such as "Location - adjacent location - distance to location," example for one node: AAA AAC 180  AAD 242  AAH 40.
My task was to read a file organized as adjacency list as described, and compute the shortest path from one node to another. 
Here is the Dijkstra pseudocode:</p>

<pre><code>    void dijkstra( Vertex s )
    {
        for each Vertex v
        {
          v.dist = INFINITY;
          v.known = false;
        }
      s.dist = 0;
        while( there is an unknown distance vertex )
         {
          Vertex v = smallest unknown distance vertex;
          v.known = true;

         for each Vertex w adjacent to v
          if( !w.known )
           {
           DistType cvw = cost of edge from v to w;
           if( v.dist + cvw &lt; w.dist )
             {
    // Update w
           decrease( w.dist to v.dist + cvw );
           w.path = v;
             }
            }
           }
    }
</code></pre>

<p>im having the most trouble with the line "for each Vertex w adjacent to v"
Here is my nonworking code:</p>

<pre><code>import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Dijkstra {

    public static boolean isInteger(String s) {
        return isInteger(s, 10);
    }

    public static boolean isInteger(String s, int radix) {
        if (s.isEmpty())
            return false;
        for (int i = 0; i &lt; s.length(); i++) {
            if (i == 0 &amp;&amp; s.charAt(i) == '-') {
                if (s.length() == 1)
                    return false;
                else
                    continue;
            }
            if (Character.digit(s.charAt(i), radix) &lt; 0)
                return false;
        }
        return true;
    }

    public static void dijkstra(Vertex[] a, Vertex s, int lineCount) {
        int i = 0;
        while (i &lt; (lineCount)) // each Vertex v
        {
            a[i].dist = Integer.MAX_VALUE;
            a[i].known = false;
            i++;
        }

        s.dist = 0;
        int min = Integer.MAX_VALUE; //

        while (!(a[0].known == true &amp;&amp; a[1].known == true &amp;&amp; a[2].known == true &amp;&amp; a[3].known == true
                &amp;&amp; a[4].known == true &amp;&amp; a[5].known == true &amp;&amp; a[6].known == true &amp;&amp; a[7].known == true
                &amp;&amp; a[8].known == true &amp;&amp; a[9].known == true &amp;&amp; a[10].known == true &amp;&amp; a[11].known == true
                &amp;&amp; a[12].known == true)) {
            System.out.println("here");
            for (int b = 0; b &lt; lineCount; b++) {

                if (a[b].dist &lt; min &amp;&amp; a[b].known == false) {
                    min = a[b].dist;
                }
            }
            int c = 0;
            while (c &lt; lineCount) {

                if (a[c].dist == min &amp;&amp; a[c].known == false) {
                    break;
                }
                c++;
            }
            System.out.println(min);

            a[c].known = true;
            int adjSize = a[c].adj.size();

            int current = 0;

            System.out.println(adjSize);

            while (current &lt; adjSize - 1) {

                String currentAdjacent = (String) a[c].adj.get(current);
                int p = 0;

                while (p &lt; lineCount) {
                    if (a[p].name.equals(currentAdjacent)) {

                        if (!a[p].known) {
                            String cvwString = (String) a[c].distance.get(current);
                            int cvw = Integer.parseInt(cvwString);
                            System.out.println(" This is cvw" + cvw);
                            System.out.println("Here2");

                            if (a[c].dist + cvw &lt; a[p].dist) {
                                a[p].dist = a[c].dist + cvw;
                                a[p].path = a[c];
                            }
                        }
                    }
                    p++;
                }
                current++;
            }
        }
    }

    public static class Vertex {
        public List adj; // Adjacency list
        public List distance;
        public boolean known;
        public int dist; // DistType is probably int
        public Vertex path;
        public String name;

        // Other fields and methods as needed
    }

    public static void printPath(Vertex v) {
        if (v.path != null) {
            printPath(v.path);
            System.out.print(" to ");
        }
        System.out.print(v);
    }

    public static void main(String[] args) throws IOException {

        int lineCounter = 0;

        BufferedReader br = new BufferedReader(new FileReader("airport.txt"));
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {

                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();

                lineCounter = lineCounter + 1;
            }

            Vertex[] arr = new Vertex[lineCounter];
            for (int i = 0; i &lt; lineCounter; i++) {
                arr[i] = new Vertex();
                arr[i].adj = new LinkedList&lt;String&gt;();
                arr[i].distance = new LinkedList&lt;Integer&gt;();
            }
            ;

            //
            int arrayCounter = 0;
            String everything = sb.toString();
            String[] lines = everything.split("\\s*\\r?\\n\\s*");

            for (String line1 : lines) {
                arr[arrayCounter] = new Vertex();

                arr[arrayCounter].adj = new LinkedList&lt;String&gt;();
                arr[arrayCounter].distance = new LinkedList&lt;Integer&gt;();
                String[] result = line1.split("\\s+");

                for (int x = 0; x &lt; result.length; x++) {
                    if (x == 0) {
                        arr[arrayCounter].name = result[0];
                        continue;
                    } else if (isInteger(result[x])) {
                        arr[arrayCounter].distance.add(result[x]);
                        continue;
                    } else {
                        arr[arrayCounter].adj.add(result[x]);
                        continue;
                    }
                }

                arrayCounter++;
            }

            for (int i = 0; i &lt; 12; i++) {
                System.out.println(arr[i].name);
            }
            System.out.println(lineCounter);
            dijkstra(arr, arr[3], lineCounter - 1);
            printPath(arr[11]);

        } finally {
            br.close();
        }
    }
}
</code></pre>

<p>Using my vertex class as is I was using a series of while loops to first, traverse the adjacency strings stored in a linked list while comparing to see which vertex is equivalent to the adjacency list string. Is there a better way to code "for each Vertex w adjacent to v" using my Vertex class? And apologies ahead for messy code and any others style sins i may have committed. Thanks!</p>