
Hi all,
The following code is from
http://www.boost.org/doc/libs/1_37_0/libs/graph/example/dijkstra-example.cpp
and it works fine on my computer.
However, if I change
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 };
to
int *weights = new int[9];
and, similarly, change the edge_array to
Edge *edge_array = new Edge[9];
(followed by assigning the weights and edges of course), then the results
are different than the original code.
Can anyone see why they are different? The reason I need to dynamically
allocate, is because I don't know the number of nodes and edges at compile
time. Please provide suggestions, thanks a lot!
(Code below comes from
http://www.boost.org/doc/libs/1_37_0/libs/graph/example/dijkstra-example.cpp)
typedef adjacency_list < listS, vecS, directedS,
no_property, property < edge_weight_t, int > > graph_t;
typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
typedef std::pair