|
Boost Users : |
Subject: [Boost-users] [graph] Modifying properties in a visitor?
From: James C. Sutherland (James.Sutherland_at_[hidden])
Date: 2009-01-15 16:52:50
Can a visitor modify properties in a graph? I would like to use the
following visitor with the breadth_first_search algorithm:
struct ExecPriorityVisitor : public boost::default_dfs_visitor
{
ExecPriorityVisitor();
void start_vertex( Vertex v, Graph& g ){ g[v].priority = 0; }
void examine_edge( Edge e, Graph& g ){
const Vertex src = boost::source(e,g);
Vertex dest = boost::target(e,g);
int& priority = g[dest].priority;
priority = std::max( priority, g[src].priority + 1 );
}
};
However, it fails to compile because apparently the graph argument
must be const. That implies that I cannot modify graph properties
from within the visitor? Why not?
Is the suggested approach to record the modifications in yet another
object and later impose that on the graph, or is there a way to
accomplish this through a visitor?
James
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