[Graph] "Weighted Bacon number" (depth from node) with dijkstra visitor

Hi all, In order to find the depth of a source_node from other nodes in my graph, without weights, I use this simple example of the bacon BFS visitor via the tree_edge(). I also count the number of nodes from that source. //////// class bfs_vis : public boost::default_bfs_visitor { public: bfs_vis(unGraph::vertex_descriptor source, boost::shared_ptr< VertexStorage> storage) : s(source), cont(storage) { } template <typename Edge, typename Graph> void tree_edge(Edge e, const Graph& g) const { typename boost::graph_traits<Graph>::vertex_descriptor u = source(e, g), v = target(e, g); cont->depth_from->at(v) = cont->depth_from->at(u) + 1.0; } template <typename Edge, typename Graph> void discover_vertex(Edge e, Graph& g) { cont->node_count = cont->node_count + 1; } private: boost::shared_ptr<VertexStorage> cont; unGraph::vertex_descriptor s; }; //////// What would be an equivalent visitor for Dijkstra? Node count is ok but how do I calculate a "weighted bacon number" with dijkstra (boost::property<boost::edge_weight_t, float>)?? Thanks, Tasos

On Mon, 4 Feb 2013, The Maschine wrote:
Hi all, In order to find the depth of a source_node from other nodes in my graph, without weights, I use this simple example of the bacon BFS visitor via the tree_edge(). I also count the number of nodes from that source. (snip) What would be an equivalent visitor for Dijkstra? Node count is ok but how do I calculate a "weighted bacon number" with dijkstra (boost::property<boost::edge_weight_t, float>)??
The interface to Dijkstra's algorithm provides a parameter for a distance map, which appears to do exactly what you want. You should be able to add that as an argument and then remove the distance part from your visitor. -- Jeremiah Willcock
participants (2)
-
Jeremiah Willcock
-
The Maschine