
On Tue, 18 Dec 2012, Brammert Ottens wrote:
Hi,
when I try to compile the following code it fails, but when I remove the graphviz part of the code it works just fine. Below I've added both my code and the error I get. Am I doing something wrong, or is this a bug in boost? The method ParseDIMECSGraph::ParseGraph simply parses a DIMECS challenge graph.
#include "stdafx.h" #include "ParseDIMECSGraph.h" #include
#include #include #include #include using namespace boost;
int _tmain(int argc, _TCHAR* argv[]) { typedef adjacency_list
> Graph; typedef graph_traits < Graph >::edge_descriptor edge_descriptor; Graph g = *ParseDIMECSGraph::ParseGraph("sample.gr");
std::ofstream ofs( "test.dot" ); write_graphviz(ofs, g); ofs.flush(); ofs.close();
typedef boost::graph_traits < Graph >::vertex_descriptor Vertex; std::vector<Vertex> predecessor(boost::num_vertices(g)); std::vector<int> distances(boost::num_vertices(g));
Vertex source = vertex(0, g); Vertex target = vertex(5, g);
property_map
::type weightmap = get(edge_weight, g); property_map ::type indexmap = get(vertex_index, g); boost::dijkstra_shortest_paths( g, source, &predecessor[0], &distances[0], weightmap, indexmap, std::less<int>(), closed_plus<int>(), (std::numeric_limits<int>::max)(), 0, default_dijkstra_visitor()); return 0; }
This seems to happen often with VC++. Try replacing "&predecessor[0]" by "boost::make_iterator_property_map(predecessor.begin(), get(boost::vertex_index, g))" and the same for "distances" and see if that fixes anything. -- Jeremiah Willcock