訪問者の中から頂点のバンドルプロパティを変更するにはどうすればよいですか?訪問者のバンドルプロパティの変更
グラフをサブスクリプトする単純な方法を使用したいが、訪問者に渡されるグラフパラメータはconstなので、コンパイラは変更を許可しない。
私はグラフへの参照を訪問者に保存できますが、これは奇妙なようです。
/**
A visitor which identifies vertices as leafs or trees
*/
class bfs_vis_leaf_finder:public default_bfs_visitor {
public:
/**
Constructor
@param[in] total reference to int variable to store total number of leaves
@param[in] g reference to graph (used to modify bundled properties)
*/
bfs_vis_leaf_finder(int& total, graph_t& g) :
myTotal(total), myGraph(g)
{
myTotal = 0;
}
/**
Called when the search finds a new vertex
If the vertex has no children, it is a leaf and the total leaf count is incremented
*/
template <typename Vertex, typename Graph>
void discover_vertex(Vertex u, Graph& g)
{
if(out_edges(u, g).first == out_edges(u, g).second) {
myTotal++;
//g[u].myLevel = s3d::cV::leaf;
myGraph[u].myLevel = s3d::cV::leaf;
} else {
//g[u].myLevel = s3d::cV::tree;
myGraph[u].myLevel = s3d::cV::tree;
}
}
int& myTotal;
graph_t& myGraph;
};
私はリファレンスが道でなければならないと考え始めています。私は何かシンプルなものを見落としていると思っていたが、誰も今まで何も示唆していないので... – ravenspoint