title: Finding all possible routes Java
body: <p>I am doing a project which i have to load a list of flights details from a text file. I read the text file and have load the 3 values into a hashmap. The 3 values are in this format (Airport ID, To, From). The To and From are being put into a list before putting into hashmap together with the ID. </p>
  
  <p>I am <strong>having trouble with finding all possible routes from a selected To and From</strong>. I have read up on Dijkstra's algorithm but i did not know how to apply this due to lack of knowledge. </p>
  
  <p>Below is an example of my code which i am able to find the direct flight and flight with 1 transfer point. </p>
  
  <pre><code>for (int i = 0; i &lt; route.get("all").size(); i++) {
          String boardAir = route.get("all").get(i).from;
          String alightAir = route.get("all").get(i).to;
          if (boardAir.equals(ar.boardAirport) &amp;&amp; alightAir.equals(ar.alightAirport)) {
              airline = route.get("all").get(i).id;
              System.out.println("Direct Airlines = " + alr.airline1.get(airline));
              System.out.println("From = " + ar.airport1.get(boardAir) + "\tDestination = " + ar.airport1.get(alightAir));
              System.out.println();
          } else {
              System.out.println("No direct flight found.");
          }
          if (boardAir.equals(ar.boardAirport)) {
              for (int j = 0; j &lt; route.get(route.get("all").get(i).id).size(); j++) {
                  String transfer = route.get(route.get("all").get(i).id).get(j).from;
                  String finalDest = route.get(route.get("all").get(i).id).get(j).to;
  
              }
          }
      }
  </code></pre>