0

What am I doing wrong?

#include <vector>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using namespace std;

typedef boost::adjacency_list<> Graph;

void dijkstra(Graph &g, vector<double> &edge_weights, int source, vector<double> &dist,   vector<int> &prev) {
boost::dijkstra_shortest_paths(g, source,
                                 boost::weight_map(boost::make_iterator_property_map(edge_weights.begin(), get(boost::edge_index, g))));

}

(Compile with: g++ main.cc -L/usr/local/boost/)

Error:

/usr/include/boost/graph/detail/adjacency_list.hpp:2665: error: invalid initialization of non-const reference of type ‘boost::detail::error_property_not_found&’ from a temporary of type ‘boost::detail::error_property_not_found’

I think the problem might be that there's no default mapping from edges to integers. If so, how do I define one?

zoo
  • 1,901
  • 1
  • 17
  • 25

1 Answers1

2

Your graph does not have an edge_index property, which you are using in your creation of the iterator_property_map. You will need to add such a property to your graph and fill it in. See Boost Graph Library: Bundled Properties and iterating across edges and edge_index zero for all edges? for what needs to be done.

Community
  • 1
  • 1
Jeremiah Willcock
  • 30,161
  • 7
  • 76
  • 78