title: Path between two cities using BFS in java
body: <p>I am trying to make a data structure for storing Map contents like roads and cities information. I am using linkedlist of vertices/cities and when a vertex/city is created it creates another linkedlist of edges in its constructor. 
  I need an algorithm to find a shortest path between two random cities.
  My modified BFS algo is not working absolute fine .
  ALgorithm:</p>
  
  <pre><code>public void getPath(String from, String to) {
          Queue&lt;cVertex&gt; Q = new LinkedList&lt;cVertex&gt;();
          List&lt;cVertex&gt; visited = new LinkedList&lt;cVertex&gt;();
          cVertex l = null;
          for (int i = 0; i &lt; c.size(); i++) {
              if (c.get(i).cityName.equals(to)) {
                  l = c.get(i);
                  break;
              }
          }
          for (cVertex a : c) {
              if (a.cityName.equals(from)) {
                  // System.out.println(a.cityName);
                  Q.add(a);
                  System.out.println("\nPath from " + a.cityName + " to "
                          + l.cityName);
                  break;
              }
          }
          while (!Q.isEmpty()) {
              cVertex u = Q.remove();
              System.out.print(u.cityName);
              if (u.cityName.equals(l.cityName)) {
                  return;
              }
              System.out.print("--&gt;");
              visited.add(u);
              for (cVertex w : c) {
                  for (Edge e : w.list) {
                      Edge n = e;
                      for (cVertex d : c) {
                          if (d.cityName.equals(e.to)) {
                              if (!visited.contains(d) &amp;&amp; !Q.contains(d))
                                  Q.add(d);
                          }
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>I need help!
  e.to means to is the cityName with which this edge is connected.</p>