Boost logo

Boost Users :

Subject: [Boost-users] is visitor object destroyed immediately after the execution of depth_first_search?
From: Suresh Kumar (suresh.amritapuri_at_[hidden])
Date: 2009-12-15 19:54:48


Hi,
my idea is to get the finishing order of vertices in dfs by pushing
the vertices in a vector and return it later through a function return
value from my visitor class object.
//code snippet
int main()
{
my_visitor vis;
depth_first_search(g, visitor(vis));
cout << "size of fin vector = " << vis.finishingOrder.size() << endl;
//i get zero here!!!
}

class my_visitor: public default_dfs_visitor {
public:
        my_visitor(){}
        void finish_vertex(Vertex u, const Graph &
g){finishingOrder.push_back(u);};
        vector<Vertex> getFinishingOrder(void){return finishingOrder;}
private:
        vector<Vertex> finishingOrder;
};

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 every
time a vertex is finished.

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

Thanks
suresh

-- 
R. Suresh Kumar
PhD Student, Vislab
#216, Engineering II Bldg
University of California, Riverside,
CA 92521

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