title: Implementing BFS on a graph
body: <p>I have vertices in graph which represent towns. I am trying to find a shortest path from point A to point B.</p>
  
  <p>I have created a graph class.</p>
  
  <pre><code>struct Edge{
      string name;
      vector&lt; Edge *&gt; v;
      Edge( string n ){
          name = n;
      }
  };
  
  class Graph{
  public:
          Graph(){};
          void addEdge( string start_point , string end_point){
              graph[ start_point ] -&gt; v.push_back( graph[ end_point ]);
          }
          void addPeak( string name ){
              graph[name] = new Edge(name);
              size++;
          }
          void printPeaks(){
              for( auto &amp;a : graph){
                  cout &lt;&lt; a . first &lt;&lt; endl;
              }
          }
      void getRoad( string starting , string ending ){
          map&lt; string , bool &gt; visited;
          queue&lt; Edge * &gt; q;
  
          for( auto &amp;a : graph ){
              visited[ a.first ] = false;
          }
  
          q.push( graph[starting] );
          while( ! q.empty( )){
                  Edge *tmp = q.front();
                  q.pop();
                  cout &lt;&lt; tmp -&gt; name &lt;&lt; endl;
                  if( tmp -&gt; name  == ending ){
                          cout &lt;&lt; "found " &lt;&lt; endl;
                          break;
                  }
                  for( unsigned int i = 0; i &lt; tmp -&gt; v.size() ; i++){
                      q.push( tmp -&gt; v [i]);
                  }
  
          }
      }
  private:
      map&lt; string , Edge *&gt; graph;
      int size = 0;
  };
  </code></pre>
  
  <p>I am adding vertices and edges as follows.</p>
  
  <pre><code>Graph g;
      g.addPeak("Prague");
      g.addPeak("Bratislava");
      g.addPeak("Budapest");
      g.addPeak("Berlin");
      g.addPeak("Moscow");
      g.addPeak("London");
      g.addEdge("Bratislava", "Berlin");
      g.addEdge("Bratislava" , "Budapest");
      g.addEdge("Bratislava" , "London");
      g.addEdge("Berlin" , "Moscow");
      g.addEdge("Budapest" , "Berlin");
      g.getRoad("Bratislava", "Moscow");
  </code></pre>
  
  <p>On the last line I want to find the shortest path from Bratislava to Moscow.
  As i demonstrated in code, I can find the path, but meanwhile all others town that have edge with Bratislava are also printed. Instead of the desired output</p>
  
  <pre><code>Bratislava 
  Berlin
  Moscow
  </code></pre>
  
  <p>it prints the following list.</p>
  
  <pre><code>Bratislava
  Berlin
  Budapest
  London
  Moscow
  </code></pre>
  
  <p>How can i store and print the path just the path i want?</p>