|
Boost Users : |
Subject: Re: [Boost-users] [BGL] passing a graph from one function to another
From: r89 (r8921025_at_[hidden])
Date: 2008-12-10 13:52:47
Andrew Sutton-2 wrote:
>
>> > main()
>> > {
>> > graph_t g = fun_A();
>> > fun_B(g);
>> > }
>>
>>
>> I tried as you suggested, and it does work in Release mode (Visual Studio
>> 2005), but NOT in Debug mode. Very strange.
>> The CPU keeps running at the line
>> return myGraph;
>> and does not go further. Any suggestions? Thanks!
>>
>
> Debug it and break the process while its "stuck". That should give you
> some
> idea why it may not be working. It sounds like it may be broken copy
> constructor or some place variable wasn't initialized correctly.
>
> It's also hard to say without more context. You might try posting your
> code
> or something similar to it.
>
> Andrew Sutton
> andrew.n.sutton_at_[hidden]
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Hi,
As suggested above, in my main function, I first create a graph, and then
pass the graph to the second function. The problem is, the program gets
stuck at the "return" statement in the first function, and never goes to the
second function. The strange thing is, the program works fine in VC2005
Release mode, but not in Debug mode. Here is the code:
main() {
graph_t g = BuildGraphShortestPath(Nnodes, N3mat, Nedge);
RunDijkstra(startPtInd, m_g);
}
graph_t BuildGraphShortestPath(unsigned long Nnodes, vnl_matrix<float>
&N3mat, int Nedge) {
graph_t g(Nnodes);
vertex_desc u, v;
float w = 0.0;
for (int i=0; i<Nedge; i++) {
u = vertex( (int)N3mat(i,0), g);
v = vertex( (int)N3mat(i,1), g);
w = (float)N3mat(i,2);
add_edge(u, v, Weight(w), g);
}
return g; // debugging gets stuck here, CPU runs 100%, but no progress
}
void RunDijkstra(int startPt, graph_t& g) {
vertex_desc s = vertex(startPt, g);
_parent.resize(num_vertices(g));
_distance.resize(num_vertices(g));
dijkstra_shortest_paths(g, s,
predecessor_map(&_parent[0]).distance_map(&_distance[0]));
}
Any suggestions would be appreciated!
-- View this message in context: http://www.nabble.com/-BGL--passing-a-graph-from-one-function-to-another-tp20582781p20941652.html Sent from the Boost - Users mailing list archive at Nabble.com.
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