Boost logo

Boost Users :

Subject: [Boost-users] dijkstra and associative property map
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-03-26 18:57:08


Hi,
 Attached below is the code to call Dijkstra over property_map data
structures. The current definition of associative property map is
incompatible for dijkstra. Somehow there is mismatch with respect to
operator[]. Attach below is the code and the error.

std::map<vertex_t, vertex_t> pred;
  boost::associative_property_map< std::map<vertex_t, vertex_t> >
    preds(pred);

  std::map<vertex_t, double> dist;
  boost::associative_property_map< std::map<vertex_t, double> >
    dists(dist);

  std::map<vertex_t, double> weight;
  boost::associative_property_map< std::map<vertex_t, double> >
    weights(weight);

  vertex_t v;
  //vertex_t v1 = preds[v];
   dijkstra_shortest_paths(tg, v,
                           predecessor_map(preds).
                           weight_map(weights).
                           distance_map(dists)
                           );

Error:
/home/sandeep/Computing/boost_1_38_0/boost/property_map.hpp:314:
error: no match for ‘operator[]’ in ‘(const
boost::associative_property_map<std::map<unsigned int, double,
std::less<unsigned int>, std::allocator<std::pair<const unsigned int,
double> > > >&)((const
boost::associative_property_map<std::map<unsigned int, double,
std::less<unsigned int>, std::allocator<std::pair<const unsigned int,
double> > > >*)(& pa))[k]’
/home/sandeep/Computing/boost_1_38_0/boost/property_map.hpp:458: note:
candidates are: typename
UniquePairAssociativeContainer::value_type::second_type&
boost::associative_property_map<UniquePairAssociativeContainer>::operator[](const
typename UniquePairAssociativeContainer::key_type&) const [with
UniquePairAssociativeContainer = std::map<unsigned int, double,
std::less<unsigned int>, std::allocator<std::pair<const unsigned int,
double> > >]

Thanks
sandeep


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net