Boost logo

Boost Users :

Subject: [Boost-users] boost graph library, default_dfs_visitor, dfs
From: List User (listuser_at_[hidden])
Date: 2009-12-15 01:48:41


Hi

Please see the code below.

class my_visitor: public default_dfs_visitor {
public:
        my_visitor(){}
        void finish_vertex(Vertex u, const Graph & g);
        vector<Vertex> getFinishingOrder(void){return finishingOrder;}
//private:
        vector<Vertex> finishingOrder;//stores the vertices in the finishing
order

};

template<typename Vertex, typename Graph>
void my_visitor::finish_vertex(Vertex u, const Graph & g){
        finishingOrder.push_back(u);

}

main.cpp has the following:
my_visitor vis;
depth_first_search(g, visitor(vis));//to get the finishing order on
vertices
cout << "size of fin vector = " << vis.finishingOrder.size() << endl;

My problem: size of the finishingOrder vector is zero outside the
my_visitor::finish_vertex method. I checked its size inside the
my_visitor::finish_vertex method and its value is increasing...

Does I miss something in the understanding of the visitor concept?
Thanks
suresh

      



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