Boost logo

Boost :

Subject: Re: [boost] [BGL] on using visitor in dijkstra_shortest_path
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-07-02 14:42:32


Hi Andrew,
 I think i have found the source of the problem and its working now. There
was mismatch between property_map and recorder.

BTW, I just googled "record_edge_predecesors" and nothing showed up. I
couldn't immediately workout visitors for dijkstra even after reading the
manual and examples. Even after knowing the solution (pasted below) I don't
know how one could have reached here after reading the manual. Maybe its
just me and other users just getting along fine.

Anyways, I appreaciate the help.
-sandeep

the usage:
std::map<vertex_t, edge_t> epred;
  boost::associative_property_map< std::map<vertex_t, edge_t> >
epreds(epred);
  dijkstra_shortest_paths(gg, src,
predecessor_map(preds).weight_map(weights).distance_map(dists).visitor(make_dijkstra_visitor(record_edge_predecessors(epreds,
on_edge_relaxed()))));

I understand that the manual describes the visitors and gives few examples.
But I couldn't

On Thu, Jul 2, 2009 at 9:31 AM, Sandeep Gupta <gupta.sandeep_at_[hidden]>wrote:

> Thanks Andrew. I changed the name and that error is now gone but I am still
> having difficulty in defining visitor function:
> As I understand the visitor's argument should model "Dijkstra Visitor".
> Hence i created
> record_predecessor which is derived from dijkstra_visitor and therefore I
> assume would model "Dijkstra Visitor".
>
> After this I made following call
> vector<vertex_t> p(num_vertices(gg));
> record_predecessor<vector<vertex_t> > rp(p);
> dijkstra_shortest_paths(gg, src,
> predecessor_map(preds).weight_map(weights).distance_map(dists).visitor(rp));
>
> But this isn't legal. Please let me know what am i missing.
>
>
>
> I also tried using the record_predecessors method of visitor as following:
> vector<vertex_t> p(num_vertices(gg));
> dijkstra_shortest_paths(gg, src, dijkstra_shortest_paths(gg, src,
> predecessor_map(preds).weight_map(weights).distance_map(dists).visitor(make_dijkstra_visitor(record_predecessors(p,
> on_edge_relaxed()))));
> But this doesn't seem to work as well. The full code is available at
> http://codepad.org/98AovhZO . Attached below are the errors.
>
> */home/sandeep/Computing/boost_sandbox/boost-trunk/boost/graph/named_function_params.hpp:112:
> error: field
> ‘boost::bgl_named_params<boost::associative_property_map<std::map<boost::detail::edge_desc_impl<boost::bidirectional_tag,
> unsigned int>, int,
> std::less<boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned
> int> >, std::allocator<std::pair<const
> boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned int>, int>
> > > > ()(int), boost::edge_weight_t,
> boost::bgl_named_params<boost::associative_property_map<std::map<unsigned
> int, unsigned int, std::less<unsigned int>, std::allocator<std::pair<const
> unsigned int, unsigned int> > > >, boost::vertex_predecessor_t,
> boost::no_property> >::m_value’ invalidly declared function type*
>
>
> */home/sandeep/Computing/boost_sandbox/boost-trunk/boost/graph/dijkstra_shortest_paths.hpp:473:
> error: no matching function for call to ‘get_param(const
> boost::bgl_named_params<boost::dijkstra_visitor<boost::predecessor_recorder<std::vector<unsigned
> int, std::allocator<unsigned int> >, boost::on_edge_relaxed> >,
> boost::graph_visitor_t,
> boost::bgl_named_params<boost::associative_property_map<std::map<unsigned
> int, int, std::less<unsigned int>, std::allocator<std::pair<const unsigned
> int, int> > > >, boost::vertex_distance_t,
> boost::bgl_named_params<boost::associative_property_map<std::map<boost::detail::edge_desc_impl<boost::bidirectional_tag,
> unsigned int>, int,
> std::less<boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned
> int> >, std::allocator<std::pair<const
> boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned int>, int>
> > > > ()(int), boost::edge_weight_t,
> boost::bgl_named_params<boost::associative_property_map<std::map<unsigned
> int, unsigned int, std::less<unsigned int>, std::allocator<std::pair<const
> unsigned int, unsigned int> > > >, boost::vertex_predecessor_t,
> boost::no_property> > > >&, boost::edge_weight_t)’*
>
>
> thanks
> sandeep
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk