Boost logo

Boost Users :

From: Rui Carvalho (rui.carvalho_at_[hidden])
Date: 2005-08-02 14:17:50


Hello,

I'm using the BFS visitor that appears in the BGL book (p 66), which can
also be found here:
http://boost.org/libs/graph/doc/kevin_bacon.html

I would like to compute a quantity that depends on the bacon number of a
vertex, but only to distance d_max as my graphs are quite big (and I need to
compute the quantity for each vertex, so I want a speedy computation).
Ideally, I'd like to write something like the code below (my code appears
after the comment), but this doesn't seem to work. Am I missing something
basic?

  template <typename DistanceMap>
  class bacon_number_recorder : public default_bfs_visitor
  {
  public:
    bacon_number_recorder(DistanceMap dist) : d(dist) { }

    template <typename Edge, typename Graph>
    void tree_edge(Edge e, const Graph& g) const
    {
      typename graph_traits<Graph>::vertex_descriptor
        u = source(e, g), v = target(e, g);
        d[v] = d[u] + 1;
        //end BFS if v is at a distance greater than d_max
        if (d[v]>dmax)
                return;
    }
  private:
      DistanceMap d;
  };

Thanks,
Rui


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net