Search code examples
c++boostboost-graph

No matching function call for boost::get in graph


I'm modeling my graph after example geometry/07_a_graph_route_example from boost.

My Graph looks like this:

typedef boost::adjacency_list<
    boost::listS,
    boost::vecS,
    boost::directedS,
    gG_vertex_property<string, double, pointClass>,
    gG_edge_property<listClass, pointClass>
> graph_type;

graph_type Graph;

with gG_vertex_property and gG_edge_property as custom properties.

Now every time I try to call dijkstra_shortest_path with

     boost::dijkstra_shortest_paths(Graph, endVert,                             // Graph Object, End of Search Object
                                       &predecessors[0], &costs[0],                                             // Vectors to store predecessors and costs
                                       boost::get(boost::edge_weight, Graph),
                                       boost::get(boost::vertex_index, Graph),                                  // Vertex Index Map
                                       std::less<double>(), std::plus<double>(),                                // Cost calculating operators
                                       (std::numeric_limits<double>::max)(), double(),                          // limits
                                       boost::dijkstra_visitor<boost::null_visitor>());                         // Visitior, does nothing at the moment

as WeightMap i get:

error: no matching function for call to 'get' boost::get(boost::edge_weight, Graph)

And a whole lot of templates for add which do not fit my use case. How i'm reading the docs this is the standard way to do it. Are my properties missing something?

What am i doing wrong?

Thanks for your help.


Solution

  • I guess gG_vertex_property and gG_edge_property are "Bundled" properties (there's no so such thing as custom properties). If so, you should pass these instead of "boost::get(boost::edge_weight, Graph)", which tries to access "Internal" properties, completely separate thing. See https://www.boost.org/doc/libs/1_77_0/libs/graph/doc/bundles.html . I guess if properties are structs and edge weights are kept in gG_edge_property::weight, the correct code would be something like this:

     boost::dijkstra_shortest_paths(Graph, endVert,                             // Graph Object, End of Search Object
                                       &predecessors[0], &costs[0],                                             // Vectors to store predecessors and costs
                                       get(&gG_edge_property::weight, Graph), /*!!!!!!!!*/
                                       boost::get(boost::vertex_index, Graph),                                  // Vertex Index Map
                                       std::less<double>(), std::plus<double>(),                                // Cost calculating operators
                                       (std::numeric_limits<double>::max)(), double(),                          // limits
                                       boost::dijkstra_visitor<boost::null_visitor>());                         // Visitior, does nothing at the moment