title: How to traverse graph in boost use BFS
body: <p>I have problems getting to compile the BFS of a very simple graph. Whatever I do I get various compiler messages about unmatched method calls (I've tried <code>boost::visitor</code> and extending <code>boost::default_bfs_visitor</code> etc.)</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;boost/graph/adjacency_list.hpp&gt;
  #include &lt;boost/graph/breadth_first_search.hpp&gt;
  
  int main() {
    typedef boost::adjacency_list&lt;boost::vecS, boost::hash_setS, boost::undirectedS, uint32_t, uint32_t, boost::no_property&gt; graph_t;
    graph_t graph(4);
    graph_t::vertex_descriptor a = boost::vertex(0, graph);
    graph_t::vertex_descriptor b = boost::vertex(1, graph);
    graph_t::vertex_descriptor c = boost::vertex(2, graph);
    graph_t::vertex_descriptor d = boost::vertex(3, graph);
    graph[a] = 0;
    graph[b] = 1;
    graph[c] = 2;
    graph[d] = 3;
    std::pair&lt;graph_t::edge_descriptor, bool&gt; result = boost::add_edge(a, b, 0, graph);
    result = boost::add_edge(a, c, 1, graph);
    result = boost::add_edge(c, b, 2, graph);
    class {
    public:
      void initialize_vertex(const graph_t::vertex_descriptor &amp;s, graph_t &amp;g) {
        std::cout &lt;&lt; "Initialize: " &lt;&lt; g[s] &lt;&lt; std::endl;
      }
      void discover_vertex(const graph_t::vertex_descriptor &amp;s, graph_t &amp;g) {
        std::cout &lt;&lt; "Discover: " &lt;&lt; g[s] &lt;&lt; std::endl;
      }
      void examine_vertex(const graph_t::vertex_descriptor &amp;s, graph_t &amp;g) {
        std::cout &lt;&lt; "Examine vertex: " &lt;&lt; g[s] &lt;&lt; std::endl;
      }
      void examine_edge(const graph_t::edge_descriptor &amp;e, graph_t &amp;g) {
        std::cout &lt;&lt; "Examine edge: " &lt;&lt; g[e] &lt;&lt; std::endl;
      }
      void tree_edge(const graph_t::edge_descriptor &amp;e, graph_t &amp;g) {
        std::cout &lt;&lt; "Tree edge: " &lt;&lt; g[e] &lt;&lt; std::endl;
      }
      void non_tree_edge(const graph_t::edge_descriptor &amp;e, graph_t &amp;g) {
        std::cout &lt;&lt; "Non-Tree edge: " &lt;&lt; g[e] &lt;&lt; std::endl;
      }
      void gray_target(const graph_t::edge_descriptor &amp;e, graph_t &amp;g) {
        std::cout &lt;&lt; "Gray target: " &lt;&lt; g[e] &lt;&lt; std::endl;
      }
      void black_target(const graph_t::edge_descriptor &amp;e, graph_t &amp;g) {
        std::cout &lt;&lt; "Black target: " &lt;&lt; g[e] &lt;&lt; std::endl;
      }
      void finish_vertex(const graph_t::vertex_descriptor &amp;s, graph_t &amp;g) {
        std::cout &lt;&lt; "Finish vertex: " &lt;&lt; g[s] &lt;&lt; std::endl;
      }
    } bfs_visitor;
    boost::breadth_first_search(graph, a, bfs_visitor);
    return 0;
  }
  </code></pre>
  
  <p>How to visit the graph using <code>bfs_visitor</code>?</p>
  
  <p>PS. I've seen and compiled <a href="https://stackoverflow.com/questions/14126/how-to-create-a-c-boost-undirected-graph-and-traverse-it-in-depth-first-search">"How to create a C++ Boost undirected graph and traverse it in depth first search (DFS) order?"</a> but it didn't help.</p>